Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Trino JDBC] NoClassDefFoundError io/opentelemetry/semconv/SemanticAttributes #21689

Open
gaeljw opened this issue Apr 24, 2024 · 4 comments
Open
Labels
jdbc Relates to Trino JDBC driver

Comments

@gaeljw
Copy link

gaeljw commented Apr 24, 2024

Preamble

I'm logging this as an issue to help other people facing it to find the explanation and solution but I believe the root cause is close to the one described in #21104.

Issue

Getting java.lang.NoClassDefFoundError: io/opentelemetry/semconv/SemanticAttributes when:

  • using trino-jdbc 445
  • having io.opentelemetry:opentelemetry-api (and optionally others OTEL dependencies) as a dependency in the classpath
  • BUT NOT having io.opentelemetry.semconv:opentelemetry-semconv as a dependency in the classpath

This is a regular setup when using the OpenTelemetry java agent: the classpath only contains the opentelemetry-api but all the SDK is in a separate classpath for the java agent.

Complete stacktrace:

[error] Caused by: java.lang.NoClassDefFoundError: io/opentelemetry/semconv/SemanticAttributes
[error]     at io.trino.jdbc.$internal.opentelemetry.instrumentation.api.semconv.http.HttpCommonAttributesExtractor.onStart(HttpCommonAttributesExtractor.java:61)
[error]     at io.trino.jdbc.$internal.opentelemetry.instrumentation.api.semconv.http.HttpClientAttributesExtractor.onStart(HttpClientAttributesExtractor.java:71)
[error]     at io.trino.jdbc.$internal.opentelemetry.instrumentation.api.instrumenter.Instrumenter.doStart(Instrumenter.java:179)
[error]     at io.trino.jdbc.$internal.opentelemetry.instrumentation.api.instrumenter.Instrumenter.startAndEnd(Instrumenter.java:158)
[error]     at io.trino.jdbc.$internal.opentelemetry.instrumentation.api.instrumenter.Instrumenter$1.startAndEnd(Instrumenter.java:272)
[error]     at io.trino.jdbc.$internal.opentelemetry.instrumentation.api.internal.InstrumenterUtil.startAndEnd(InstrumenterUtil.java:44)
[error]     at io.trino.jdbc.$internal.opentelemetry.instrumentation.okhttp.v3_0.internal.ConnectionErrorSpanInterceptor.intercept(ConnectionErrorSpanInterceptor.java:47)
[error]     at io.trino.jdbc.$internal.okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
[error]     at io.trino.jdbc.$internal.opentelemetry.instrumentation.okhttp.v3_0.ContextInterceptor.intercept(ContextInterceptor.java:28)
[error]     at io.trino.jdbc.$internal.okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
[error]     at io.trino.jdbc.$internal.okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
[error]     at io.trino.jdbc.$internal.okhttp3.internal.connection.RealCall.execute(RealCall.kt:154)
[error]     at io.trino.jdbc.$internal.opentelemetry.instrumentation.okhttp.v3_0.TracingCallFactory$TracingCall.execute(TracingCallFactory.java:100)
[error]     at io.trino.jdbc.$internal.client.JsonResponse.execute(JsonResponse.java:113)
[error]     at io.trino.jdbc.$internal.client.StatementClientV1.executeRequest(StatementClientV1.java:401)
[error]     at io.trino.jdbc.$internal.client.StatementClientV1.(StatementClientV1.java:132)
[error]     at io.trino.jdbc.$internal.client.StatementClientFactory.newStatementClient(StatementClientFactory.java:28)
[error]     at io.trino.jdbc.TrinoConnection.startQuery(TrinoConnection.java:771)
[error]     at io.trino.jdbc.TrinoStatement.internalExecute(TrinoStatement.java:252)
[error]     at io.trino.jdbc.TrinoStatement.execute(TrinoStatement.java:240)

Fix

Force to have a (recent) io.opentelemetry.semconv:opentelemetry-semconv dependency in the classpath.

@gaeljw gaeljw closed this as completed Apr 24, 2024
@gaeljw gaeljw added the jdbc Relates to Trino JDBC driver label Apr 24, 2024
@gaeljw gaeljw reopened this Apr 25, 2024
@gaeljw
Copy link
Author

gaeljw commented Apr 25, 2024

I reopen because it's actually a different issue than #21104: having trino-jdbc + opentelemetry-api in the classpath and using the opentelemetry java agent leads to this issue. It's not only a dependency version conflict. It's a missing needed dependency (not pulled via Maven POM declarations).

@kaushik-revefi
Copy link

Hitting the same issue

@lukaseder
Copy link

lukaseder commented Aug 15, 2024

I'm running into this as well. It appears to me that shading isn't done properly for various opentelemetry dependencies?

                <relocation>
                  <pattern>io.opentelemetry.extension</pattern>
                  <shadedPattern>${shadeBase}.opentelemetry.extension</shadedPattern>
                </relocation>
                <relocation>
                  <pattern>io.opentelemetry.instrumentation</pattern>
                  <shadedPattern>${shadeBase}.opentelemetry.instrumentation</shadedPattern>
                </relocation>
                <relocation>
                  <pattern>io.opentelemetry.api.incubator</pattern>
                  <shadedPattern>${shadeBase}.opentelemetry.api.incubator</shadedPattern>
                </relocation>

@wendigo
Copy link
Contributor

wendigo commented Sep 17, 2024

OTEL shouldn't be shaded at all. I'll merge soon a change that excludes OTEL entirely so it will be provided only externally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
jdbc Relates to Trino JDBC driver
Development

No branches or pull requests

4 participants