Search in sources :

Example 6 with DefaultMetricNamingStrategy

use of com.nike.riposte.metrics.codahale.CodahaleMetricsListener.DefaultMetricNamingStrategy in project riposte by Nike-Inc.

the class CodahaleMetricsListenerTest method verifyServerStatisticMetrics.

private void verifyServerStatisticMetrics(CodahaleMetricsListener instance) {
    String prefix = ((DefaultMetricNamingStrategy) instance.serverStatsMetricNamingStrategy).prefix;
    assertThat(instance.getInflightRequests()).isSameAs(instance.inflightRequests);
    verify(metricRegistryMock).counter(name(prefix, "inflight_requests"));
    assertThat(instance.inflightRequests).isSameAs(registeredCounterMocks.get(name(prefix, "inflight_requests")));
    assertThat(instance.getProcessedRequests()).isSameAs(instance.processedRequests);
    verify(metricRegistryMock).counter(name(prefix, "processed_requests"));
    assertThat(instance.processedRequests).isSameAs(registeredCounterMocks.get(name(prefix, "processed_requests")));
    assertThat(instance.getFailedRequests()).isSameAs(instance.failedRequests);
    verify(metricRegistryMock).counter(name(prefix, "failed_requests"));
    assertThat(instance.failedRequests).isSameAs(registeredCounterMocks.get(name(prefix, "failed_requests")));
    assertThat(instance.getResponseWriteFailed()).isSameAs(instance.responseWriteFailed);
    verify(metricRegistryMock).counter(name(prefix, "response_write_failed"));
    assertThat(instance.responseWriteFailed).isSameAs(registeredCounterMocks.get(name(prefix, "response_write_failed")));
    assertThat(instance.getResponseSizes()).isSameAs(instance.responseSizes);
    verify(metricRegistryMock).register(name(prefix, "response_sizes"), instance.responseSizes);
    assertThat(instance.responseSizes).isSameAs(registeredHistogramMocks.get(name(prefix, "response_sizes")));
    assertThat(instance.getRequestSizes()).isSameAs(instance.requestSizes);
    verify(metricRegistryMock).register(name(prefix, "request_sizes"), instance.requestSizes);
    assertThat(instance.requestSizes).isSameAs(registeredHistogramMocks.get(name(prefix, "request_sizes")));
}
Also used : DefaultMetricNamingStrategy(com.nike.riposte.metrics.codahale.CodahaleMetricsListener.DefaultMetricNamingStrategy) Matchers.anyString(org.mockito.Matchers.anyString)

Example 7 with DefaultMetricNamingStrategy

use of com.nike.riposte.metrics.codahale.CodahaleMetricsListener.DefaultMetricNamingStrategy in project riposte by Nike-Inc.

the class CodahaleMetricsListenerTest method metricNamingStrategy_defaultImpl_with_args_method_works_as_expected.

@Test
public void metricNamingStrategy_defaultImpl_with_args_method_works_as_expected() {
    // given
    String prefix = UUID.randomUUID().toString();
    String wordDelimiter = UUID.randomUUID().toString();
    // when
    MetricNamingStrategy result = MetricNamingStrategy.defaultImpl(prefix, wordDelimiter);
    // then
    assertThat(result).isInstanceOf(DefaultMetricNamingStrategy.class);
    DefaultMetricNamingStrategy defStrat = (DefaultMetricNamingStrategy) result;
    assertThat(defStrat.prefix).isEqualTo(prefix);
    assertThat(defStrat.wordDelimiter).isEqualTo(wordDelimiter);
}
Also used : DefaultMetricNamingStrategy(com.nike.riposte.metrics.codahale.CodahaleMetricsListener.DefaultMetricNamingStrategy) MetricNamingStrategy(com.nike.riposte.metrics.codahale.CodahaleMetricsListener.MetricNamingStrategy) DefaultMetricNamingStrategy(com.nike.riposte.metrics.codahale.CodahaleMetricsListener.DefaultMetricNamingStrategy) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Aggregations

DefaultMetricNamingStrategy (com.nike.riposte.metrics.codahale.CodahaleMetricsListener.DefaultMetricNamingStrategy)7 Test (org.junit.Test)5 MetricNamingStrategy (com.nike.riposte.metrics.codahale.CodahaleMetricsListener.MetricNamingStrategy)3 Matchers.anyString (org.mockito.Matchers.anyString)3 DataProvider (com.tngtech.java.junit.dataprovider.DataProvider)2 Histogram (com.codahale.metrics.Histogram)1 Builder (com.nike.riposte.metrics.codahale.CodahaleMetricsListener.Builder)1 ServerConfigMetricNames (com.nike.riposte.metrics.codahale.CodahaleMetricsListener.ServerConfigMetricNames)1 ServerStatisticsMetricNames (com.nike.riposte.metrics.codahale.CodahaleMetricsListener.ServerStatisticsMetricNames)1