use of io.micrometer.core.instrument.search.RequiredSearch in project cxf by apache.
the class SpringClientOnlyJaxrsTest method testJaxrsClientSuccessMetric.
@Test
public void testJaxrsClientSuccessMetric() {
final WebTarget target = createWebTarget();
final Builder builder = target.request().header(HttpHeaders.CONTENT_TYPE, "text/plain");
try (Response r = builder.get()) {
assertThat(r.getStatus()).isEqualTo(200);
}
// no server meters
assertThat(registry.getMeters()).noneMatch(m -> "cxf.server.requests".equals(m.getId().getName()));
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"), entry("outcome", "SUCCESS"), entry("status", "200"));
}
use of io.micrometer.core.instrument.search.RequiredSearch in project cxf by apache.
the class SpringJaxrsTest method testJaxrsProxyClientExceptionMetric.
@Test
public void testJaxrsProxyClientExceptionMetric() {
final int fakePort = SocketUtils.findAvailableTcpPort();
final LibraryApi api = createApi(fakePort);
assertThatThrownBy(() -> api.deleteBooks()).isInstanceOf(ProcessingException.class).hasMessageContaining("Connection refused");
// no server meters
assertThat(registry.getMeters()).noneMatch(m -> "cxf.server.requests".equals(m.getId().getName()));
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", "DELETE"), entry("operation", "deleteBooks"), entry("uri", "http://localhost:" + fakePort + "/api/library"), entry("outcome", "UNKNOWN"), entry("status", "UNKNOWN"));
}
use of io.micrometer.core.instrument.search.RequiredSearch in project cxf by apache.
the class SpringJaxrsTest method testJaxrsProxyExceptionMetric.
@Test
public void testJaxrsProxyExceptionMetric() {
final LibraryApi api = createApi(port);
assertThatThrownBy(() -> api.deleteBooks()).isInstanceOf(InternalServerErrorException.class).hasMessageContaining("Internal Server Error");
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", "UnsupportedOperationException"), entry("method", "DELETE"), entry("operation", "deleteBooks"), entry("uri", "/api/library"), 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("method", "DELETE"), entry("operation", "deleteBooks"), entry("uri", "http://localhost:" + port + "/api/library"), entry("outcome", "SERVER_ERROR"), entry("status", "500"));
}
use of io.micrometer.core.instrument.search.RequiredSearch in project cxf by apache.
the class SpringJaxwsTest method testJaxwsFailedMetric.
@Test
public void testJaxwsFailedMetric() {
// given
String requestBody = "<q0:sayHello xmlns:q0=\"http://service.ws.sample/\"></q0:sayHello>";
// when
Throwable throwable = catchThrowable(() -> sendSoapRequest(requestBody, HELLO_SERVICE_NAME_V1));
// then
assertThat(throwable).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", "Invoke"), 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 testJaxwsProxyClientExceptionMetric.
@Test
public void testJaxwsProxyClientExceptionMetric() throws MalformedURLException {
final int fakePort = SocketUtils.findAvailableTcpPort();
final HelloService api = createApi(fakePort, HELLO_SERVICE_NAME_V1);
assertThatThrownBy(() -> api.sayHello("Elan")).isInstanceOf(WebServiceException.class).hasMessageContaining("Could not send Message");
// no server meters
assertThat(registry.getMeters()).noneMatch(m -> "cxf.server.requests".equals(m.getId().getName()));
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", "RUNTIME_FAULT"), entry("method", "POST"), entry("operation", "sayHello"), entry("uri", "http://localhost:" + fakePort + "/Service/" + HELLO_SERVICE_NAME_V1), entry("outcome", "UNKNOWN"), entry("status", "UNKNOWN"));
}
Aggregations