Search in sources :

Example 1 with CountingTransformer

use of com.codahale.metrics.newrelic.transformer.interfaces.CountingTransformer in project dropwizard-metrics-newrelic by newrelic.

the class HistogramTransformerTest method testRemove.

@Test
void testRemove() {
    CountingTransformer counting = mock(CountingTransformer.class);
    HistogramTransformer testClass = new HistogramTransformer(counting, null);
    testClass.onHistogramRemoved("jim");
    verify(counting).remove("jim");
}
Also used : CountingTransformer(com.codahale.metrics.newrelic.transformer.interfaces.CountingTransformer) Test(org.junit.jupiter.api.Test)

Example 2 with CountingTransformer

use of com.codahale.metrics.newrelic.transformer.interfaces.CountingTransformer in project dropwizard-metrics-newrelic by newrelic.

the class MeterTransformerTest method testRemoveWithNameCustomization.

@Test
void testRemoveWithNameCustomization() {
    CountingTransformer counting = mock(CountingTransformer.class);
    MeterTransformer testClass = new MeterTransformer(null, counting, MetricCustomizerTestUtils.NAME_TAG_STRIPPER, null);
    testClass.onMeterRemoved("something[tag:value]");
    verify(counting).remove("something");
}
Also used : CountingTransformer(com.codahale.metrics.newrelic.transformer.interfaces.CountingTransformer) Test(org.junit.jupiter.api.Test)

Example 3 with CountingTransformer

use of com.codahale.metrics.newrelic.transformer.interfaces.CountingTransformer 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);
}
Also used : SamplingTransformer(com.codahale.metrics.newrelic.transformer.interfaces.SamplingTransformer) MeteredTransformer(com.codahale.metrics.newrelic.transformer.interfaces.MeteredTransformer) Timer(com.codahale.metrics.Timer) Attributes(com.newrelic.telemetry.Attributes) Metric(com.newrelic.telemetry.metrics.Metric) Count(com.newrelic.telemetry.metrics.Count) CountingTransformer(com.codahale.metrics.newrelic.transformer.interfaces.CountingTransformer) Gauge(com.newrelic.telemetry.metrics.Gauge) Test(org.junit.jupiter.api.Test)

Example 4 with CountingTransformer

use of com.codahale.metrics.newrelic.transformer.interfaces.CountingTransformer in project dropwizard-metrics-newrelic by newrelic.

the class TimerTransformerTest method testRemove.

@Test
void testRemove() throws Exception {
    CountingTransformer counting = mock(CountingTransformer.class);
    TimerTransformer testClass = new TimerTransformer(null, null, counting);
    testClass.onTimerRemoved("money");
    verify(counting).remove("money");
}
Also used : CountingTransformer(com.codahale.metrics.newrelic.transformer.interfaces.CountingTransformer) Test(org.junit.jupiter.api.Test)

Example 5 with CountingTransformer

use of com.codahale.metrics.newrelic.transformer.interfaces.CountingTransformer in project dropwizard-metrics-newrelic by newrelic.

the class TimerTransformerTest method testRemoveWithNameCustomization.

@Test
void testRemoveWithNameCustomization() {
    CountingTransformer counting = mock(CountingTransformer.class);
    TimerTransformer testClass = new TimerTransformer(null, null, counting, MetricCustomizerTestUtils.NAME_TAG_STRIPPER, null);
    testClass.onTimerRemoved("money[tag:value]");
    verify(counting).remove("money");
}
Also used : CountingTransformer(com.codahale.metrics.newrelic.transformer.interfaces.CountingTransformer) Test(org.junit.jupiter.api.Test)

Aggregations

CountingTransformer (com.codahale.metrics.newrelic.transformer.interfaces.CountingTransformer)8 Test (org.junit.jupiter.api.Test)8 Timer (com.codahale.metrics.Timer)2 MeteredTransformer (com.codahale.metrics.newrelic.transformer.interfaces.MeteredTransformer)2 SamplingTransformer (com.codahale.metrics.newrelic.transformer.interfaces.SamplingTransformer)2 Attributes (com.newrelic.telemetry.Attributes)2 Count (com.newrelic.telemetry.metrics.Count)2 Gauge (com.newrelic.telemetry.metrics.Gauge)2 Metric (com.newrelic.telemetry.metrics.Metric)2