Skip to content
This repository was archived by the owner on Jul 18, 2025. It is now read-only.

Commit 701faca

Browse files
Merge pull request #8 from finn-no/bugfix/vanilla-statsd-time-semantics
restores "recordExecutionTime" compatibility with vanilla statsd
2 parents 3aa86c2 + b99aab9 commit 701faca

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
bin
22
build
3-
*.iml
3+
*.iml
4+
/target/

src/main/java/com/timgroup/statsd/NonBlockingStatsDClient.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ public void gauge(String aspect, long value, String... tags) {
374374
*/
375375
@Override
376376
public void recordExecutionTime(String aspect, long timeInMs, String... tags) {
377-
recordHistogramValue(aspect, (timeInMs * 0.001), tags);
377+
send(String.format("%s%s:%d|ms%s", prefix, aspect, timeInMs, tagString(tags)));
378378
}
379379

380380
/**

src/test/java/com/timgroup/statsd/NonBlockingStatsDClientTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,7 @@ public void stop() throws Exception {
214214
client.recordExecutionTime("mytime", 123);
215215
server.waitForMessage();
216216

217-
assertThat(server.messagesReceived(), contains("my.prefix.mytime:0.123|h"));
217+
assertThat(server.messagesReceived(), contains("my.prefix.mytime:123|ms"));
218218
}
219219

220220
/**
@@ -235,7 +235,7 @@ public void stop() throws Exception {
235235
client.recordExecutionTime("mytime", 123, "foo:bar", "baz");
236236
server.waitForMessage();
237237

238-
assertThat(server.messagesReceived(), contains("my.prefix.mytime:0.123|h|#baz,foo:bar"));
238+
assertThat(server.messagesReceived(), contains("my.prefix.mytime:123|ms|#baz,foo:bar"));
239239
} finally {
240240
// reset the default Locale in case changing it has side-effects
241241
Locale.setDefault(originalDefaultLocale);
@@ -250,7 +250,7 @@ public void stop() throws Exception {
250250
client.recordExecutionTime("mytime", 123, "foo:bar", "baz");
251251
server.waitForMessage();
252252

253-
assertThat(server.messagesReceived(), contains("my.prefix.mytime:0.123|h|#baz,foo:bar"));
253+
assertThat(server.messagesReceived(), contains("my.prefix.mytime:123|ms|#baz,foo:bar"));
254254
}
255255

256256

0 commit comments

Comments
 (0)