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

StatsDEmitter rounds rates/percentages to 0 #3936

Merged
merged 1 commit into from
Feb 16, 2017

Conversation

michaelschiff
Copy link
Contributor

StatsD expects that metric values be integers. Some Druid metrics are emitted as doubles with values between 0 and 1. Currently these values are floored to 0 when converted to longs. This PR implements the solution proposed in #3350 which optionally converts metric values into the proper range by multiplying by 100 and rounding to the nearest integer.

Copy link
Contributor

@gianm gianm left a comment

Choose a reason for hiding this comment

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

@michaelschiff, thanks for the fix. The code looks good, but one of the tests is failing -- could you please fix it?

java.lang.AssertionError: correct StatsDMetric.Type expected:<timer> but was:<io.druid.emitter.statsd.StatsDMetric@67c33749>
	at org.junit.Assert.fail(Assert.java:88)
	at org.junit.Assert.failNotEquals(Assert.java:743)
	at org.junit.Assert.assertEquals(Assert.java:118)
	at DimensionConverterTest.testConvert(DimensionConverterTest.java:59)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:483)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
	at org.apache.maven.surefire.junit4.JUnit4Provider.execute(JUnit4Provider.java:367)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeWithRerun(JUnit4Provider.java:274)
	at org.apache.maven.surefire.junit4.JUnit4Provider.executeTestSet(JUnit4Provider.java:238)
	at org.apache.maven.surefire.junit4.JUnit4Provider.invoke(JUnit4Provider.java:161)
	at org.apache.maven.surefire.booter.ForkedBooter.invokeProviderInSameClassLoader(ForkedBooter.java:290)
	at org.apache.maven.surefire.booter.ForkedBooter.runSuitesInProcess(ForkedBooter.java:242)
	at org.apache.maven.surefire.booter.ForkedBooter.main(ForkedBooter.java:121)


/**
* Created by michael.schiff on 2/14/17.
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

Please don't include author tags.

@JsonCreator
public StatsDMetric(
@JsonProperty("dimensions") SortedSet<String> dimensions,
@JsonProperty("type") Type type)
@JsonProperty("type") Type type,
@JsonProperty("convertRange") boolean convertRange
Copy link
Contributor

Choose a reason for hiding this comment

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

Please update the docs in "statsd.md" for this new parameter.

…metric values from range 0-1 to 0-100. This

prevents rates and percentages expressed as Doubles (0.xx) from being rounded down to 0.
Copy link
Contributor

@gianm gianm left a comment

Choose a reason for hiding this comment

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

👍 LGTM

In the future please do updates by pushing new commits rather than amending or rebasing, since that makes it easier for reviewers to see what's new since they last looked. (GitHub can show a diff for just the latest commits)

We'll squash the multiple commits before merging them.

@gianm gianm added this to the 0.10.0 milestone Feb 16, 2017
@gianm gianm requested a review from fjy February 16, 2017 20:58
@gianm gianm unassigned fjy Feb 16, 2017
@fjy
Copy link
Contributor

fjy commented Feb 16, 2017

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants