From 147601cf97686f70f32461db16636f990deba2b6 Mon Sep 17 00:00:00 2001 From: Georgios Andrianakis Date: Thu, 20 Jul 2023 12:17:42 +0300 Subject: [PATCH] Make the creation of the Tracer bean lazy This is needed to avoid a timing issue that can lead to java.lang.IllegalStateException: GlobalOpenTelemetry.set has already been called --- .../opentelemetry/runtime/tracing/cdi/TracerProducer.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/cdi/TracerProducer.java b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/cdi/TracerProducer.java index fed847a2ef87d..b17c611cfd6e5 100644 --- a/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/cdi/TracerProducer.java +++ b/extensions/opentelemetry/runtime/src/main/java/io/quarkus/opentelemetry/runtime/tracing/cdi/TracerProducer.java @@ -2,6 +2,7 @@ import static io.quarkus.opentelemetry.runtime.config.build.OTelBuildConfig.INSTRUMENTATION_NAME; +import jakarta.enterprise.context.ApplicationScoped; import jakarta.enterprise.context.RequestScoped; import jakarta.enterprise.inject.Produces; import jakarta.inject.Singleton; @@ -22,7 +23,7 @@ public DelayedAttributes getDelayedAttributes() { } @Produces - @Singleton + @ApplicationScoped @DefaultBean public Tracer getTracer() { return GlobalOpenTelemetry.getTracer(INSTRUMENTATION_NAME);