diff --git a/bom/application/pom.xml b/bom/application/pom.xml index 23b1674c510699..4c8c367268a6ce 100644 --- a/bom/application/pom.xml +++ b/bom/application/pom.xml @@ -36,8 +36,8 @@ 0.2.4 0.1.15 0.1.5 - 1.23.1 - 1.23.0-alpha + 1.24.0 + 1.24.0-alpha 1.23.0-alpha 1.23.0 1.8.1 diff --git a/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/instrumentation/VertxClientOpenTelemetryTest.java b/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/instrumentation/VertxClientOpenTelemetryTest.java index f99592e6f7706b..97419bbf5426c1 100644 --- a/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/instrumentation/VertxClientOpenTelemetryTest.java +++ b/extensions/opentelemetry/deployment/src/test/java/io/quarkus/opentelemetry/deployment/instrumentation/VertxClientOpenTelemetryTest.java @@ -9,6 +9,8 @@ import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.HTTP_URL; import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NET_HOST_NAME; import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NET_HOST_PORT; +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NET_PEER_NAME; +import static io.opentelemetry.semconv.trace.attributes.SemanticAttributes.NET_PEER_PORT; import static io.quarkus.opentelemetry.deployment.common.TestSpanExporter.getSpanByKindAndParentId; import static java.net.HttpURLConnection.HTTP_OK; import static java.util.stream.Collectors.toSet; @@ -79,6 +81,8 @@ void client() throws Exception { 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(uri.getHost(), client.getAttributes().get(NET_PEER_NAME)); + assertEquals(uri.getPort(), client.getAttributes().get(NET_PEER_PORT)); SpanData server = getSpanByKindAndParentId(spans, SERVER, client.getSpanId()); assertEquals(SERVER, server.getKind()); @@ -111,6 +115,8 @@ void path() throws Exception { 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(uri.getHost(), client.getAttributes().get(NET_PEER_NAME)); + assertEquals(uri.getPort(), client.getAttributes().get(NET_PEER_PORT)); SpanData server = getSpanByKindAndParentId(spans, SERVER, client.getSpanId()); assertEquals(SERVER, server.getKind()); diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/graal/Target_io_opentelemetry_exporter_otlp_internal_grpc_ManagedChannelUtil.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/graal/Target_io_opentelemetry_exporter_otlp_internal_grpc_ManagedChannelUtil.java index c5e632010db264..39d466cb7263dd 100644 --- a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/graal/Target_io_opentelemetry_exporter_otlp_internal_grpc_ManagedChannelUtil.java +++ b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/graal/Target_io_opentelemetry_exporter_otlp_internal_grpc_ManagedChannelUtil.java @@ -24,18 +24,11 @@ final class Target_io_opentelemetry_exporter_otlp_internal_grpc_ManagedChannelUt @Substitute public static void setClientKeysAndTrustedCertificatesPem( ManagedChannelBuilder managedChannelBuilder, - byte[] privateKeyPem, - byte[] certificatePem, - byte[] trustedCertificatesPem) + X509TrustManager tmf, + X509KeyManager kmf) throws SSLException { requireNonNull(managedChannelBuilder, "managedChannelBuilder"); - requireNonNull(trustedCertificatesPem, "trustedCertificatesPem"); - - X509TrustManager tmf = TlsUtil.trustManager(trustedCertificatesPem); - X509KeyManager kmf = null; - if (privateKeyPem != null && certificatePem != null) { - kmf = TlsUtil.keyManager(privateKeyPem, certificatePem); - } + requireNonNull(tmf, "X509TrustManager"); // gRPC does not abstract TLS configuration so we need to check the implementation and act // accordingly. diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/restclient/OpenTelemetryClientFilter.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/restclient/OpenTelemetryClientFilter.java index 55d23a672b3bc4..bf4688a4a10d11 100644 --- a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/restclient/OpenTelemetryClientFilter.java +++ b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/restclient/OpenTelemetryClientFilter.java @@ -26,6 +26,8 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpClientAttributesGetter; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter; +import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import io.quarkus.arc.Unremovable; import io.quarkus.opentelemetry.runtime.QuarkusContextStorage; @@ -60,6 +62,7 @@ public OpenTelemetryClientFilter() { @Inject public OpenTelemetryClientFilter(final OpenTelemetry openTelemetry) { ClientAttributesExtractor clientAttributesExtractor = new ClientAttributesExtractor(); + ClientNetAttributesGetter clientNetAttributesExtractor = new ClientNetAttributesGetter(); InstrumenterBuilder builder = Instrumenter.builder( openTelemetry, @@ -68,7 +71,8 @@ public OpenTelemetryClientFilter(final OpenTelemetry openTelemetry) { this.instrumenter = builder .setSpanStatusExtractor(HttpSpanStatusExtractor.create(clientAttributesExtractor)) - .addAttributesExtractor(HttpClientAttributesExtractor.create(clientAttributesExtractor)) + .addAttributesExtractor(HttpClientAttributesExtractor.create( + clientAttributesExtractor, clientNetAttributesExtractor)) .buildClientInstrumenter(new ClientRequestContextTextMapSetter()); } @@ -178,4 +182,23 @@ public List getResponseHeader(final ClientRequestContext request, final return response.getHeaders().getOrDefault(name, emptyList()); } } + + private static class ClientNetAttributesGetter + implements NetClientAttributesGetter { + + @Override + public String getTransport(ClientRequestContext clientRequestContext, ClientResponseContext clientResponseContext) { + return SemanticAttributes.NetTransportValues.IP_TCP; + } + + @Override + public String getPeerName(ClientRequestContext clientRequestContext) { + return clientRequestContext.getUri().getHost(); + } + + @Override + public Integer getPeerPort(ClientRequestContext clientRequestContext) { + return clientRequestContext.getUri().getPort(); + } + } } diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/vertx/HttpInstrumenterVertxTracer.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/vertx/HttpInstrumenterVertxTracer.java index 07a677a3e051b7..38de269b45f384 100644 --- a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/vertx/HttpInstrumenterVertxTracer.java +++ b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/intrumentation/vertx/HttpInstrumenterVertxTracer.java @@ -28,7 +28,9 @@ import io.opentelemetry.instrumentation.api.instrumenter.http.HttpServerAttributesGetter; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanNameExtractor; import io.opentelemetry.instrumentation.api.instrumenter.http.HttpSpanStatusExtractor; +import io.opentelemetry.instrumentation.api.instrumenter.net.NetClientAttributesGetter; import io.opentelemetry.instrumentation.api.instrumenter.net.NetServerAttributesGetter; +import io.opentelemetry.semconv.trace.attributes.SemanticAttributes; import io.vertx.core.Context; import io.vertx.core.MultiMap; import io.vertx.core.http.HttpHeaders; @@ -127,6 +129,7 @@ private static Instrumenter getServerInstrumenter(fin private static Instrumenter getClientInstrumenter(final OpenTelemetry openTelemetry) { ServerAttributesExtractor serverAttributesExtractor = new ServerAttributesExtractor(); ClientAttributesExtractor clientAttributesExtractor = new ClientAttributesExtractor(); + HttpClientNetAttributeGetter httpClientNetAttributeGetter = new HttpClientNetAttributeGetter(); InstrumenterBuilder clientBuilder = Instrumenter.builder( openTelemetry, @@ -135,7 +138,8 @@ private static Instrumenter getClientInstrumenter(fin return clientBuilder .setSpanStatusExtractor(HttpSpanStatusExtractor.create(serverAttributesExtractor)) - .addAttributesExtractor(HttpClientAttributesExtractor.create(clientAttributesExtractor)) + .addAttributesExtractor(HttpClientAttributesExtractor.create( + clientAttributesExtractor, httpClientNetAttributeGetter)) .buildClientInstrumenter(new HttpRequestTextMapSetter()); } @@ -295,6 +299,25 @@ public Integer getHostPort(HttpRequest httpRequest) { } } + private static class HttpClientNetAttributeGetter implements NetClientAttributesGetter { + @Override + public String getTransport(HttpRequest httpClientRequest, HttpResponse httpClientResponse) { + return SemanticAttributes.NetTransportValues.IP_TCP; + } + + @javax.annotation.Nullable + @Override + public String getPeerName(HttpRequest httpRequest) { + return httpRequest.remoteAddress().hostName(); + } + + @javax.annotation.Nullable + @Override + public Integer getPeerPort(HttpRequest httpRequest) { + return httpRequest.remoteAddress().port(); + } + } + private static class HttpRequestTextMapGetter implements TextMapGetter { @Override public Iterable keys(final HttpRequest carrier) {