use of io.micrometer.core.instrument.search.RequiredSearch in project webpieces by deanhiller.
the class TestLesson8JsonHttp2 method testSynchronousController.
/**
* Testing a synchronous controller may be easier especially if there is no remote communication.
*/
@Test
public void testSynchronousController() {
SearchRequest req = new SearchRequest();
req.setQuery("my query");
SearchResponse resp = search(req);
Assert.assertEquals("match1", resp.getMatches().get(0));
// check metrics are wired correctly here as well
RequiredSearch result = metrics.get("testCounter");
Counter counter = result.counter();
Assert.assertEquals(1.0, counter.count(), 0.1);
}
use of io.micrometer.core.instrument.search.RequiredSearch in project cxf by apache.
the class SpringJaxrsTest method testJaxrsProxyFailedMetric.
@Test
public void testJaxrsProxyFailedMetric() {
final LibraryApi api = createApi(port);
try (Response r = api.getBook("100")) {
assertThat(r.getStatus()).isEqualTo(404);
}
await().atMost(Duration.ofSeconds(1)).ignoreException(MeterNotFoundException.class).until(() -> registry.get("cxf.server.requests").timers(), not(empty()));
RequiredSearch serverRequestMetrics = registry.get("cxf.server.requests");
Map<Object, Object> serverTags = serverRequestMetrics.timer().getId().getTags().stream().collect(toMap(Tag::getKey, Tag::getValue));
assertThat(serverTags).containsOnly(entry("exception", "None"), entry("method", "GET"), entry("operation", "getBook"), entry("uri", "/api/library/{id}"), entry("outcome", "CLIENT_ERROR"), entry("status", "404"));
RequiredSearch clientRequestMetrics = registry.get("cxf.client.requests");
Map<Object, Object> clientTags = clientRequestMetrics.timer().getId().getTags().stream().collect(toMap(Tag::getKey, Tag::getValue));
assertThat(clientTags).containsOnly(entry("exception", "None"), entry("method", "GET"), entry("operation", "getBook"), entry("uri", "http://localhost:" + port + "/api/library/100"), entry("outcome", "CLIENT_ERROR"), entry("status", "404"));
}
use of io.micrometer.core.instrument.search.RequiredSearch in project cxf by apache.
the class SpringJaxrsTest method testJaxrsFailedMetric.
@Test
public void testJaxrsFailedMetric() {
final WebTarget target = createWebTarget();
assertThatThrownBy(() -> target.path("100").request().get(Book.class)).isInstanceOf(NotFoundException.class).hasMessageContaining("Not Found");
await().atMost(Duration.ofSeconds(1)).ignoreException(MeterNotFoundException.class).until(() -> registry.get("cxf.server.requests").timers(), not(empty()));
RequiredSearch serverRequestMetrics = registry.get("cxf.server.requests");
Map<Object, Object> serverTags = serverRequestMetrics.timer().getId().getTags().stream().collect(toMap(Tag::getKey, Tag::getValue));
assertThat(serverTags).containsOnly(entry("exception", "None"), entry("method", "GET"), entry("operation", "getBook"), entry("uri", "/api/library/{id}"), entry("outcome", "CLIENT_ERROR"), entry("status", "404"));
RequiredSearch clientRequestMetrics = registry.get("cxf.client.requests");
Map<Object, Object> clientTags = clientRequestMetrics.timer().getId().getTags().stream().collect(toMap(Tag::getKey, Tag::getValue));
assertThat(clientTags).containsOnly(entry("exception", "None"), entry("method", "GET"), entry("operation", "UNKNOWN"), entry("uri", "http://localhost:" + port + "/api/library/100"), entry("outcome", "CLIENT_ERROR"), entry("status", "404"));
}
use of io.micrometer.core.instrument.search.RequiredSearch in project cxf by apache.
the class SpringJaxwsTest method testJaxwsProxyFailedMetric.
@Test
public void testJaxwsProxyFailedMetric() {
final HelloService api = createApi(port, HELLO_SERVICE_NAME_V1);
// then
assertThatThrownBy(() -> api.sayHello(null)).isInstanceOf(SOAPFaultException.class).hasMessageContaining("Fault occurred while processing");
await().atMost(Duration.ofSeconds(1)).ignoreException(MeterNotFoundException.class).until(() -> registry.get("cxf.server.requests").timers(), not(empty()));
RequiredSearch serverRequestMetrics = registry.get("cxf.server.requests");
Map<Object, Object> serverTags = serverRequestMetrics.timer().getId().getTags().stream().collect(toMap(Tag::getKey, Tag::getValue));
assertThat(serverTags).containsOnly(entry("exception", "NullPointerException"), entry("faultCode", "UNCHECKED_APPLICATION_FAULT"), entry("method", "POST"), entry("operation", "sayHello"), entry("uri", "/Service/" + HELLO_SERVICE_NAME_V1), entry("outcome", "SERVER_ERROR"), entry("status", "500"));
RequiredSearch clientRequestMetrics = registry.get("cxf.client.requests");
Map<Object, Object> clientTags = clientRequestMetrics.timer().getId().getTags().stream().collect(toMap(Tag::getKey, Tag::getValue));
assertThat(clientTags).containsOnly(entry("exception", "None"), entry("faultCode", "UNCHECKED_APPLICATION_FAULT"), entry("method", "POST"), entry("operation", "sayHello"), entry("uri", "http://localhost:" + port + "/Service/" + HELLO_SERVICE_NAME_V1), entry("outcome", "SERVER_ERROR"), entry("status", "500"));
}
use of io.micrometer.core.instrument.search.RequiredSearch in project cxf by apache.
the class SpringJaxwsTest method testJaxwsProxySuccessMetric.
@Test
public void testJaxwsProxySuccessMetric() throws MalformedURLException {
final HelloService api = createApi(port, HELLO_SERVICE_NAME_V1);
assertThat(api.sayHello("Elan")).isEqualTo("Hello, Elan");
await().atMost(Duration.ofSeconds(1)).ignoreException(MeterNotFoundException.class).until(() -> registry.get("cxf.server.requests").timers(), not(empty()));
RequiredSearch serverRequestMetrics = registry.get("cxf.server.requests");
Map<Object, Object> serverTags = serverRequestMetrics.timer().getId().getTags().stream().collect(toMap(Tag::getKey, Tag::getValue));
assertThat(serverTags).containsOnly(entry("exception", "None"), entry("faultCode", "None"), entry("method", "POST"), entry("operation", "sayHello"), entry("uri", "/Service/" + HELLO_SERVICE_NAME_V1), entry("outcome", "SUCCESS"), entry("status", "200"));
RequiredSearch clientRequestMetrics = registry.get("cxf.client.requests");
Map<Object, Object> clientTags = clientRequestMetrics.timer().getId().getTags().stream().collect(toMap(Tag::getKey, Tag::getValue));
assertThat(clientTags).containsOnly(entry("exception", "None"), entry("faultCode", "None"), entry("method", "POST"), entry("operation", "sayHello"), entry("uri", "http://localhost:" + port + "/Service/" + HELLO_SERVICE_NAME_V1), entry("outcome", "SUCCESS"), entry("status", "200"));
}
Aggregations