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

Support for floating-point delta in counters #37

Merged
merged 3 commits into from
Nov 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
language: java
jdk:
- oraclejdk8
- oraclejdk7
Copy link
Contributor

Choose a reason for hiding this comment

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

Why dropping Oracle Java7?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@masci, please take a look at travis-ci/travis-ci#7884
basically, oraclejdk7 is no longer available

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for the link, merging!

- openjdk7
- openjdk6

install: mvn install -DskipTests -Dgpg.skip
2 changes: 2 additions & 0 deletions src/main/java/com/timgroup/statsd/NoOpStatsDClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public final class NoOpStatsDClient implements StatsDClient {
@Override public void close() { }
@Override public void count(String aspect, long delta, String... tags) { }
@Override public void count(String aspect, long delta, double sampleRate, String... tags) { }
@Override public void count(String aspect, double delta, String... tags) { }
@Override public void count(String aspect, double delta, double sampleRate, String... tags) { }
@Override public void incrementCounter(String aspect, String... tags) { }
@Override public void incrementCounter(String aspect, double sampleRate, String... tags) { }
@Override public void increment(String aspect, String... tags) { }
Expand Down
28 changes: 28 additions & 0 deletions src/main/java/com/timgroup/statsd/NonBlockingStatsDClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,34 @@ public void count(final String aspect, final long delta, final double sampleRate
send(String.format("%s%s:%d|c|@%f%s", prefix, aspect, delta, sampleRate, tagString(tags)));
}

/**
* Adjusts the specified counter by a given delta.
*
* <p>This method is non-blocking and is guaranteed not to throw an exception.</p>
*
* @param aspect
* the name of the counter to adjust
* @param delta
* the amount to adjust the counter by
* @param tags
* array of tags to be added to the data
*/
@Override
public void count(final String aspect, final double delta, final String... tags) {
send(String.format("%s%s:%s|c%s", prefix, aspect, NUMBER_FORMATTERS.get().format(delta), tagString(tags)));
}

/**
* {@inheritDoc}
*/
@Override
public void count(final String aspect, final double delta, final double sampleRate, final String...tags) {
if(isInvalidSample(sampleRate)) {
return;
}
send(String.format("%s%s:%s|c|@%f%s", prefix, aspect, NUMBER_FORMATTERS.get().format(delta), sampleRate, tagString(tags)));
}

/**
* Increments the specified counter by one.
*
Expand Down
36 changes: 35 additions & 1 deletion src/main/java/com/timgroup/statsd/StatsDClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,41 @@ public interface StatsDClient extends Closeable {
* array of tags to be added to the data
*/
void count(String aspect, long delta, double sampleRate, String... tags);


/**
* Adjusts the specified counter by a given delta.
*
* <p>This method is a DataDog extension, and may not work with other servers.</p>
*
* <p>This method is non-blocking and is guaranteed not to throw an exception.</p>
*
* @param aspect
* the name of the counter to adjust
* @param delta
* the amount to adjust the counter by
* @param tags
* array of tags to be added to the data
*/
void count(String aspect, double delta, String... tags);

/**
* Adjusts the specified counter by a given delta.
*
* <p>This method is a DataDog extension, and may not work with other servers.</p>
*
* <p>This method is non-blocking and is guaranteed not to throw an exception.</p>
*
* @param aspect
* the name of the counter to adjust
* @param delta
* the amount to adjust the counter by
* @param sampleRate
* percentage of time metric to be sent
* @param tags
* array of tags to be added to the data
*/
void count(String aspect, double delta, double sampleRate, String... tags);

/**
* Increments the specified counter by one.
*
Expand Down