-
Notifications
You must be signed in to change notification settings - Fork 6
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 :by option to increment and decrement #20
Add :by option to increment and decrement #20
Conversation
**Why is this change necessary:** clojure-dogstatsd-client didn't have a way to increment or decrement by a value different than one. **How does this change address the issue:** Add an optional `:by` option to the increment and decrement function. Implement `increment` and `decrement` by calling java-dogstatsd-client's `count` method, which supports incrementing or decrementing by other values than one. (This is the method that java-dogstatsd-client's `incrementCount` and `decrementCount` call.) Add unit tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the contribution. This looks pretty awesome -- I have one small question for you. Once that's looked at, I'd be happy to merge and cut a new release :)
@@ -41,29 +41,29 @@ | |||
(when-not (and client once?) | |||
(shutdown!) | |||
(alter-var-root #'client (constantly | |||
(com.timgroup.statsd.NonBlockingStatsDClient. | |||
(NonBlockingStatsDClient. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is covered by the import line in the module above, is it necessary to fully qualify this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly, the class is imported into the current namespace, so I changed the code to refer to it directly instead of fully qualifying it. (Not sure I understand your question?)
This is just a small clean-up edit, unrelated to the new feature. Fine to revert it if you'd prefer the fully qualified name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah okay, I gotcha. Sorry I was reading the PR backwards 😅
README.md
Outdated
@@ -24,6 +24,7 @@ Somewhere in your code, you should setup the client: | |||
|
|||
;; Increment or derement a counter | |||
(statsd/increment "counter") | |||
(statsd/increment "counter" {:by 2.5 :sample-rate 3.3 :tags ["foo" "bar"]}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd suggest removing sample-rate
and tags
and add a comment to describe what by
is intended to do :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, changed it.
Thanks for the contribution :) |
Why is this change necessary:
clojure-dogstatsd-client didn't have a way to increment or decrement
by a value different than one.
How does this change address the issue:
Add an optional
:by
option to the increment and decrement function.Implement
increment
anddecrement
by callingjava-dogstatsd-client's
count
method, which supports incrementing ordecrementing by other values than one. (This is the method that
java-dogstatsd-client's
incrementCount
anddecrementCount
call.)Add unit tests.