OpenTelemetry JDBC instrumentation shouldn't initialize OpenTelemetry at build time #8080
Labels
contribution welcome
Request makes sense, maintainers probably won't have time, contribution would be welcome
enhancement
New feature or request
Is your feature request related to a problem? Please describe.
Quarkus is using
OpenTelemetryDatasource
in the Quarkus Agroal extension, which allows users to trace JDBC queries. As we create OpenTelemetry at runtime (in order to support OpenTelemetry SDK Autoconfigure), we can't have classes statically accessing OpenTelemetry viaGlobalOpenTelemetry#get
at build time, however that's exactly whatJdbcSingletons
does:opentelemetry-java-instrumentation/instrumentation/jdbc/library/src/main/java/io/opentelemetry/instrumentation/jdbc/internal/JdbcSingletons.java
Line 19 in d57405f
As
JdbcSingletons
is only used byOpenTelemetryDriver
we have to remove both in order to adaptopentelemetry-jdbc
for native mode. This shouldn't be necessary as we shouldn't need knowledge ofjdbc.internal
package, for it is an API that is unstable and can change at any time.Describe the solution you'd like
As the driver is singleton and initialized statically, we need lazy
io.opentelemetry.instrumentation.jdbc.internal.JdbcSingletons#STATEMENT_INSTRUMENTER
to be lazily initialized. Either we can usevolatile
orsynchronized
for the initialization needs to be thread safe.Describe alternatives you've considered
I don't see other options.
Additional context
I'm happy to take care of this when I find a little time, the problem is not time sensitive.
The text was updated successfully, but these errors were encountered: