Search in sources :

Example 6 with SpanData

use of io.opentelemetry.sdk.trace.data.SpanData in project quarkus by quarkusio.

the class VertxClientOpenTelemetryTest method path.

@Test
void path() throws Exception {
    HttpResponse<Buffer> response = WebClient.create(vertx).get(uri.getPort(), uri.getHost(), "/hello/naruto").send().toCompletionStage().toCompletableFuture().get();
    assertEquals(HTTP_OK, response.statusCode());
    List<SpanData> spans = spanExporter.getFinishedSpanItems(2);
    SpanData server = spans.get(0);
    assertEquals(SERVER, server.getKind());
    assertEquals("/hello/:name", server.getName());
    assertEquals(HTTP_OK, server.getAttributes().get(HTTP_STATUS_CODE));
    assertEquals(HttpMethod.GET, server.getAttributes().get(HTTP_METHOD));
    assertEquals("/hello/:name", server.getAttributes().get(HTTP_ROUTE));
    assertEquals(uri.getHost() + ":" + uri.getPort(), server.getAttributes().get(HTTP_HOST));
    assertEquals(uri.getPath() + "hello/naruto", server.getAttributes().get(HTTP_TARGET));
    SpanData client = spans.get(1);
    assertEquals(CLIENT, client.getKind());
    assertEquals("HTTP GET", client.getName());
    assertEquals(HTTP_OK, client.getAttributes().get(HTTP_STATUS_CODE));
    assertEquals(HttpMethod.GET, client.getAttributes().get(HTTP_METHOD));
    assertEquals(uri.toString() + "hello/naruto", client.getAttributes().get(HTTP_URL));
    assertEquals(client.getTraceId(), server.getTraceId());
    assertEquals(server.getParentSpanId(), client.getSpanId());
}
Also used : Buffer(io.vertx.core.buffer.Buffer) SpanData(io.opentelemetry.sdk.trace.data.SpanData) QuarkusUnitTest(io.quarkus.test.QuarkusUnitTest) Test(org.junit.jupiter.api.Test)

Example 7 with SpanData

use of io.opentelemetry.sdk.trace.data.SpanData in project quarkus by quarkusio.

the class VertxClientOpenTelemetryTest method client.

@Test
void client() throws Exception {
    HttpResponse<Buffer> response = WebClient.create(vertx).get(uri.getPort(), uri.getHost(), "/hello").send().toCompletionStage().toCompletableFuture().get();
    assertEquals(HTTP_OK, response.statusCode());
    List<SpanData> spans = spanExporter.getFinishedSpanItems(2);
    SpanData server = spans.get(0);
    assertEquals(SERVER, server.getKind());
    assertEquals("/hello", server.getName());
    assertEquals(HTTP_OK, server.getAttributes().get(HTTP_STATUS_CODE));
    assertEquals(HttpMethod.GET, server.getAttributes().get(HTTP_METHOD));
    assertEquals("/hello", server.getAttributes().get(HTTP_ROUTE));
    assertEquals(uri.getHost() + ":" + uri.getPort(), server.getAttributes().get(HTTP_HOST));
    assertEquals(uri.getPath() + "hello", server.getAttributes().get(HTTP_TARGET));
    SpanData client = spans.get(1);
    assertEquals(CLIENT, client.getKind());
    assertEquals("HTTP GET", client.getName());
    assertEquals(HTTP_OK, client.getAttributes().get(HTTP_STATUS_CODE));
    assertEquals(HttpMethod.GET, client.getAttributes().get(HTTP_METHOD));
    assertEquals(uri.toString() + "hello", client.getAttributes().get(HTTP_URL));
    assertEquals(client.getTraceId(), server.getTraceId());
    assertEquals(server.getParentSpanId(), client.getSpanId());
}
Also used : Buffer(io.vertx.core.buffer.Buffer) SpanData(io.opentelemetry.sdk.trace.data.SpanData) QuarkusUnitTest(io.quarkus.test.QuarkusUnitTest) Test(org.junit.jupiter.api.Test)

Example 8 with SpanData

use of io.opentelemetry.sdk.trace.data.SpanData in project quarkus by quarkusio.

the class RestClientOpenTelemetryTest method path.

@Test
void path() {
    Response response = client.path("another");
    assertEquals(response.getStatus(), HTTP_OK);
    List<SpanData> spans = spanExporter.getFinishedSpanItems(2);
    SpanData server = spans.get(0);
    assertEquals(SERVER, server.getKind());
    assertEquals("/hello/{path}", server.getName());
    assertEquals(HTTP_OK, server.getAttributes().get(HTTP_STATUS_CODE));
    assertEquals(HttpMethod.GET, server.getAttributes().get(HTTP_METHOD));
    assertEquals("/hello/{path}", server.getAttributes().get(HTTP_ROUTE));
    assertEquals(uri.getHost() + ":" + uri.getPort(), server.getAttributes().get(HTTP_HOST));
    assertEquals(uri.getPath() + "hello/another", server.getAttributes().get(HTTP_TARGET));
    SpanData client = spans.get(1);
    assertEquals(CLIENT, client.getKind());
    assertEquals("/hello/{path}", client.getName());
    assertEquals(HTTP_OK, client.getAttributes().get(HTTP_STATUS_CODE));
    assertEquals(HttpMethod.GET, client.getAttributes().get(HTTP_METHOD));
    assertEquals(uri.toString() + "hello/another", client.getAttributes().get(HTTP_URL));
    assertEquals(client.getTraceId(), server.getTraceId());
    assertEquals(server.getParentSpanId(), client.getSpanId());
}
Also used : Response(javax.ws.rs.core.Response) SpanData(io.opentelemetry.sdk.trace.data.SpanData) QuarkusUnitTest(io.quarkus.test.QuarkusUnitTest) Test(org.junit.jupiter.api.Test)

Example 9 with SpanData

use of io.opentelemetry.sdk.trace.data.SpanData in project quarkus by quarkusio.

the class RestClientOpenTelemetryTest method urlWithoutAuthentication.

@Test
void urlWithoutAuthentication() {
    WebTarget target = ClientBuilder.newClient().target(UriBuilder.fromUri(uri).userInfo("username:password").path("hello").queryParam("query", "1"));
    Response response = target.request().get();
    assertEquals(response.getStatus(), HTTP_OK);
    List<SpanData> spans = spanExporter.getFinishedSpanItems(2);
    SpanData client = spans.get(1);
    assertEquals(CLIENT, client.getKind());
    assertEquals("/hello", client.getName());
    assertEquals(HTTP_OK, client.getAttributes().get(HTTP_STATUS_CODE));
    assertEquals(HttpMethod.GET, client.getAttributes().get(HTTP_METHOD));
    assertEquals(uri.toString() + "hello?query=1", client.getAttributes().get(HTTP_URL));
    assertEquals(client.getTraceId(), spans.get(0).getTraceId());
    assertEquals(spans.get(0).getParentSpanId(), client.getSpanId());
}
Also used : Response(javax.ws.rs.core.Response) SpanData(io.opentelemetry.sdk.trace.data.SpanData) WebTarget(javax.ws.rs.client.WebTarget) QuarkusUnitTest(io.quarkus.test.QuarkusUnitTest) Test(org.junit.jupiter.api.Test)

Example 10 with SpanData

use of io.opentelemetry.sdk.trace.data.SpanData in project quarkus by quarkusio.

the class RestClientOpenTelemetryTest method spanNameWithoutQueryString.

@Test
void spanNameWithoutQueryString() {
    Response response = client.hello("1");
    assertEquals(response.getStatus(), HTTP_OK);
    List<SpanData> spans = spanExporter.getFinishedSpanItems(2);
    SpanData client = spans.get(1);
    assertEquals(CLIENT, client.getKind());
    assertEquals("/hello", client.getName());
    assertEquals(HTTP_OK, client.getAttributes().get(HTTP_STATUS_CODE));
    assertEquals(HttpMethod.GET, client.getAttributes().get(HTTP_METHOD));
    assertEquals(uri.toString() + "hello?query=1", client.getAttributes().get(HTTP_URL));
    assertEquals(client.getTraceId(), spans.get(0).getTraceId());
    assertEquals(spans.get(0).getParentSpanId(), client.getSpanId());
}
Also used : Response(javax.ws.rs.core.Response) SpanData(io.opentelemetry.sdk.trace.data.SpanData) QuarkusUnitTest(io.quarkus.test.QuarkusUnitTest) Test(org.junit.jupiter.api.Test)

Aggregations

SpanData (io.opentelemetry.sdk.trace.data.SpanData)335 Test (org.junit.jupiter.api.Test)190 Test (org.junit.Test)100 Span (io.opentelemetry.api.trace.Span)78 ArrayList (java.util.ArrayList)71 ReadableSpan (io.opentelemetry.sdk.trace.ReadableSpan)61 SpanExporter (io.opentelemetry.sdk.trace.export.SpanExporter)57 TestSpanData (io.opentelemetry.sdk.testing.trace.TestSpanData)48 ProcessorConfig (com.microsoft.applicationinsights.agent.internal.configuration.Configuration.ProcessorConfig)38 Attributes (io.opentelemetry.api.common.Attributes)38 List (java.util.List)35 EventData (io.opentelemetry.sdk.trace.data.EventData)32 CompletableResultCode (io.opentelemetry.sdk.common.CompletableResultCode)29 SpanKind (io.opentelemetry.api.trace.SpanKind)27 SemanticAttributes (io.opentelemetry.semconv.trace.attributes.SemanticAttributes)24 Activity (android.app.Activity)23 ProcessorAction (com.microsoft.applicationinsights.agent.internal.configuration.Configuration.ProcessorAction)23 AttributeKey (io.opentelemetry.api.common.AttributeKey)19 Collectors (java.util.stream.Collectors)19 Scope (io.opentelemetry.context.Scope)17