Search in sources :

Example 6 with RollingWindowTimerBuilder

use of com.nike.riposte.metrics.codahale.impl.SignalFxEndpointMetricsHandler.RollingWindowTimerBuilder in project riposte by Nike-Inc.

the class SignalFxEndpointMetricsHandlerTest method three_arg_constructor_sets_fields_as_expected.

@Test
public void three_arg_constructor_sets_fields_as_expected() {
    // given
    SignalFxReporter reporterMock = mock(SignalFxReporter.class);
    MetricMetadata expectedMetricMetadata = wireUpReporterForConstructor(reporterMock);
    Pair<Long, TimeUnit> reportingFrequency = Pair.of(42L, TimeUnit.DAYS);
    // when
    SignalFxEndpointMetricsHandler instance = new SignalFxEndpointMetricsHandler(reporterMock, reportingFrequency, metricRegistryMock);
    // then
    assertThat(instance.metricMetadata).isSameAs(expectedMetricMetadata);
    assertThat(instance.metricRegistry).isSameAs(metricRegistryMock);
    assertThat(instance.requestTimerBuilder).isInstanceOf(RollingWindowTimerBuilder.class);
    RollingWindowTimerBuilder rwtb = (RollingWindowTimerBuilder) instance.requestTimerBuilder;
    assertThat(rwtb.amount).isEqualTo(reportingFrequency.getLeft());
    assertThat(rwtb.timeUnit).isEqualTo(reportingFrequency.getRight());
    assertThat(instance.requestTimerDimensionConfigurator).isSameAs(DEFAULT_REQUEST_LATENCY_TIMER_DIMENSION_CONFIGURATOR);
}
Also used : MetricMetadata(com.signalfx.codahale.reporter.MetricMetadata) SignalFxReporter(com.signalfx.codahale.reporter.SignalFxReporter) Matchers.anyLong(org.mockito.Matchers.anyLong) TimeUnit(java.util.concurrent.TimeUnit) RollingWindowTimerBuilder(com.nike.riposte.metrics.codahale.impl.SignalFxEndpointMetricsHandler.RollingWindowTimerBuilder) Test(org.junit.Test)

Aggregations

RollingWindowTimerBuilder (com.nike.riposte.metrics.codahale.impl.SignalFxEndpointMetricsHandler.RollingWindowTimerBuilder)6 Test (org.junit.Test)6 Timer (com.codahale.metrics.Timer)3 TimeUnit (java.util.concurrent.TimeUnit)3 MetricMetadata (com.signalfx.codahale.reporter.MetricMetadata)2 DataProvider (com.tngtech.java.junit.dataprovider.DataProvider)2 Gauge (com.codahale.metrics.Gauge)1 Histogram (com.codahale.metrics.Histogram)1 Metric (com.codahale.metrics.Metric)1 Reservoir (com.codahale.metrics.Reservoir)1 SlidingTimeWindowReservoir (com.codahale.metrics.SlidingTimeWindowReservoir)1 Pair (com.nike.internal.util.Pair)1 SignalFxReporterFactory (com.nike.riposte.metrics.codahale.contrib.SignalFxReporterFactory)1 SignalFxReporter (com.signalfx.codahale.reporter.SignalFxReporter)1 Matchers.anyLong (org.mockito.Matchers.anyLong)1