From 7f130a939d8782ccc14719764293c6fe4805aeaa Mon Sep 17 00:00:00 2001 From: brunobat Date: Tue, 17 Oct 2023 11:36:33 +0100 Subject: [PATCH] Fix native mode and update parent --- pom.xml | 11 +++++--- .../RemovableLateBoundSpanProcessor.java | 14 ++++++++++ .../gcp/deployment/GcpExporterProcessor.java | 8 ++++++ .../src/main/resources/application.properties | 2 -- .../runtime/pom.xml | 21 ++++++++------- .../gcp/runtime/graal/Substitutions.java | 27 +++++++++++++++++++ .../deployment/JaegerExporterProcessor.java | 10 +++++++ 7 files changed, 77 insertions(+), 16 deletions(-) create mode 100644 quarkus-opentelemetry-exporter-common/src/main/java/io/quarkiverse/opentelemetry/exporter/common/runtime/RemovableLateBoundSpanProcessor.java diff --git a/pom.xml b/pom.xml index b410f33..df50ff1 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ io.quarkiverse quarkiverse-parent - 12 + 15 @@ -34,12 +34,15 @@ UTF-8 UTF-8 - 3.5.1 + 3.5.0 1.30.1 1.30.0-alpha - 0.25.2 - 2.25.0 + + 0.23.0 + + 2.23.0 + 1.8.2 3.24.2 1.18.0 diff --git a/quarkus-opentelemetry-exporter-common/src/main/java/io/quarkiverse/opentelemetry/exporter/common/runtime/RemovableLateBoundSpanProcessor.java b/quarkus-opentelemetry-exporter-common/src/main/java/io/quarkiverse/opentelemetry/exporter/common/runtime/RemovableLateBoundSpanProcessor.java new file mode 100644 index 0000000..525ffe8 --- /dev/null +++ b/quarkus-opentelemetry-exporter-common/src/main/java/io/quarkiverse/opentelemetry/exporter/common/runtime/RemovableLateBoundSpanProcessor.java @@ -0,0 +1,14 @@ +package io.quarkiverse.opentelemetry.exporter.common.runtime; + +/** + * The only point in having this class is to allow {@link TracerProviderCustomizer} + * to easily ignore the configured {@link LateBoundSpanProcessor}. + */ +public final class RemovableLateBoundSpanProcessor extends LateBoundSpanProcessor { + + public static final RemovableLateBoundSpanProcessor INSTANCE = new RemovableLateBoundSpanProcessor(); + + private RemovableLateBoundSpanProcessor() { + super(null); + } +} diff --git a/quarkus-opentelemetry-exporter-gcp/deployment/src/main/java/io/quarkiverse/opentelemetry/exporter/gcp/deployment/GcpExporterProcessor.java b/quarkus-opentelemetry-exporter-gcp/deployment/src/main/java/io/quarkiverse/opentelemetry/exporter/gcp/deployment/GcpExporterProcessor.java index d4f9b8d..f42a72e 100644 --- a/quarkus-opentelemetry-exporter-gcp/deployment/src/main/java/io/quarkiverse/opentelemetry/exporter/gcp/deployment/GcpExporterProcessor.java +++ b/quarkus-opentelemetry-exporter-gcp/deployment/src/main/java/io/quarkiverse/opentelemetry/exporter/gcp/deployment/GcpExporterProcessor.java @@ -23,6 +23,7 @@ import io.quarkus.deployment.annotations.BuildSteps; import io.quarkus.deployment.annotations.Record; import io.quarkus.deployment.builditem.LaunchModeBuildItem; +import io.quarkus.deployment.builditem.nativeimage.NativeImageConfigBuildItem; import io.quarkus.opentelemetry.deployment.exporter.otlp.ExternalOtelExporterBuildItem; @BuildSteps(onlyIf = GcpExporterProcessor.GcpExporterEnabled.class) @@ -41,6 +42,13 @@ void registerExternalExporter(BuildProducer build buildProducer.produce(new ExternalOtelExporterBuildItem("gcp")); } + @BuildStep + NativeImageConfigBuildItem nativeImageConfiguration() { + NativeImageConfigBuildItem.Builder builder = NativeImageConfigBuildItem.builder() + .addRuntimeReinitializedClass("com.google.protobuf.UnsafeUtil"); + return builder.build(); + } + @BuildStep @Record(RUNTIME_INIT) SyntheticBeanBuildItem installBatchSpanProcessorForGcp(GcpRecorder recorder, diff --git a/quarkus-opentelemetry-exporter-gcp/integration-tests/src/main/resources/application.properties b/quarkus-opentelemetry-exporter-gcp/integration-tests/src/main/resources/application.properties index 14ef0b9..84ce6d9 100644 --- a/quarkus-opentelemetry-exporter-gcp/integration-tests/src/main/resources/application.properties +++ b/quarkus-opentelemetry-exporter-gcp/integration-tests/src/main/resources/application.properties @@ -2,8 +2,6 @@ quarkus.application.name=opentelemetry-exporter-gcp-integration-test quarkus.application.version=999-SNAPSHOT -quarkus.opentelemetry.tracer.exporter.otlp.enabled=false - simple/mp-rest/url=${test.url} quarkus.generate-code.grpc.scan-for-imports=all \ No newline at end of file diff --git a/quarkus-opentelemetry-exporter-gcp/runtime/pom.xml b/quarkus-opentelemetry-exporter-gcp/runtime/pom.xml index 9bb8eb5..9b4d664 100644 --- a/quarkus-opentelemetry-exporter-gcp/runtime/pom.xml +++ b/quarkus-opentelemetry-exporter-gcp/runtime/pom.xml @@ -33,10 +33,21 @@ io.quarkus quarkus-grpc-common + + com.google.api + gax-grpc + ${gax-grpc.version} + + + com.google.api + gax + ${gax-grpc.version} + com.google.cloud.opentelemetry exporter-trace ${gcp-opentelemetry.version} + compile com.google.api @@ -48,16 +59,6 @@ - - com.google.api - gax-grpc - ${gax-grpc.version} - - - com.google.api - gax - ${gax-grpc.version} - io.opentelemetry opentelemetry-exporter-otlp-common diff --git a/quarkus-opentelemetry-exporter-gcp/runtime/src/main/java/io/quarkiverse/opentelemetry/exporter/gcp/runtime/graal/Substitutions.java b/quarkus-opentelemetry-exporter-gcp/runtime/src/main/java/io/quarkiverse/opentelemetry/exporter/gcp/runtime/graal/Substitutions.java index 8fba930..82ad8ed 100644 --- a/quarkus-opentelemetry-exporter-gcp/runtime/src/main/java/io/quarkiverse/opentelemetry/exporter/gcp/runtime/graal/Substitutions.java +++ b/quarkus-opentelemetry-exporter-gcp/runtime/src/main/java/io/quarkiverse/opentelemetry/exporter/gcp/runtime/graal/Substitutions.java @@ -1,6 +1,7 @@ package io.quarkiverse.opentelemetry.exporter.gcp.runtime.graal; import java.io.IOException; +import java.lang.reflect.Field; import java.security.GeneralSecurityException; import java.util.concurrent.Executor; import java.util.concurrent.TimeUnit; @@ -28,6 +29,8 @@ import io.grpc.MethodDescriptor; import io.grpc.netty.shaded.io.netty.util.internal.logging.InternalLogLevel; import io.grpc.netty.shaded.io.netty.util.internal.logging.InternalLogger; +import io.grpc.netty.shaded.io.netty.util.internal.logging.InternalLoggerFactory; +import sun.misc.Unsafe; /** * Cut out unsupported and optional features that are only present in grpc-alts. @@ -154,9 +157,33 @@ public ClientCall interceptCall(MethodDescriptor clazz) { return new InternalLogger() { diff --git a/quarkus-opentelemetry-exporter-jaeger/deployment/src/main/java/io/quarkiverse/opentelemetry/exporter/jaeger/deployment/JaegerExporterProcessor.java b/quarkus-opentelemetry-exporter-jaeger/deployment/src/main/java/io/quarkiverse/opentelemetry/exporter/jaeger/deployment/JaegerExporterProcessor.java index 1b71117..d34419f 100644 --- a/quarkus-opentelemetry-exporter-jaeger/deployment/src/main/java/io/quarkiverse/opentelemetry/exporter/jaeger/deployment/JaegerExporterProcessor.java +++ b/quarkus-opentelemetry-exporter-jaeger/deployment/src/main/java/io/quarkiverse/opentelemetry/exporter/jaeger/deployment/JaegerExporterProcessor.java @@ -10,6 +10,7 @@ import org.jboss.jandex.ParameterizedType; import org.jboss.jandex.Type; +import io.opentelemetry.exporter.internal.grpc.GrpcSenderProvider; import io.opentelemetry.sdk.trace.SpanProcessor; import io.opentelemetry.sdk.trace.export.SpanExporter; import io.quarkiverse.opentelemetry.exporter.common.runtime.LateBoundSpanProcessor; @@ -22,6 +23,8 @@ import io.quarkus.deployment.annotations.ExecutionTime; import io.quarkus.deployment.annotations.Record; import io.quarkus.deployment.builditem.LaunchModeBuildItem; +import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem; +import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem; import io.quarkus.opentelemetry.deployment.exporter.otlp.ExternalOtelExporterBuildItem; @BuildSteps(onlyIf = JaegerExporterProcessor.JaegerExporterEnabled.class) @@ -35,6 +38,13 @@ public boolean getAsBoolean() { } } + @BuildStep + void retainBeans(BuildProducer services) { + + services.produce(new ServiceProviderBuildItem(GrpcSenderProvider.class.getName(), + "io.opentelemetry.exporter.sender.okhttp.internal.OkHttpGrpcSenderProvider")); + } + @BuildStep void registerExternalExporter(BuildProducer buildProducer) { buildProducer.produce(new ExternalOtelExporterBuildItem("jaeger"));