Skip to content

Commit

Permalink
Make the creation of the Tracer bean lazy
Browse files Browse the repository at this point in the history
This is needed to avoid a timing issue
that can lead to
java.lang.IllegalStateException: GlobalOpenTelemetry.set has already been called
  • Loading branch information
geoand committed Jul 20, 2023
1 parent e23f434 commit 147601c
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -22,7 +23,7 @@ public DelayedAttributes getDelayedAttributes() {
}

@Produces
@Singleton
@ApplicationScoped
@DefaultBean
public Tracer getTracer() {
return GlobalOpenTelemetry.getTracer(INSTRUMENTATION_NAME);
Expand Down

0 comments on commit 147601c

Please sign in to comment.