From 067f4477fa8add0fc258da196b8dd407fb11bdde Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Mon, 31 Jul 2023 13:52:23 +0300 Subject: [PATCH] Introduce HTTP OTLP exporter The integration utilizes the HttpSender interface introduced in OTel 1.28 and is based on the Vert.x HTTP Client --- .../exporter/OtlpExporterTracesConfig.java | 10 +- .../otlp/NonCopyingByteArrayOutputStream.java | 18 ++ .../exporter/otlp/OtlpExporterUtil.java | 26 +++ .../runtime/exporter/otlp/OtlpRecorder.java | 219 +++++++++++------- .../exporter/otlp/VertxGrpcExporter.java | 34 +-- .../exporter/otlp/VertxHttpExporter.java | 165 +++++++++++++ .../pom.xml | 4 +- .../vertx}/exporter/HelloResource.java | 2 +- .../src/main/resources/application.properties | 0 .../vertx}/exporter/AbstractExporterTest.java | 2 +- .../OtelCollectorLifecycleManager.java | 18 +- .../opentelemetry/vertx}/exporter/Traces.java | 2 +- .../grpc/GrpcNoTLSNoCompressionTest.java | 12 + .../grpc/GrpcNoTLSWithCompressionTest.java} | 6 +- .../grpc/GrpcWithTLSNoCompressionTest.java} | 6 +- .../grpc/GrpcWithTLSWithCompressionTest.java} | 6 +- ...thTLSWithTrustAllWithCompressionTest.java} | 8 +- .../http/HttpNoTLSNoCompressionTest.java | 13 ++ .../http/HttpNoTLSWithCompressionTest.java | 16 ++ .../http/HttpWithTLSNoCompressionTest.java | 16 ++ .../http/HttpWithTLSWithCompressionTest.java | 17 ++ ...ithTLSWithTrustAllWithCompressionTest.java | 33 +++ .../src/test/resources/otel-config.yaml | 16 +- .../grpc/exporter/NoTLSNoCompressionTest.java | 10 - integration-tests/pom.xml | 4 +- 25 files changed, 508 insertions(+), 155 deletions(-) create mode 100644 extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/NonCopyingByteArrayOutputStream.java create mode 100644 extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/OtlpExporterUtil.java create mode 100644 extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/VertxHttpExporter.java rename integration-tests/{opentelemetry-vertx-grpc-exporter => opentelemetry-vertx-exporter}/pom.xml (97%) rename integration-tests/{opentelemetry-vertx-grpc-exporter/src/main/java/io/quarkus/it/opentelemetry/vertx/grpc => opentelemetry-vertx-exporter/src/main/java/io/quarkus/it/opentelemetry/vertx}/exporter/HelloResource.java (74%) rename integration-tests/{opentelemetry-vertx-grpc-exporter => opentelemetry-vertx-exporter}/src/main/resources/application.properties (100%) rename integration-tests/{opentelemetry-vertx-grpc-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/grpc => opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx}/exporter/AbstractExporterTest.java (98%) rename integration-tests/{opentelemetry-vertx-grpc-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/grpc => opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx}/exporter/OtelCollectorLifecycleManager.java (91%) rename integration-tests/{opentelemetry-vertx-grpc-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/grpc => opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx}/exporter/Traces.java (88%) create mode 100644 integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/grpc/GrpcNoTLSNoCompressionTest.java rename integration-tests/{opentelemetry-vertx-grpc-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/grpc/exporter/NoTLSWithCompressionTest.java => opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/grpc/GrpcNoTLSWithCompressionTest.java} (53%) rename integration-tests/{opentelemetry-vertx-grpc-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/grpc/exporter/WithTLSNoCompressionTest.java => opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/grpc/GrpcWithTLSNoCompressionTest.java} (52%) rename integration-tests/{opentelemetry-vertx-grpc-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/grpc/exporter/WithTLSWithCompressionTest.java => opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/grpc/GrpcWithTLSWithCompressionTest.java} (57%) rename integration-tests/{opentelemetry-vertx-grpc-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/grpc/exporter/WithTLSWithTrustAllWithCompressionTest.java => opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/grpc/GrpcWithTLSWithTrustAllWithCompressionTest.java} (68%) create mode 100644 integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/http/HttpNoTLSNoCompressionTest.java create mode 100644 integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/http/HttpNoTLSWithCompressionTest.java create mode 100644 integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/http/HttpWithTLSNoCompressionTest.java create mode 100644 integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/http/HttpWithTLSWithCompressionTest.java create mode 100644 integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/http/HttpWithTLSWithTrustAllWithCompressionTest.java rename integration-tests/{opentelemetry-vertx-grpc-exporter => opentelemetry-vertx-exporter}/src/test/resources/otel-config.yaml (76%) delete mode 100644 integration-tests/opentelemetry-vertx-grpc-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/grpc/exporter/NoTLSNoCompressionTest.java diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/config/runtime/exporter/OtlpExporterTracesConfig.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/config/runtime/exporter/OtlpExporterTracesConfig.java index 95ccbd654753c5..d7fdb965242edc 100644 --- a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/config/runtime/exporter/OtlpExporterTracesConfig.java +++ b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/config/runtime/exporter/OtlpExporterTracesConfig.java @@ -54,8 +54,10 @@ public interface OtlpExporterTracesConfig { /** * OTLP defines the encoding of telemetry data and the protocol used to exchange data between the client and the * server. Depending on the exporter, the available protocols will be different. + *

+ * Currently, only {@code grpc} and {@code http} are allowed. */ - @WithDefault(Protocol.HTTP_PROTOBUF) + @WithDefault(Protocol.GRPC) Optional protocol(); /** @@ -89,9 +91,9 @@ interface TrustCert { Optional> certs(); } - public static class Protocol { + class Protocol { public static final String GRPC = "grpc"; - public static final String HTTP_PROTOBUF = "http/protobuf"; - public static final String HTTP_JSON = "http/json"; + public static final String HTTP_PROTOBUF = "http"; + public static final String HTTP_JSON = "http+json"; } } diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/NonCopyingByteArrayOutputStream.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/NonCopyingByteArrayOutputStream.java new file mode 100644 index 00000000000000..b200efa7acf3cd --- /dev/null +++ b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/NonCopyingByteArrayOutputStream.java @@ -0,0 +1,18 @@ +package io.quarkus.opentelemetry.runtime.exporter.otlp; + +import java.io.ByteArrayOutputStream; + +/** + * Used when we know that the stream will never be used again, therefore we can skip copying the data + * WARNING: This should only be used when we know that we will write at least this many bytes to the stream + */ +final class NonCopyingByteArrayOutputStream extends ByteArrayOutputStream { + NonCopyingByteArrayOutputStream(int size) { + super(size); + } + + @Override + public byte[] toByteArray() { + return buf; + } +} diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/OtlpExporterUtil.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/OtlpExporterUtil.java new file mode 100644 index 00000000000000..1108a7aca4f243 --- /dev/null +++ b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/OtlpExporterUtil.java @@ -0,0 +1,26 @@ +package io.quarkus.opentelemetry.runtime.exporter.otlp; + +import java.net.URI; +import java.util.Locale; + +final class OtlpExporterUtil { + + private OtlpExporterUtil() { + } + + static int getPort(URI uri) { + int originalPort = uri.getPort(); + if (originalPort > -1) { + return originalPort; + } + + if (isHttps(uri)) { + return 443; + } + return 80; + } + + static boolean isHttps(URI uri) { + return "https".equals(uri.getScheme().toLowerCase(Locale.ROOT)); + } +} diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/OtlpRecorder.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/OtlpRecorder.java index 8f89f33608e47f..d9e0e43718c6d4 100644 --- a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/OtlpRecorder.java +++ b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/OtlpRecorder.java @@ -1,6 +1,8 @@ package io.quarkus.opentelemetry.runtime.exporter.otlp; import static io.quarkus.opentelemetry.runtime.config.runtime.exporter.OtlpExporterRuntimeConfig.DEFAULT_GRPC_BASE_URI; +import static io.quarkus.opentelemetry.runtime.config.runtime.exporter.OtlpExporterTracesConfig.Protocol.GRPC; +import static io.quarkus.opentelemetry.runtime.config.runtime.exporter.OtlpExporterTracesConfig.Protocol.HTTP_JSON; import static io.quarkus.opentelemetry.runtime.config.runtime.exporter.OtlpExporterTracesConfig.Protocol.HTTP_PROTOBUF; import java.net.URI; @@ -16,6 +18,8 @@ import io.opentelemetry.api.metrics.MeterProvider; import io.opentelemetry.exporter.internal.ExporterBuilderUtil; +import io.opentelemetry.exporter.internal.http.HttpExporter; +import io.opentelemetry.exporter.internal.otlp.traces.TraceRequestMarshaler; import io.opentelemetry.exporter.otlp.internal.OtlpUserAgent; import io.opentelemetry.sdk.trace.export.BatchSpanProcessor; import io.opentelemetry.sdk.trace.export.BatchSpanProcessorBuilder; @@ -41,12 +45,12 @@ public Function, LateBou OTelRuntimeConfig otelRuntimeConfig, OtlpExporterRuntimeConfig exporterRuntimeConfig, TlsConfig tlsConfig, Supplier vertx) { - URI grpcBaseUri = getGrpcBaseUri(exporterRuntimeConfig); // do the creation and validation here in order to preserve backward compatibility + URI baseUri = getBaseUri(exporterRuntimeConfig); // do the creation and validation here in order to preserve backward compatibility return new Function<>() { @Override public LateBoundBatchSpanProcessor apply( SyntheticCreationalContext context) { - if (otelRuntimeConfig.sdkDisabled() || grpcBaseUri == null) { + if (otelRuntimeConfig.sdkDisabled() || baseUri == null) { return RemoveableLateBoundBatchSpanProcessor.INSTANCE; } // Only create the OtlpGrpcSpanExporter if an endpoint was set in runtime config and was properly validated at startup @@ -57,7 +61,7 @@ public LateBoundBatchSpanProcessor apply( } try { - var spanExporter = createOtlpGrpcSpanExporter(exporterRuntimeConfig, vertx.get(), grpcBaseUri); + var spanExporter = createSpanExporter(exporterRuntimeConfig, vertx.get(), baseUri); BatchSpanProcessorBuilder processorBuilder = BatchSpanProcessor.builder(spanExporter); @@ -73,102 +77,95 @@ public LateBoundBatchSpanProcessor apply( } } - private SpanExporter createOtlpGrpcSpanExporter(OtlpExporterRuntimeConfig exporterRuntimeConfig, - Vertx vertx, final URI grpcBaseUri) { - + private SpanExporter createSpanExporter(OtlpExporterRuntimeConfig exporterRuntimeConfig, + Vertx vertx, final URI baseUri) { OtlpExporterTracesConfig tracesConfig = exporterRuntimeConfig.traces(); - if (tracesConfig.protocol().isPresent()) { - if (!tracesConfig.protocol().get().equals(HTTP_PROTOBUF)) { - throw new IllegalStateException("Only the GRPC Exporter is currently supported. " + - "Please check `quarkus.otel.exporter.otlp.traces.protocol` property"); - } + if (tracesConfig.protocol().isEmpty()) { + throw new IllegalStateException("No OTLP protocol specified. " + + "Please check `quarkus.otel.exporter.otlp.traces.protocol` property"); } - boolean compressionEnabled = false; - if (tracesConfig.compression().isPresent()) { - compressionEnabled = (tracesConfig.compression().get() == CompressionType.GZIP); + String protocol = tracesConfig.protocol().get(); + if (GRPC.equals(protocol)) { + return createOtlpGrpcSpanExporter(exporterRuntimeConfig, vertx, baseUri); + } else if (HTTP_PROTOBUF.equals(protocol)) { + return createHttpSpanExporter(exporterRuntimeConfig, vertx, baseUri, protocol); } - Map headersMap = new HashMap<>(); - OtlpUserAgent.addUserAgentHeader(headersMap::put); - if (tracesConfig.headers().isPresent()) { - List headers = tracesConfig.headers().get(); - if (!headers.isEmpty()) { - for (String header : headers) { - if (header.isEmpty()) { - continue; - } - String[] parts = header.split("=", 2); - String key = parts[0].trim(); - String value = parts[1].trim(); - headersMap.put(key, value); - } - } - } + throw new IllegalArgumentException(String.format("Unsupported OTLP protocol %s specified. " + + "Please check `quarkus.otel.exporter.otlp.traces.protocol` property", protocol)); + } + + private SpanExporter createOtlpGrpcSpanExporter(OtlpExporterRuntimeConfig exporterRuntimeConfig, + Vertx vertx, final URI baseUri) { + + OtlpExporterTracesConfig tracesConfig = exporterRuntimeConfig.traces(); return new VertxGrpcExporter( "otlp", // use the same as OTel does "span", // use the same as OTel does MeterProvider::noop, - grpcBaseUri, - compressionEnabled, + baseUri, + determineCompression(tracesConfig), tracesConfig.timeout(), - headersMap, - new Consumer<>() { - @Override - public void accept(HttpClientOptions options) { - configureTLS(options); - } - - private void configureTLS(HttpClientOptions options) { - // TODO: this can reuse existing stuff when https://github.com/quarkusio/quarkus/pull/33228 is in - options.setKeyCertOptions(toPemKeyCertOptions(tracesConfig)); - options.setPemTrustOptions(toPemTrustOptions(tracesConfig)); - - if (VertxGrpcExporter.isHttps(grpcBaseUri)) { - options.setSsl(true); - options.setUseAlpn(true); - } - if (tlsConfig.trustAll) { - options.setTrustAll(true); - options.setVerifyHost(false); - } - } - - private KeyCertOptions toPemKeyCertOptions(OtlpExporterTracesConfig configuration) { - PemKeyCertOptions pemKeyCertOptions = new PemKeyCertOptions(); - OtlpExporterTracesConfig.KeyCert keyCert = configuration.keyCert(); - if (keyCert.certs().isPresent()) { - for (String cert : keyCert.certs().get()) { - pemKeyCertOptions.addCertPath(cert); - } - } - if (keyCert.keys().isPresent()) { - for (String cert : keyCert.keys().get()) { - pemKeyCertOptions.addKeyPath(cert); - } - } - return pemKeyCertOptions; - } - - private PemTrustOptions toPemTrustOptions(OtlpExporterTracesConfig configuration) { - PemTrustOptions pemTrustOptions = new PemTrustOptions(); - OtlpExporterTracesConfig.TrustCert trustCert = configuration.trustCert(); - if (trustCert.certs().isPresent()) { - for (String cert : trustCert.certs().get()) { - pemTrustOptions.addCertPath(cert); - } - } - return pemTrustOptions; - } - }, + populateTracingExportHttpHeaders(tracesConfig), + new HttpClientOptionsConsumer(tracesConfig, baseUri, tlsConfig), vertx); } + + private SpanExporter createHttpSpanExporter(OtlpExporterRuntimeConfig exporterRuntimeConfig, Vertx vertx, + URI baseUri, String protocol) { + + OtlpExporterTracesConfig tracesConfig = exporterRuntimeConfig.traces(); + + boolean exportAsJson = HTTP_JSON.equals(protocol); + + return new VertxHttpExporter(new HttpExporter( + "otlp", // use the same as OTel does + "span", // use the same as OTel does + new VertxHttpExporter.VertxHttpSender( + baseUri, + determineCompression(tracesConfig), + tracesConfig.timeout(), + populateTracingExportHttpHeaders(tracesConfig), + exportAsJson ? "application/json" : "application/x-protobuf", + new HttpClientOptionsConsumer(tracesConfig, baseUri, tlsConfig), + vertx), + MeterProvider::noop, + exportAsJson)); + } }; } - private URI getGrpcBaseUri(OtlpExporterRuntimeConfig exporterRuntimeConfig) { + private static boolean determineCompression(OtlpExporterTracesConfig tracesConfig) { + if (tracesConfig.compression().isPresent()) { + return (tracesConfig.compression().get() == CompressionType.GZIP); + } + return false; + } + + private static Map populateTracingExportHttpHeaders(OtlpExporterTracesConfig tracesConfig) { + Map headersMap = new HashMap<>(); + OtlpUserAgent.addUserAgentHeader(headersMap::put); + if (tracesConfig.headers().isPresent()) { + List headers = tracesConfig.headers().get(); + if (!headers.isEmpty()) { + for (String header : headers) { + if (header.isEmpty()) { + continue; + } + String[] parts = header.split("=", 2); + String key = parts[0].trim(); + String value = parts[1].trim(); + headersMap.put(key, value); + } + } + } + return headersMap; + } + + private URI getBaseUri(OtlpExporterRuntimeConfig exporterRuntimeConfig) { String endpoint = resolveEndpoint(exporterRuntimeConfig).trim(); if (endpoint.isEmpty()) { return null; @@ -191,4 +188,62 @@ private static boolean excludeDefaultEndpoint(String endpoint) { return !DEFAULT_GRPC_BASE_URI.equals(endpoint); } + private static class HttpClientOptionsConsumer implements Consumer { + private final OtlpExporterTracesConfig tracesConfig; + private final URI baseUri; + private final TlsConfig tlsConfig; + + public HttpClientOptionsConsumer(OtlpExporterTracesConfig tracesConfig, URI baseUri, TlsConfig tlsConfig) { + this.tracesConfig = tracesConfig; + this.baseUri = baseUri; + this.tlsConfig = tlsConfig; + } + + @Override + public void accept(HttpClientOptions options) { + configureTLS(options); + } + + private void configureTLS(HttpClientOptions options) { + // TODO: this can reuse existing stuff when https://github.com/quarkusio/quarkus/pull/33228 is in + options.setKeyCertOptions(toPemKeyCertOptions()); + options.setPemTrustOptions(toPemTrustOptions()); + + if (OtlpExporterUtil.isHttps(baseUri)) { + options.setSsl(true); + options.setUseAlpn(true); + } + if (tlsConfig.trustAll) { + options.setTrustAll(true); + options.setVerifyHost(false); + } + } + + private KeyCertOptions toPemKeyCertOptions() { + PemKeyCertOptions pemKeyCertOptions = new PemKeyCertOptions(); + OtlpExporterTracesConfig.KeyCert keyCert = tracesConfig.keyCert(); + if (keyCert.certs().isPresent()) { + for (String cert : keyCert.certs().get()) { + pemKeyCertOptions.addCertPath(cert); + } + } + if (keyCert.keys().isPresent()) { + for (String cert : keyCert.keys().get()) { + pemKeyCertOptions.addKeyPath(cert); + } + } + return pemKeyCertOptions; + } + + private PemTrustOptions toPemTrustOptions() { + PemTrustOptions pemTrustOptions = new PemTrustOptions(); + OtlpExporterTracesConfig.TrustCert trustCert = tracesConfig.trustCert(); + if (trustCert.certs().isPresent()) { + for (String cert : trustCert.certs().get()) { + pemTrustOptions.addCertPath(cert); + } + } + return pemTrustOptions; + } + } } diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/VertxGrpcExporter.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/VertxGrpcExporter.java index 6d4a4e54cea87c..5377044d463fb5 100644 --- a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/VertxGrpcExporter.java +++ b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/VertxGrpcExporter.java @@ -1,12 +1,10 @@ package io.quarkus.opentelemetry.runtime.exporter.otlp; -import java.io.ByteArrayOutputStream; import java.io.IOException; import java.net.URI; import java.nio.charset.StandardCharsets; import java.time.Duration; import java.util.Collection; -import java.util.Locale; import java.util.Map; import java.util.concurrent.atomic.AtomicBoolean; import java.util.function.Consumer; @@ -68,7 +66,7 @@ final class VertxGrpcExporter implements SpanExporter { Vertx vertx) { this.type = type; this.exporterMetrics = ExporterMetrics.createGrpcOkHttp(exporterName, type, meterProviderSupplier); - this.server = SocketAddress.inetSocketAddress(getPort(grpcBaseUri), grpcBaseUri.getHost()); + this.server = SocketAddress.inetSocketAddress(OtlpExporterUtil.getPort(grpcBaseUri), grpcBaseUri.getHost()); this.compressionEnabled = compressionEnabled; this.headers = headersMap; var httpClientOptions = new HttpClientOptions() @@ -79,22 +77,6 @@ final class VertxGrpcExporter implements SpanExporter { this.client = GrpcClient.client(vertx, httpClientOptions); } - private static int getPort(URI uri) { - int originalPort = uri.getPort(); - if (originalPort > -1) { - return originalPort; - } - - if (isHttps(uri)) { - return 443; - } - return 80; - } - - static boolean isHttps(URI uri) { - return "https".equals(uri.getScheme().toLowerCase(Locale.ROOT)); - } - private CompletableResultCode export(TraceRequestMarshaler marshaler, int numItems) { if (isShutdown.get()) { return CompletableResultCode.ofFailure(); @@ -160,18 +142,6 @@ public CompletableResultCode shutdown() { return CompletableResultCode.ofSuccess(); } - private static final class NonCopyingByteArrayOutputStream extends ByteArrayOutputStream { - - public NonCopyingByteArrayOutputStream(int size) { - super(size); - } - - @Override - public byte[] toByteArray() { - return buf; - } - } - private static final class ClientRequestOnSuccessHandler implements Handler> { private final Map headers; @@ -224,7 +194,7 @@ public void handle(GrpcClientRequest request) { try { int messageSize = marshaler.getBinarySerializedSize(); - var baos = new NonCopyingByteArrayOutputStream(messageSize); + var baos = new NonCopyingByteArrayOutputStream(messageSize); // TODO: we can probably use Vert.x / Netty buffering here marshaler.writeBinaryTo(baos); Buffer buffer = Buffer.buffer(messageSize); buffer.appendBytes(baos.toByteArray()); diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/VertxHttpExporter.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/VertxHttpExporter.java new file mode 100644 index 00000000000000..0242aef5ae5f4c --- /dev/null +++ b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/exporter/otlp/VertxHttpExporter.java @@ -0,0 +1,165 @@ +package io.quarkus.opentelemetry.runtime.exporter.otlp; + +import static io.quarkus.opentelemetry.runtime.exporter.otlp.OtlpExporterUtil.getPort; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.net.URI; +import java.time.Duration; +import java.util.Collection; +import java.util.Map; +import java.util.function.Consumer; +import java.util.zip.GZIPOutputStream; + +import io.opentelemetry.exporter.internal.http.HttpExporter; +import io.opentelemetry.exporter.internal.http.HttpSender; +import io.opentelemetry.exporter.internal.otlp.traces.TraceRequestMarshaler; +import io.opentelemetry.sdk.common.CompletableResultCode; +import io.opentelemetry.sdk.trace.data.SpanData; +import io.opentelemetry.sdk.trace.export.SpanExporter; +import io.vertx.core.AsyncResult; +import io.vertx.core.Handler; +import io.vertx.core.Vertx; +import io.vertx.core.buffer.Buffer; +import io.vertx.core.http.HttpClient; +import io.vertx.core.http.HttpClientOptions; +import io.vertx.core.http.HttpClientRequest; +import io.vertx.core.http.HttpClientResponse; +import io.vertx.core.http.HttpMethod; +import io.vertx.core.tracing.TracingPolicy; + +final class VertxHttpExporter implements SpanExporter { + + private final HttpExporter delegate; + + VertxHttpExporter(HttpExporter delegate) { + this.delegate = delegate; + } + + @Override + public CompletableResultCode export(Collection spans) { + TraceRequestMarshaler exportRequest = TraceRequestMarshaler.create(spans); + return delegate.export(exportRequest, spans.size()); + } + + @Override + public CompletableResultCode flush() { + return CompletableResultCode.ofSuccess(); + } + + @Override + public CompletableResultCode shutdown() { + return delegate.shutdown(); + } + + static final class VertxHttpSender implements HttpSender { + + private static final String TRACES_PATH = "/v1/traces"; + private final boolean compressionEnabled; + private final Map headers; + private final String contentType; + private final HttpClient client; + + VertxHttpSender( + URI baseUri, + boolean compressionEnabled, + Duration timeout, + Map headersMap, + String contentType, + Consumer clientOptionsCustomizer, + Vertx vertx) { + this.compressionEnabled = compressionEnabled; + this.headers = headersMap; + this.contentType = contentType; + var httpClientOptions = new HttpClientOptions() + .setReadIdleTimeout((int) timeout.getSeconds()) + .setDefaultHost(baseUri.getHost()) + .setDefaultPort(getPort(baseUri)) + .setTracingPolicy(TracingPolicy.IGNORE); // needed to avoid tracing the calls from this http client + clientOptionsCustomizer.accept(httpClientOptions); + this.client = vertx.createHttpClient(httpClientOptions); + } + + @Override + public void send(Consumer marshaler, + int contentLength, + Consumer onResponse, + Consumer onError) { + + client.request(HttpMethod.POST, TRACES_PATH) + .onSuccess(new Handler<>() { + @Override + public void handle(HttpClientRequest request) { + + HttpClientRequest clientRequest = request.response(new Handler<>() { + @Override + public void handle(AsyncResult callResult) { + if (callResult.succeeded()) { + HttpClientResponse clientResponse = callResult.result(); + clientResponse.body(new Handler<>() { + @Override + public void handle(AsyncResult bodyResult) { + if (bodyResult.succeeded()) { + onResponse.accept(new Response() { + @Override + public int statusCode() { + return clientResponse.statusCode(); + } + + @Override + public String statusMessage() { + return clientResponse.statusMessage(); + } + + @Override + public byte[] responseBody() { + return bodyResult.result().getBytes(); + } + }); + } else { + onError.accept(bodyResult.cause()); + } + } + }); + } else { + onError.accept(callResult.cause()); + } + } + }) + .putHeader("Content-Type", contentType); + + ByteArrayOutputStream os; // TODO: we can probably use Vert.x / Netty buffering here + if (compressionEnabled) { + os = new ByteArrayOutputStream(contentLength); + clientRequest.putHeader("Content-Encoding", "gzip"); + try (var gzos = new GZIPOutputStream(os)) { + marshaler.accept(gzos); + } catch (IOException e) { + throw new IllegalStateException(e); + } + } else { + os = new NonCopyingByteArrayOutputStream(contentLength); + marshaler.accept(os); + } + + if (!headers.isEmpty()) { + for (var entry : headers.entrySet()) { + clientRequest.putHeader(entry.getKey(), entry.getValue()); + } + } + + clientRequest.send(Buffer.buffer(os.toByteArray())); + + } + }) + .onFailure(onError::accept); + } + + @Override + public CompletableResultCode shutdown() { + client.close(); + return CompletableResultCode.ofSuccess(); + } + } +} diff --git a/integration-tests/opentelemetry-vertx-grpc-exporter/pom.xml b/integration-tests/opentelemetry-vertx-exporter/pom.xml similarity index 97% rename from integration-tests/opentelemetry-vertx-grpc-exporter/pom.xml rename to integration-tests/opentelemetry-vertx-exporter/pom.xml index 0635e60e990d69..62250879fb750b 100644 --- a/integration-tests/opentelemetry-vertx-grpc-exporter/pom.xml +++ b/integration-tests/opentelemetry-vertx-exporter/pom.xml @@ -10,8 +10,8 @@ 999-SNAPSHOT - quarkus-integration-test-opentelemetry-vertx-grpc-exporter - Quarkus - Integration Tests - OpenTelemetry Vert.x gRPC exporter + quarkus-integration-test-opentelemetry-vertx-exporter + Quarkus - Integration Tests - OpenTelemetry Vert.x exporter diff --git a/integration-tests/opentelemetry-vertx-grpc-exporter/src/main/java/io/quarkus/it/opentelemetry/vertx/grpc/exporter/HelloResource.java b/integration-tests/opentelemetry-vertx-exporter/src/main/java/io/quarkus/it/opentelemetry/vertx/exporter/HelloResource.java similarity index 74% rename from integration-tests/opentelemetry-vertx-grpc-exporter/src/main/java/io/quarkus/it/opentelemetry/vertx/grpc/exporter/HelloResource.java rename to integration-tests/opentelemetry-vertx-exporter/src/main/java/io/quarkus/it/opentelemetry/vertx/exporter/HelloResource.java index 7e2021e2ed5fe3..f8c3ccc5a605be 100644 --- a/integration-tests/opentelemetry-vertx-grpc-exporter/src/main/java/io/quarkus/it/opentelemetry/vertx/grpc/exporter/HelloResource.java +++ b/integration-tests/opentelemetry-vertx-exporter/src/main/java/io/quarkus/it/opentelemetry/vertx/exporter/HelloResource.java @@ -1,4 +1,4 @@ -package io.quarkus.it.opentelemetry.vertx.grpc.exporter; +package io.quarkus.it.opentelemetry.vertx.exporter; import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; diff --git a/integration-tests/opentelemetry-vertx-grpc-exporter/src/main/resources/application.properties b/integration-tests/opentelemetry-vertx-exporter/src/main/resources/application.properties similarity index 100% rename from integration-tests/opentelemetry-vertx-grpc-exporter/src/main/resources/application.properties rename to integration-tests/opentelemetry-vertx-exporter/src/main/resources/application.properties diff --git a/integration-tests/opentelemetry-vertx-grpc-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/grpc/exporter/AbstractExporterTest.java b/integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/AbstractExporterTest.java similarity index 98% rename from integration-tests/opentelemetry-vertx-grpc-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/grpc/exporter/AbstractExporterTest.java rename to integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/AbstractExporterTest.java index 1b8805686c2a13..3fffe846f12fa0 100644 --- a/integration-tests/opentelemetry-vertx-grpc-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/grpc/exporter/AbstractExporterTest.java +++ b/integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/AbstractExporterTest.java @@ -1,4 +1,4 @@ -package io.quarkus.it.opentelemetry.vertx.grpc.exporter; +package io.quarkus.it.opentelemetry.vertx.exporter; import static io.restassured.RestAssured.when; import static org.assertj.core.api.Assertions.assertThat; diff --git a/integration-tests/opentelemetry-vertx-grpc-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/grpc/exporter/OtelCollectorLifecycleManager.java b/integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/OtelCollectorLifecycleManager.java similarity index 91% rename from integration-tests/opentelemetry-vertx-grpc-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/grpc/exporter/OtelCollectorLifecycleManager.java rename to integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/OtelCollectorLifecycleManager.java index c80e748bdf4b59..51b2900a7a4282 100644 --- a/integration-tests/opentelemetry-vertx-grpc-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/grpc/exporter/OtelCollectorLifecycleManager.java +++ b/integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/OtelCollectorLifecycleManager.java @@ -1,5 +1,6 @@ -package io.quarkus.it.opentelemetry.vertx.grpc.exporter; +package io.quarkus.it.opentelemetry.vertx.exporter; +import static io.quarkus.opentelemetry.runtime.config.runtime.exporter.OtlpExporterTracesConfig.Protocol.GRPC; import static org.testcontainers.Testcontainers.exposeHostPorts; import java.util.HashMap; @@ -44,6 +45,8 @@ public class OtelCollectorLifecycleManager implements QuarkusTestResourceLifecyc private SelfSignedCertificate serverTls; private SelfSignedCertificate clientTlS; + + private String protocol = GRPC; private boolean enableTLS = false; private boolean preventTrustCert = false; private boolean enableCompression = false; @@ -70,6 +73,10 @@ public void init(Map initArgs) { if (enableCompressionStr != null && !enableCompressionStr.isEmpty()) { enableCompression = Boolean.parseBoolean(enableCompressionStr); } + + if (initArgs.containsKey("protocol")) { + protocol = initArgs.get("protocol"); + } } @Override @@ -114,10 +121,15 @@ public Map start() { collector.start(); Map result = new HashMap<>(); + result.put("quarkus.otel.exporter.otlp.traces.protocol", protocol); + + boolean isGrpc = GRPC.equals(protocol); + int secureEndpointPort = isGrpc ? COLLECTOR_OTLP_GRPC_MTLS_PORT : COLLECTOR_OTLP_HTTP_MTLS_PORT; + int inSecureEndpointPort = isGrpc ? COLLECTOR_OTLP_GRPC_PORT : COLLECTOR_OTLP_HTTP_PORT; if (enableTLS) { result.put("quarkus.otel.exporter.otlp.traces.endpoint", - "https://" + collector.getHost() + ":" + collector.getMappedPort(COLLECTOR_OTLP_GRPC_MTLS_PORT)); + "https://" + collector.getHost() + ":" + collector.getMappedPort(secureEndpointPort)); if (!preventTrustCert) { result.put("quarkus.otel.exporter.otlp.traces.trust-cert.certs", serverTls.certificatePath()); } @@ -125,7 +137,7 @@ public Map start() { result.put("quarkus.otel.exporter.otlp.traces.key-cert.keys", clientTlS.privateKeyPath()); } else { result.put("quarkus.otel.exporter.otlp.traces.endpoint", - "http://" + collector.getHost() + ":" + collector.getMappedPort(COLLECTOR_OTLP_GRPC_PORT)); + "http://" + collector.getHost() + ":" + collector.getMappedPort(inSecureEndpointPort)); } if (enableCompression) { diff --git a/integration-tests/opentelemetry-vertx-grpc-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/grpc/exporter/Traces.java b/integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/Traces.java similarity index 88% rename from integration-tests/opentelemetry-vertx-grpc-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/grpc/exporter/Traces.java rename to integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/Traces.java index 30e46df57dbc8b..eb27363d00d841 100644 --- a/integration-tests/opentelemetry-vertx-grpc-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/grpc/exporter/Traces.java +++ b/integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/Traces.java @@ -1,4 +1,4 @@ -package io.quarkus.it.opentelemetry.vertx.grpc.exporter; +package io.quarkus.it.opentelemetry.vertx.exporter; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; diff --git a/integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/grpc/GrpcNoTLSNoCompressionTest.java b/integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/grpc/GrpcNoTLSNoCompressionTest.java new file mode 100644 index 00000000000000..de67a1f1bae3aa --- /dev/null +++ b/integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/grpc/GrpcNoTLSNoCompressionTest.java @@ -0,0 +1,12 @@ +package io.quarkus.it.opentelemetry.vertx.exporter.grpc; + +import io.quarkus.it.opentelemetry.vertx.exporter.AbstractExporterTest; +import io.quarkus.it.opentelemetry.vertx.exporter.OtelCollectorLifecycleManager; +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +@QuarkusTestResource(value = OtelCollectorLifecycleManager.class, restrictToAnnotatedClass = true) +public class GrpcNoTLSNoCompressionTest extends AbstractExporterTest { + +} diff --git a/integration-tests/opentelemetry-vertx-grpc-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/grpc/exporter/NoTLSWithCompressionTest.java b/integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/grpc/GrpcNoTLSWithCompressionTest.java similarity index 53% rename from integration-tests/opentelemetry-vertx-grpc-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/grpc/exporter/NoTLSWithCompressionTest.java rename to integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/grpc/GrpcNoTLSWithCompressionTest.java index 65f67e19d9f6e2..facf170af3fc6d 100644 --- a/integration-tests/opentelemetry-vertx-grpc-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/grpc/exporter/NoTLSWithCompressionTest.java +++ b/integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/grpc/GrpcNoTLSWithCompressionTest.java @@ -1,11 +1,13 @@ -package io.quarkus.it.opentelemetry.vertx.grpc.exporter; +package io.quarkus.it.opentelemetry.vertx.exporter.grpc; +import io.quarkus.it.opentelemetry.vertx.exporter.AbstractExporterTest; +import io.quarkus.it.opentelemetry.vertx.exporter.OtelCollectorLifecycleManager; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.common.ResourceArg; import io.quarkus.test.junit.QuarkusTest; @QuarkusTest @QuarkusTestResource(value = OtelCollectorLifecycleManager.class, initArgs = @ResourceArg(name = "enableCompression", value = "true"), restrictToAnnotatedClass = true) -public class NoTLSWithCompressionTest extends AbstractExporterTest { +public class GrpcNoTLSWithCompressionTest extends AbstractExporterTest { } diff --git a/integration-tests/opentelemetry-vertx-grpc-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/grpc/exporter/WithTLSNoCompressionTest.java b/integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/grpc/GrpcWithTLSNoCompressionTest.java similarity index 52% rename from integration-tests/opentelemetry-vertx-grpc-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/grpc/exporter/WithTLSNoCompressionTest.java rename to integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/grpc/GrpcWithTLSNoCompressionTest.java index 23d8aea2581b40..b2420fd1b689b0 100644 --- a/integration-tests/opentelemetry-vertx-grpc-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/grpc/exporter/WithTLSNoCompressionTest.java +++ b/integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/grpc/GrpcWithTLSNoCompressionTest.java @@ -1,11 +1,13 @@ -package io.quarkus.it.opentelemetry.vertx.grpc.exporter; +package io.quarkus.it.opentelemetry.vertx.exporter.grpc; +import io.quarkus.it.opentelemetry.vertx.exporter.AbstractExporterTest; +import io.quarkus.it.opentelemetry.vertx.exporter.OtelCollectorLifecycleManager; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.common.ResourceArg; import io.quarkus.test.junit.QuarkusTest; @QuarkusTest @QuarkusTestResource(value = OtelCollectorLifecycleManager.class, initArgs = @ResourceArg(name = "enableTLS", value = "true"), restrictToAnnotatedClass = true) -public class WithTLSNoCompressionTest extends AbstractExporterTest { +public class GrpcWithTLSNoCompressionTest extends AbstractExporterTest { } diff --git a/integration-tests/opentelemetry-vertx-grpc-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/grpc/exporter/WithTLSWithCompressionTest.java b/integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/grpc/GrpcWithTLSWithCompressionTest.java similarity index 57% rename from integration-tests/opentelemetry-vertx-grpc-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/grpc/exporter/WithTLSWithCompressionTest.java rename to integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/grpc/GrpcWithTLSWithCompressionTest.java index 42b958965d3c6c..557c2f8f7f3a7f 100644 --- a/integration-tests/opentelemetry-vertx-grpc-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/grpc/exporter/WithTLSWithCompressionTest.java +++ b/integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/grpc/GrpcWithTLSWithCompressionTest.java @@ -1,5 +1,7 @@ -package io.quarkus.it.opentelemetry.vertx.grpc.exporter; +package io.quarkus.it.opentelemetry.vertx.exporter.grpc; +import io.quarkus.it.opentelemetry.vertx.exporter.AbstractExporterTest; +import io.quarkus.it.opentelemetry.vertx.exporter.OtelCollectorLifecycleManager; import io.quarkus.test.common.QuarkusTestResource; import io.quarkus.test.common.ResourceArg; import io.quarkus.test.junit.QuarkusTest; @@ -9,6 +11,6 @@ @ResourceArg(name = "enableTLS", value = "true"), @ResourceArg(name = "enableCompression", value = "true") }, restrictToAnnotatedClass = true) -public class WithTLSWithCompressionTest extends AbstractExporterTest { +public class GrpcWithTLSWithCompressionTest extends AbstractExporterTest { } diff --git a/integration-tests/opentelemetry-vertx-grpc-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/grpc/exporter/WithTLSWithTrustAllWithCompressionTest.java b/integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/grpc/GrpcWithTLSWithTrustAllWithCompressionTest.java similarity index 68% rename from integration-tests/opentelemetry-vertx-grpc-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/grpc/exporter/WithTLSWithTrustAllWithCompressionTest.java rename to integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/grpc/GrpcWithTLSWithTrustAllWithCompressionTest.java index bd5a85940192fc..3b4240a5d703bf 100644 --- a/integration-tests/opentelemetry-vertx-grpc-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/grpc/exporter/WithTLSWithTrustAllWithCompressionTest.java +++ b/integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/grpc/GrpcWithTLSWithTrustAllWithCompressionTest.java @@ -1,16 +1,18 @@ -package io.quarkus.it.opentelemetry.vertx.grpc.exporter; +package io.quarkus.it.opentelemetry.vertx.exporter.grpc; import java.util.Collections; import java.util.List; import java.util.Map; +import io.quarkus.it.opentelemetry.vertx.exporter.AbstractExporterTest; +import io.quarkus.it.opentelemetry.vertx.exporter.OtelCollectorLifecycleManager; import io.quarkus.test.junit.QuarkusTest; import io.quarkus.test.junit.QuarkusTestProfile; import io.quarkus.test.junit.TestProfile; @QuarkusTest -@TestProfile(WithTLSWithTrustAllWithCompressionTest.Profile.class) -public class WithTLSWithTrustAllWithCompressionTest extends AbstractExporterTest { +@TestProfile(GrpcWithTLSWithTrustAllWithCompressionTest.Profile.class) +public class GrpcWithTLSWithTrustAllWithCompressionTest extends AbstractExporterTest { public static class Profile implements QuarkusTestProfile { @Override diff --git a/integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/http/HttpNoTLSNoCompressionTest.java b/integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/http/HttpNoTLSNoCompressionTest.java new file mode 100644 index 00000000000000..fed08c35ec157c --- /dev/null +++ b/integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/http/HttpNoTLSNoCompressionTest.java @@ -0,0 +1,13 @@ +package io.quarkus.it.opentelemetry.vertx.exporter.http; + +import io.quarkus.it.opentelemetry.vertx.exporter.AbstractExporterTest; +import io.quarkus.it.opentelemetry.vertx.exporter.OtelCollectorLifecycleManager; +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.common.ResourceArg; +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +@QuarkusTestResource(value = OtelCollectorLifecycleManager.class, initArgs = @ResourceArg(name = "protocol", value = "http"), restrictToAnnotatedClass = true) +public class HttpNoTLSNoCompressionTest extends AbstractExporterTest { + +} diff --git a/integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/http/HttpNoTLSWithCompressionTest.java b/integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/http/HttpNoTLSWithCompressionTest.java new file mode 100644 index 00000000000000..7025b1215dfbee --- /dev/null +++ b/integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/http/HttpNoTLSWithCompressionTest.java @@ -0,0 +1,16 @@ +package io.quarkus.it.opentelemetry.vertx.exporter.http; + +import io.quarkus.it.opentelemetry.vertx.exporter.AbstractExporterTest; +import io.quarkus.it.opentelemetry.vertx.exporter.OtelCollectorLifecycleManager; +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.common.ResourceArg; +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +@QuarkusTestResource(value = OtelCollectorLifecycleManager.class, initArgs = { + @ResourceArg(name = "enableCompression", value = "true"), + @ResourceArg(name = "protocol", value = "http") +}, restrictToAnnotatedClass = true) +public class HttpNoTLSWithCompressionTest extends AbstractExporterTest { + +} diff --git a/integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/http/HttpWithTLSNoCompressionTest.java b/integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/http/HttpWithTLSNoCompressionTest.java new file mode 100644 index 00000000000000..ea4b0d7e47679e --- /dev/null +++ b/integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/http/HttpWithTLSNoCompressionTest.java @@ -0,0 +1,16 @@ +package io.quarkus.it.opentelemetry.vertx.exporter.http; + +import io.quarkus.it.opentelemetry.vertx.exporter.AbstractExporterTest; +import io.quarkus.it.opentelemetry.vertx.exporter.OtelCollectorLifecycleManager; +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.common.ResourceArg; +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +@QuarkusTestResource(value = OtelCollectorLifecycleManager.class, initArgs = { + @ResourceArg(name = "enableTLS", value = "true"), + @ResourceArg(name = "protocol", value = "http") +}, restrictToAnnotatedClass = true) +public class HttpWithTLSNoCompressionTest extends AbstractExporterTest { + +} diff --git a/integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/http/HttpWithTLSWithCompressionTest.java b/integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/http/HttpWithTLSWithCompressionTest.java new file mode 100644 index 00000000000000..561c3523033523 --- /dev/null +++ b/integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/http/HttpWithTLSWithCompressionTest.java @@ -0,0 +1,17 @@ +package io.quarkus.it.opentelemetry.vertx.exporter.http; + +import io.quarkus.it.opentelemetry.vertx.exporter.AbstractExporterTest; +import io.quarkus.it.opentelemetry.vertx.exporter.OtelCollectorLifecycleManager; +import io.quarkus.test.common.QuarkusTestResource; +import io.quarkus.test.common.ResourceArg; +import io.quarkus.test.junit.QuarkusTest; + +@QuarkusTest +@QuarkusTestResource(value = OtelCollectorLifecycleManager.class, initArgs = { + @ResourceArg(name = "enableTLS", value = "true"), + @ResourceArg(name = "enableCompression", value = "true"), + @ResourceArg(name = "protocol", value = "http") +}, restrictToAnnotatedClass = true) +public class HttpWithTLSWithCompressionTest extends AbstractExporterTest { + +} diff --git a/integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/http/HttpWithTLSWithTrustAllWithCompressionTest.java b/integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/http/HttpWithTLSWithTrustAllWithCompressionTest.java new file mode 100644 index 00000000000000..488818a3575886 --- /dev/null +++ b/integration-tests/opentelemetry-vertx-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/exporter/http/HttpWithTLSWithTrustAllWithCompressionTest.java @@ -0,0 +1,33 @@ +package io.quarkus.it.opentelemetry.vertx.exporter.http; + +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import io.quarkus.it.opentelemetry.vertx.exporter.AbstractExporterTest; +import io.quarkus.it.opentelemetry.vertx.exporter.OtelCollectorLifecycleManager; +import io.quarkus.test.junit.QuarkusTest; +import io.quarkus.test.junit.QuarkusTestProfile; +import io.quarkus.test.junit.TestProfile; + +@QuarkusTest +@TestProfile(HttpWithTLSWithTrustAllWithCompressionTest.Profile.class) +public class HttpWithTLSWithTrustAllWithCompressionTest extends AbstractExporterTest { + + public static class Profile implements QuarkusTestProfile { + @Override + public Map getConfigOverrides() { + return Map.of("quarkus.tls.trust-all", "true"); + } + + @Override + public List testResources() { + return Collections.singletonList( + new TestResourceEntry( + OtelCollectorLifecycleManager.class, + Map.of("enableTLS", "true", "enableCompression", "true", "preventTrustCert", "true", "protocol", + "http"))); + } + } + +} diff --git a/integration-tests/opentelemetry-vertx-grpc-exporter/src/test/resources/otel-config.yaml b/integration-tests/opentelemetry-vertx-exporter/src/test/resources/otel-config.yaml similarity index 76% rename from integration-tests/opentelemetry-vertx-grpc-exporter/src/test/resources/otel-config.yaml rename to integration-tests/opentelemetry-vertx-exporter/src/test/resources/otel-config.yaml index 24e1239387835b..bab60e41819c7a 100644 --- a/integration-tests/opentelemetry-vertx-grpc-exporter/src/test/resources/otel-config.yaml +++ b/integration-tests/opentelemetry-vertx-exporter/src/test/resources/otel-config.yaml @@ -5,8 +5,8 @@ receivers: protocols: grpc: endpoint: 0.0.0.0:4317 -# http: -# endpoint: 0.0.0.0:4318 + http: + endpoint: 0.0.0.0:4318 otlp/mtls: protocols: grpc: @@ -15,12 +15,12 @@ receivers: client_ca_file: $MTLS_CLIENT_CERTIFICATE cert_file: $MTLS_SERVER_CERTIFICATE key_file: $MTLS_SERVER_KEY -# http: -# endpoint: 0.0.0.0:5318 -# tls: -# client_ca_file: $MTLS_CLIENT_CERTIFICATE -# cert_file: $MTLS_SERVER_CERTIFICATE -# key_file: $MTLS_SERVER_KEY + http: + endpoint: 0.0.0.0:5318 + tls: + client_ca_file: $MTLS_CLIENT_CERTIFICATE + cert_file: $MTLS_SERVER_CERTIFICATE + key_file: $MTLS_SERVER_KEY exporters: logging: verbosity: $LOGGING_EXPORTER_VERBOSITY_LEVEL diff --git a/integration-tests/opentelemetry-vertx-grpc-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/grpc/exporter/NoTLSNoCompressionTest.java b/integration-tests/opentelemetry-vertx-grpc-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/grpc/exporter/NoTLSNoCompressionTest.java deleted file mode 100644 index 47f6d31a98d4e9..00000000000000 --- a/integration-tests/opentelemetry-vertx-grpc-exporter/src/test/java/io/quarkus/it/opentelemetry/vertx/grpc/exporter/NoTLSNoCompressionTest.java +++ /dev/null @@ -1,10 +0,0 @@ -package io.quarkus.it.opentelemetry.vertx.grpc.exporter; - -import io.quarkus.test.common.QuarkusTestResource; -import io.quarkus.test.junit.QuarkusTest; - -@QuarkusTest -@QuarkusTestResource(value = OtelCollectorLifecycleManager.class, restrictToAnnotatedClass = true) -public class NoTLSNoCompressionTest extends AbstractExporterTest { - -} diff --git a/integration-tests/pom.xml b/integration-tests/pom.xml index edbce987659e58..31a50fda0f4e28 100644 --- a/integration-tests/pom.xml +++ b/integration-tests/pom.xml @@ -358,7 +358,7 @@ opentelemetry-vertx opentelemetry-reactive opentelemetry-grpc - opentelemetry-vertx-grpc-exporter + opentelemetry-vertx-exporter opentelemetry-reactive-messaging logging-json jaxb @@ -512,4 +512,4 @@ - \ No newline at end of file +