Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add arbitrary count method #24

Merged
merged 3 commits into from
Feb 24, 2019

Conversation

nastevens
Copy link
Contributor

Sometimes in hot-path code it is more economical to track a counter internally and only update the StatsD instance periodically. This is as opposed to using incr and decr repeatedly. So this PR adds a count method that takes an arbitrary integer value to update a counter statistic by.

Also fixed a couple random bugs:

  • Benchmarks were failing to compile due to library changes (the benchmarks aren't normally run so it's easy to miss breaking changes)
  • The decrement metric wasn't pre-allocating enough string space so it would end up allocating every time anyway.

Benchmarks were failing to compile due to a couple of changes in the
rest of the library.

Signed-off-by: Nick Stevens <[email protected]>
The counter decrement metric actually needs 5 characters to store the
constant part of the string to account for the "-" sign on "-1". This
wasn't breaking anything, but the String was being forced to reallocate
each time.

Signed-off-by: Nick Stevens <[email protected]>
Sometimes in hot-path code it is more economical to track a counter
internally and only update the StatsD instance periodically. This is as
opposed to using `incr` and `decr` repeatedly.

This commit adds `count` method that takes an arbitrary integer value to
update a counter statistic by.

Signed-off-by: Nick Stevens <[email protected]>
@mcasper
Copy link
Owner

mcasper commented Feb 24, 2019

Thank you for the great contributions @nastevens!

@mcasper mcasper merged commit 53e1b19 into mcasper:master Feb 24, 2019
@mcasper
Copy link
Owner

mcasper commented Feb 24, 2019

Published in 0.6.0

@nastevens nastevens deleted the add-arbitrary-count-method branch February 27, 2019 21:17
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.

2 participants