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 :by option to increment and decrement #20

Merged
merged 2 commits into from
Jan 14, 2020

Conversation

bbvebjorn
Copy link
Contributor

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.

**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.
Copy link
Contributor

@rymndhng rymndhng left a 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.
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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"]})
Copy link
Contributor

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 :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, changed it.

@rymndhng rymndhng merged commit 4114094 into unbounce:master Jan 14, 2020
@rymndhng
Copy link
Contributor

Thanks for the contribution :)

@rymndhng
Copy link
Contributor

rymndhng commented Jan 14, 2020

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