Search in sources :

Example 1 with Search

use of io.micrometer.core.instrument.search.Search in project kork by spinnaker.

the class MetricsInterceptorMicrometerTest method allPublishedMetricsHaveTheSameSetOfTagsAndCanBeRegisteredInMicrometer.

@Test
public void allPublishedMetricsHaveTheSameSetOfTagsAndCanBeRegisteredInMicrometer() throws Exception {
    MockHttpServletRequest request1 = new MockHttpServletRequest();
    request1.setAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, Collections.emptyMap());
    MockHttpServletRequest request2 = new MockHttpServletRequest();
    request2.setAttribute(HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE, Collections.singletonMap("path-var-1", "path-val-1"));
    request2.setParameter("param-1", "val-1");
    interceptCall(interceptor, request1, RESPONSE, HANDLER, null);
    interceptCall(interceptor, request1, RESPONSE, HANDLER, new RuntimeException());
    interceptCall(interceptor, request2, RESPONSE, HANDLER, null);
    interceptCall(interceptor, request2, RESPONSE, HANDLER, new IllegalArgumentException());
    Search actual = simpleMeterRegistry.find("controller.invocations");
    assertThat(getAllTagsAndRemovePercentileTag(actual)).hasSize(4).containsOnly(Arrays.asList(Tag.of("cause", "IllegalArgumentException"), Tag.of("controller", "TestController"), Tag.of("criticality", "unknown"), Tag.of("method", "execute"), Tag.of("param-1", "val-1"), Tag.of("param-2", "None"), Tag.of("path-var-1", "path-val-1"), Tag.of("path-var-2", "None"), Tag.of("statistic", "percentile"), Tag.of("status", "5xx"), Tag.of("statusCode", "500"), Tag.of("success", "false")), Arrays.asList(Tag.of("cause", "RuntimeException"), Tag.of("controller", "TestController"), Tag.of("criticality", "unknown"), Tag.of("method", "execute"), Tag.of("param-1", "None"), Tag.of("param-2", "None"), Tag.of("path-var-1", "None"), Tag.of("path-var-2", "None"), Tag.of("statistic", "percentile"), Tag.of("status", "5xx"), Tag.of("statusCode", "500"), Tag.of("success", "false")), Arrays.asList(Tag.of("cause", "None"), Tag.of("controller", "TestController"), Tag.of("criticality", "unknown"), Tag.of("method", "execute"), Tag.of("param-1", "val-1"), Tag.of("param-2", "None"), Tag.of("path-var-1", "path-val-1"), Tag.of("path-var-2", "None"), Tag.of("statistic", "percentile"), Tag.of("status", "2xx"), Tag.of("statusCode", "200"), Tag.of("success", "true")), Arrays.asList(Tag.of("cause", "None"), Tag.of("controller", "TestController"), Tag.of("criticality", "unknown"), Tag.of("method", "execute"), Tag.of("param-1", "None"), Tag.of("param-2", "None"), Tag.of("path-var-1", "None"), Tag.of("path-var-2", "None"), Tag.of("statistic", "percentile"), Tag.of("status", "2xx"), Tag.of("statusCode", "200"), Tag.of("success", "true")));
}
Also used : MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) Search(io.micrometer.core.instrument.search.Search) Test(org.junit.Test)

Aggregations

Search (io.micrometer.core.instrument.search.Search)1 Test (org.junit.Test)1 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)1