Skip to content

Add a "distribution_time" method#248

Merged
remeh merged 2 commits intoDataDog:masterfrom
jordan-brough:distribution-time
Apr 11, 2022
Merged

Add a "distribution_time" method#248
remeh merged 2 commits intoDataDog:masterfrom
jordan-brough:distribution-time

Conversation

@jordan-brough
Copy link
Contributor

Note: New PR for #200 with tests added.


Add a "distribution_time" method to facilitate measuring timing for
a yielded block and report it as a distribution metric instead of as a
histogram metric.

@jordan-brough
Copy link
Contributor Author

@remeh @djmitche here's a new PR for #200 with tests added now. Apologies for letting this drop off my radar!

If you'd prefer to re-open #200 that's fine, just lmk.

# @example Report the time (in ms) taken to activate an account
# $statsd.distribution_time('account.activate') { @account.activate! }
def distribution_time(stat, opts = EMPTY_OPTIONS)
opts = { sample_rate: opts } if opts.is_a?(Numeric)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added this while adding specs, to mimic what happens in the timing method below. Is that what you'd like to do here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect this is for backward-compatibility, so can probably be omitted here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall I go ahead and remove this then? cc @remeh

@jordan-brough
Copy link
Contributor Author

jordan-brough commented Feb 19, 2022

Are there other specs besides spec/statsd_spec.rb that you'd like me to add?

Also is something wrong w/ the CircleCI specs? They failed due to this error:

No configuration was found in your project. Please refer to https://circleci.com/docs/2.0/ to get started with your configuration.

@djmitche
Copy link
Contributor

It looks like the patch is based on a version of master that still used circleci (ef41904). A rebase should help.

To facilitate measuring timing for a yielded block and report it as a
distribution metric instead of as a histogram metric.
@jordan-brough
Copy link
Contributor Author

@djmitche thanks, I've rebased on latest master and force-pushed.

Copy link
Contributor

@djmitche djmitche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, but I'd like @remeh to take a look as well, based on reservations expressed in #200.

# @example Report the time (in ms) taken to activate an account
# $statsd.distribution_time('account.activate') { @account.activate! }
def distribution_time(stat, opts = EMPTY_OPTIONS)
opts = { sample_rate: opts } if opts.is_a?(Numeric)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect this is for backward-compatibility, so can probably be omitted here.

@jordan-brough
Copy link
Contributor Author

@remeh does this look ok?

Copy link
Contributor

@remeh remeh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM! Thanks for the added tests and sorry for the late review 🙇

@jordan-brough
Copy link
Contributor Author

jordan-brough commented Mar 7, 2022

Great! I left a follow-up comment above. Anything else before someone can merge this? Thanks again.

@jordan-brough
Copy link
Contributor Author

@djmitche @remeh just following up on this. Are we ok to merge this?

@remeh
Copy link
Contributor

remeh commented Apr 11, 2022

Yep absolutely, latest change + the additional tests are great! Sorry for the latency @jordan-brough

@remeh remeh merged commit 1870ba7 into DataDog:master Apr 11, 2022
@jordan-brough jordan-brough deleted the distribution-time branch April 11, 2022 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants