use of com.nike.riposte.metrics.codahale.impl.SignalFxEndpointMetricsHandler.RollingWindowTimerBuilder in project riposte by Nike-Inc.
the class SignalFxEndpointMetricsHandlerTest method RollingWindowTimerBuilder_newMetric_creates_new_timer_with_SlidingTimeWindowReservoir_with_expected_values.
@DataProvider(value = { "42 | DAYS", "123 | SECONDS", "999 | MILLISECONDS", "3 | HOURS" }, splitBy = "\\|")
@Test
public void RollingWindowTimerBuilder_newMetric_creates_new_timer_with_SlidingTimeWindowReservoir_with_expected_values(long amount, TimeUnit timeUnit) {
// given
RollingWindowTimerBuilder rwtb = new RollingWindowTimerBuilder(amount, timeUnit);
// when
Timer timer = rwtb.newMetric();
// then
Histogram histogram = (Histogram) getInternalState(timer, "histogram");
Reservoir reservoir = (Reservoir) getInternalState(histogram, "reservoir");
assertThat(reservoir).isInstanceOf(SlidingTimeWindowReservoir.class);
// The expected value here comes from logic in the SlidingTimeWindowReservoir constructor.
assertThat(getInternalState(reservoir, "window")).isEqualTo(timeUnit.toNanos(amount) * 256);
}
use of com.nike.riposte.metrics.codahale.impl.SignalFxEndpointMetricsHandler.RollingWindowTimerBuilder in project riposte by Nike-Inc.
the class SignalFxEndpointMetricsHandlerTest method RollingWindowTimerBuilder_constructor_sets_fields_as_expected.
@Test
public void RollingWindowTimerBuilder_constructor_sets_fields_as_expected() {
// given
long amount = 42;
TimeUnit timeUnit = TimeUnit.DAYS;
// when
RollingWindowTimerBuilder rwtb = new RollingWindowTimerBuilder(amount, timeUnit);
// then
assertThat(rwtb.amount).isEqualTo(amount);
assertThat(rwtb.timeUnit).isEqualTo(timeUnit);
}
use of com.nike.riposte.metrics.codahale.impl.SignalFxEndpointMetricsHandler.RollingWindowTimerBuilder in project riposte by Nike-Inc.
the class SignalFxEndpointMetricsHandlerTest method RollingWindowTimerBuilder_newMetric_creates_new_timer_with_SlidingTimeWindowArrayReservoir_with_expected_values.
@DataProvider(value = { "42 | DAYS", "123 | SECONDS", "999 | MILLISECONDS", "3 | HOURS" }, splitBy = "\\|")
@Test
public void RollingWindowTimerBuilder_newMetric_creates_new_timer_with_SlidingTimeWindowArrayReservoir_with_expected_values(long amount, TimeUnit timeUnit) {
// given
RollingWindowTimerBuilder rwtb = new RollingWindowTimerBuilder(amount, timeUnit);
// when
Timer timer = rwtb.newMetric();
// then
Histogram histogram = (Histogram) getInternalState(timer, "histogram");
Reservoir reservoir = (Reservoir) getInternalState(histogram, "reservoir");
assertThat(reservoir).isInstanceOf(SlidingTimeWindowArrayReservoir.class);
// The expected value here comes from logic in the SlidingTimeWindowArrayReservoir constructor.
assertThat(getInternalState(reservoir, "window")).isEqualTo(timeUnit.toNanos(amount) * 256);
}
use of com.nike.riposte.metrics.codahale.impl.SignalFxEndpointMetricsHandler.RollingWindowTimerBuilder in project riposte by Nike-Inc.
the class SignalFxEndpointMetricsHandlerTest method two_arg_constructor_sets_fields_as_expected.
@Test
public void two_arg_constructor_sets_fields_as_expected() {
// given
SignalFxReporterFactory reporterFactoryMock = mock(SignalFxReporterFactory.class);
Pair<Pair<SignalFxReporter, MetricMetadata>, Pair<Long, TimeUnit>> wiredUpMocksAndData = wireUpReporterFactoryMockForConstructor(reporterFactoryMock, metricRegistryMock);
MetricMetadata expectedMetricMetadata = wiredUpMocksAndData.getLeft().getRight();
long expectedReportingInterval = wiredUpMocksAndData.getRight().getLeft();
TimeUnit expectedReportingTimeUnit = wiredUpMocksAndData.getRight().getRight();
// when
SignalFxEndpointMetricsHandler instance = new SignalFxEndpointMetricsHandler(reporterFactoryMock, 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(expectedReportingInterval);
assertThat(rwtb.timeUnit).isEqualTo(expectedReportingTimeUnit);
assertThat(instance.requestTimerDimensionConfigurator).isSameAs(DEFAULT_REQUEST_LATENCY_TIMER_DIMENSION_CONFIGURATOR);
}
use of com.nike.riposte.metrics.codahale.impl.SignalFxEndpointMetricsHandler.RollingWindowTimerBuilder in project riposte by Nike-Inc.
the class SignalFxEndpointMetricsHandlerTest method RollingWindowTimerBuilder_newMetric_creates_a_new_timer_with_each_call.
@Test
public void RollingWindowTimerBuilder_newMetric_creates_a_new_timer_with_each_call() {
// given
RollingWindowTimerBuilder rwtb = new RollingWindowTimerBuilder(42, TimeUnit.DAYS);
// when
Timer firstCallTimer = rwtb.newMetric();
Timer secondCallTimer = rwtb.newMetric();
// then
assertThat(firstCallTimer).isNotSameAs(secondCallTimer);
}
Aggregations