forked from apache/druid
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New property for each metric that tells the StatsDEmitter to convert …
…metric values from range 0-1 to 0-100. This (apache#3936) prevents rates and percentages expressed as Doubles (0.xx) from being rounded down to 0.
- Loading branch information
1 parent
ca6053d
commit e5fb0e1
Showing
8 changed files
with
190 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
111 changes: 111 additions & 0 deletions
111
extensions-contrib/statsd-emitter/src/test/java/StatsDEmitterTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
/* | ||
* Licensed to Metamarkets Group Inc. (Metamarkets) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. Metamarkets licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an | ||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
* KIND, either express or implied. See the License for the | ||
* specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.metamx.emitter.service.ServiceMetricEvent; | ||
import com.timgroup.statsd.StatsDClient; | ||
import io.druid.emitter.statsd.StatsDEmitter; | ||
import io.druid.emitter.statsd.StatsDEmitterConfig; | ||
|
||
import static org.easymock.EasyMock.createMock; | ||
import static org.easymock.EasyMock.replay; | ||
import static org.easymock.EasyMock.verify; | ||
|
||
import org.joda.time.DateTime; | ||
import org.junit.Test; | ||
|
||
/** | ||
*/ | ||
public class StatsDEmitterTest | ||
{ | ||
@Test | ||
public void testConvertRange() | ||
{ | ||
StatsDClient client = createMock(StatsDClient.class); | ||
StatsDEmitter emitter = new StatsDEmitter( | ||
new StatsDEmitterConfig("localhost", 8888, null, null, null, null), | ||
new ObjectMapper(), | ||
client | ||
); | ||
client.gauge("broker.query.cache.total.hitRate", 54); | ||
replay(client); | ||
emitter.emit(new ServiceMetricEvent.Builder() | ||
.setDimension("dataSource", "data-source") | ||
.build(new DateTime(), "query/cache/total/hitRate", 0.54) | ||
.build("broker", "brokerHost1") | ||
); | ||
verify(client); | ||
} | ||
|
||
@Test | ||
public void testNoConvertRange() | ||
{ | ||
StatsDClient client = createMock(StatsDClient.class); | ||
StatsDEmitter emitter = new StatsDEmitter( | ||
new StatsDEmitterConfig("localhost", 8888, null, null, null, null), | ||
new ObjectMapper(), | ||
client | ||
); | ||
client.time("broker.query.time.data-source.groupBy", 10); | ||
replay(client); | ||
emitter.emit(new ServiceMetricEvent.Builder() | ||
.setDimension("dataSource", "data-source") | ||
.setDimension("type", "groupBy") | ||
.setDimension("interval", "2013/2015") | ||
.setDimension("some_random_dim1", "random_dim_value1") | ||
.setDimension("some_random_dim2", "random_dim_value2") | ||
.setDimension("hasFilters", "no") | ||
.setDimension("duration", "P1D") | ||
.setDimension("remoteAddress", "194.0.90.2") | ||
.setDimension("id", "ID") | ||
.setDimension("context", "{context}") | ||
.build(new DateTime(), "query/time", 10) | ||
.build("broker", "brokerHost1") | ||
); | ||
verify(client); | ||
} | ||
|
||
@Test | ||
public void testConfigOptions() | ||
{ | ||
StatsDClient client = createMock(StatsDClient.class); | ||
StatsDEmitter emitter = new StatsDEmitter( | ||
new StatsDEmitterConfig("localhost", 8888, null, "#", true, null), | ||
new ObjectMapper(), | ||
client | ||
); | ||
client.time("brokerHost1#broker#query#time#data-source#groupBy", 10); | ||
replay(client); | ||
emitter.emit(new ServiceMetricEvent.Builder() | ||
.setDimension("dataSource", "data-source") | ||
.setDimension("type", "groupBy") | ||
.setDimension("interval", "2013/2015") | ||
.setDimension("some_random_dim1", "random_dim_value1") | ||
.setDimension("some_random_dim2", "random_dim_value2") | ||
.setDimension("hasFilters", "no") | ||
.setDimension("duration", "P1D") | ||
.setDimension("remoteAddress", "194.0.90.2") | ||
.setDimension("id", "ID") | ||
.setDimension("context", "{context}") | ||
.build(new DateTime(), "query/time", 10) | ||
.build("broker", "brokerHost1") | ||
); | ||
verify(client); | ||
} | ||
} |