use of com.codahale.metrics.newrelic.transformer.interfaces.SamplingTransformer in project dropwizard-metrics-newrelic by newrelic.
the class TimerTransformerTest method testTransformWithAttributeAndNameCustomization.
@Test
void testTransformWithAttributeAndNameCustomization() {
Attributes otherTags = new Attributes().put("tag", "value").put("otherTag", "otherValue");
long now = System.currentTimeMillis();
Gauge result1 = new Gauge(baseName, 55d, now, otherTags);
Gauge result2 = new Gauge(baseName, 999d, now, otherTags);
Count expectedCount = createExpectedCountMetric(otherTags);
Timer timer = mock(Timer.class);
SamplingTransformer samplingTransformer = mock(SamplingTransformer.class);
MeteredTransformer meteredTransformer = mock(MeteredTransformer.class);
CountingTransformer countingTransformer = mock(CountingTransformer.class);
when(samplingTransformer.transform(eq(baseName), eq(timer), notNull())).thenReturn(singleton(result1));
when(meteredTransformer.transform(eq(baseName), eq(timer), notNull())).thenReturn(singleton(result2));
when(countingTransformer.transform(eq(baseName), eq(timer), notNull())).thenReturn(singleton(expectedCount));
TimerTransformer timerTransformer = new TimerTransformer(samplingTransformer, meteredTransformer, countingTransformer, MetricCustomizerTestUtils.NAME_TAG_STRIPPER, MetricCustomizerTestUtils.ATTRIBUTES_FROM_TAGGED_NAME);
Collection<Metric> results = timerTransformer.transform(baseName + "[tag:value,otherTag:otherValue]", timer);
Collection<Metric> expected = Sets.newSet(result1, result2, expectedCount);
assertEquals(expected, results);
}
use of com.codahale.metrics.newrelic.transformer.interfaces.SamplingTransformer in project dropwizard-metrics-newrelic by newrelic.
the class TimerTransformerTest method testTransform.
@Test
void testTransform() {
long now = System.currentTimeMillis();
Gauge result1 = new Gauge(baseName, 55d, now, new Attributes());
Gauge result2 = new Gauge(baseName, 999d, now, new Attributes());
Count expectedCount = createExpectedCountMetric(new Attributes());
Timer timer = mock(Timer.class);
SamplingTransformer samplingTransformer = mock(SamplingTransformer.class);
MeteredTransformer meteredTransformer = mock(MeteredTransformer.class);
CountingTransformer countingTransformer = mock(CountingTransformer.class);
when(samplingTransformer.transform(eq(baseName), eq(timer), notNull())).thenReturn(singleton(result1));
when(meteredTransformer.transform(eq(baseName), eq(timer), notNull())).thenReturn(singleton(result2));
when(countingTransformer.transform(eq(baseName), eq(timer), notNull())).thenReturn(singleton(expectedCount));
TimerTransformer timerTransformer = new TimerTransformer(samplingTransformer, meteredTransformer, countingTransformer);
Collection<Metric> results = timerTransformer.transform(baseName, timer);
Collection<Metric> expected = Sets.newSet(result1, result2, expectedCount);
assertEquals(expected, results);
}
Aggregations