Search in sources :

Example 1 with DimensionConverter

use of io.druid.emitter.statsd.DimensionConverter in project druid by druid-io.

the class DimensionConverterTest method testConvert.

@Test
public void testConvert() throws Exception {
    DimensionConverter dimensionConverter = new DimensionConverter(new ObjectMapper(), null);
    ServiceMetricEvent event = 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");
    ImmutableList.Builder<String> actual = new ImmutableList.Builder<>();
    StatsDMetric statsDMetric = dimensionConverter.addFilteredUserDims(event.getService(), event.getMetric(), event.getUserDims(), actual);
    assertEquals("correct StatsDMetric.Type", StatsDMetric.Type.timer, statsDMetric.type);
    ImmutableList.Builder<String> expected = new ImmutableList.Builder<>();
    expected.add("data-source");
    expected.add("groupBy");
    assertEquals("correct Dimensions", expected.build(), actual.build());
}
Also used : DimensionConverter(io.druid.emitter.statsd.DimensionConverter) ImmutableList(com.google.common.collect.ImmutableList) ServiceMetricEvent(com.metamx.emitter.service.ServiceMetricEvent) StatsDMetric(io.druid.emitter.statsd.StatsDMetric) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) DateTime(org.joda.time.DateTime) Test(org.junit.Test)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ImmutableList (com.google.common.collect.ImmutableList)1 ServiceMetricEvent (com.metamx.emitter.service.ServiceMetricEvent)1 DimensionConverter (io.druid.emitter.statsd.DimensionConverter)1 StatsDMetric (io.druid.emitter.statsd.StatsDMetric)1 DateTime (org.joda.time.DateTime)1 Test (org.junit.Test)1