Search in sources :

Example 6 with SignalFxReporter

use of com.signalfx.codahale.reporter.SignalFxReporter 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)

Example 7 with SignalFxReporter

use of com.signalfx.codahale.reporter.SignalFxReporter in project riposte by Nike-Inc.

the class SignalFxReporterFactoryTest method getReporter_caches_result_and_reuses_it_for_subsequent_calls.

@Test
public void getReporter_caches_result_and_reuses_it_for_subsequent_calls() {
    // given
    SignalFxReporter initialResult = factory.getReporter(metricRegistryMock);
    verify(configuratorMock).apply(any(Builder.class));
    // when
    SignalFxReporter subsequentResult = factory.getReporter(metricRegistryMock);
    // then
    verifyNoMoreInteractions(configuratorMock);
    assertThat(subsequentResult).isSameAs(initialResult);
}
Also used : SignalFxReporter(com.signalfx.codahale.reporter.SignalFxReporter) Builder(com.signalfx.codahale.reporter.SignalFxReporter.Builder) Test(org.junit.Test)

Aggregations

SignalFxReporter (com.signalfx.codahale.reporter.SignalFxReporter)7 Test (org.junit.Test)6 TimeUnit (java.util.concurrent.TimeUnit)3 Assertions.catchThrowable (org.assertj.core.api.Assertions.catchThrowable)3 MetricMetadata (com.signalfx.codahale.reporter.MetricMetadata)2 Builder (com.signalfx.codahale.reporter.SignalFxReporter.Builder)2 Matchers.anyLong (org.mockito.Matchers.anyLong)2 RollingWindowTimerBuilder (com.nike.riposte.metrics.codahale.impl.SignalFxEndpointMetricsHandler.RollingWindowTimerBuilder)1 DimensionInclusion (com.signalfx.codahale.reporter.DimensionInclusion)1 AuthToken (com.signalfx.metrics.auth.AuthToken)1 DataProvider (com.tngtech.java.junit.dataprovider.DataProvider)1