Search in sources :

Example 1 with DefaultMetricDimensionConfigurator

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

the class SignalFxEndpointMetricsHandlerTest method DefaultMetricDimensionConfigurator_one_arg_constructor_sets_fields_as_expected.

@Test
public void DefaultMetricDimensionConfigurator_one_arg_constructor_sets_fields_as_expected() {
    // give
    String metricName = UUID.randomUUID().toString();
    // when
    DefaultMetricDimensionConfigurator instance = new DefaultMetricDimensionConfigurator(metricName);
    // then
    assertThat(instance.metricName).isEqualTo(metricName);
    assertThat(instance.responseCodeDimensionKey).isEqualTo(DEFAULT_RESPONSE_CODE_DIMENSION_KEY);
    assertThat(instance.uriDimensionKey).isEqualTo(DEFAULT_URI_DIMENSION_KEY);
    assertThat(instance.methodDimensionKey).isEqualTo(DEFAULT_METHOD_DIMENSION_KEY);
    assertThat(instance.endpointClassKey).isEqualTo(DEFAULT_ENDPOINT_CLASS_DIMENSION_KEY);
}
Also used : DefaultMetricDimensionConfigurator(com.nike.riposte.metrics.codahale.impl.SignalFxEndpointMetricsHandler.DefaultMetricDimensionConfigurator) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 2 with DefaultMetricDimensionConfigurator

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

the class SignalFxEndpointMetricsHandlerTest method DefaultMetricDimensionConfigurator_kitchen_sink_constructor_sets_fields_as_expected.

@Test
public void DefaultMetricDimensionConfigurator_kitchen_sink_constructor_sets_fields_as_expected() {
    // give
    String metricName = UUID.randomUUID().toString();
    String responseCodeDimKey = UUID.randomUUID().toString();
    String uriDimKey = UUID.randomUUID().toString();
    String methodDimKey = UUID.randomUUID().toString();
    String endpointDimKey = UUID.randomUUID().toString();
    // when
    DefaultMetricDimensionConfigurator instance = new DefaultMetricDimensionConfigurator(metricName, responseCodeDimKey, uriDimKey, methodDimKey, endpointDimKey);
    // then
    assertThat(instance.metricName).isEqualTo(metricName);
    assertThat(instance.responseCodeDimensionKey).isEqualTo(responseCodeDimKey);
    assertThat(instance.uriDimensionKey).isEqualTo(uriDimKey);
    assertThat(instance.methodDimensionKey).isEqualTo(methodDimKey);
    assertThat(instance.endpointClassKey).isEqualTo(endpointDimKey);
}
Also used : DefaultMetricDimensionConfigurator(com.nike.riposte.metrics.codahale.impl.SignalFxEndpointMetricsHandler.DefaultMetricDimensionConfigurator) Matchers.anyString(org.mockito.Matchers.anyString) Test(org.junit.Test)

Example 3 with DefaultMetricDimensionConfigurator

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

the class SignalFxEndpointMetricsHandlerTest method DefaultMetricDimensionConfigurator_setupMetricWithDimensions_works_as_expected.

@Test
public void DefaultMetricDimensionConfigurator_setupMetricWithDimensions_works_as_expected() {
    // given
    BuilderTagger builderMock = mock(BuilderTagger.class);
    doReturn(builderMock).when(builderMock).withMetricName(anyString());
    doReturn(builderMock).when(builderMock).withDimension(anyString(), anyString());
    String metricName = UUID.randomUUID().toString();
    String responseCodeDimKey = UUID.randomUUID().toString();
    String uriDimKey = UUID.randomUUID().toString();
    String methodDimKey = UUID.randomUUID().toString();
    String endpointDimKey = UUID.randomUUID().toString();
    DefaultMetricDimensionConfigurator instance = new DefaultMetricDimensionConfigurator(metricName, responseCodeDimKey, uriDimKey, methodDimKey, endpointDimKey);
    int responseStatusCode = 242;
    int responseStatusCodeXXValue = 2;
    long elapsedTimeMillis = 42;
    String endpointClass = UUID.randomUUID().toString();
    String method = UUID.randomUUID().toString();
    // when
    BuilderTagger result = instance.setupMetricWithDimensions(builderMock, requestInfoMock, responseInfoMock, httpStateMock, responseStatusCode, responseStatusCodeXXValue, elapsedTimeMillis, endpointMock, endpointClass, method, matchingPathTemplate);
    // then
    assertThat(result).isSameAs(builderMock);
    verify(builderMock).withMetricName(metricName);
    verify(builderMock).withDimension(responseCodeDimKey, String.valueOf(responseStatusCode));
    verify(builderMock).withDimension(uriDimKey, matchingPathTemplate);
    verify(builderMock).withDimension(methodDimKey, method);
    verify(builderMock).withDimension(endpointDimKey, endpointClass);
    verifyNoMoreInteractions(builderMock);
}
Also used : DefaultMetricDimensionConfigurator(com.nike.riposte.metrics.codahale.impl.SignalFxEndpointMetricsHandler.DefaultMetricDimensionConfigurator) Matchers.anyString(org.mockito.Matchers.anyString) BuilderTagger(com.signalfx.codahale.reporter.MetricMetadata.BuilderTagger) Endpoint(com.nike.riposte.server.http.Endpoint) Test(org.junit.Test)

Aggregations

DefaultMetricDimensionConfigurator (com.nike.riposte.metrics.codahale.impl.SignalFxEndpointMetricsHandler.DefaultMetricDimensionConfigurator)3 Test (org.junit.Test)3 Matchers.anyString (org.mockito.Matchers.anyString)3 Endpoint (com.nike.riposte.server.http.Endpoint)1 BuilderTagger (com.signalfx.codahale.reporter.MetricMetadata.BuilderTagger)1