You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running an application with the Java agent and support for OpenTelemetry enabled (dd.trace.otel.enabled=true) and calling addEvent or recordException on an io.opentelemetry.api.trace.Span (support for this added in #7408), in certain cases it fails with the following error:
Exception in thread "main" java.lang.NoClassDefFoundError: datadog/opentelemetry/shim/trace/OtelSpanEvent
at datadog.opentelemetry.shim.trace.OtelSpan.addEvent(OtelSpan.java:85)
at io.opentelemetry.api.trace.Span.addEvent(Span.java:198)
at org.example.App.thisThrows(App.java:18)
at org.example.App.main(App.java:11)
Caused by: java.lang.ClassNotFoundException: datadog.opentelemetry.shim.trace.OtelSpanEvent
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
... 4 more
Tested using the following versions:
Java:
$ java -version
openjdk version "17.0.8" 2023-07-18 LTS
OpenJDK Runtime Environment Zulu17.44+15-CA (build 17.0.8+7-LTS)
OpenJDK 64-Bit Server VM Zulu17.44+15-CA (build 17.0.8+7-LTS, mixed mode, sharing)
dd-trace-java: 1.43.0
Example
A minimal example that reproduces the error can be found below.
In the example, I use @WithSpan because it's an easy way to make the Java agent create a span (so that Span.current() doesn't return a no-op span), however we're seeing the same problem in other scenarios as well.
It should be noted that if thisThrows is called after thisWorks, no exception is thrown.
The issue is that for the @WithSpan example only OpenTelemetryContextStorageInstrumentation is getting applied - and that doesn't currently inject OtelSpanEvent, which was an oversight.
As a workaround you can add this to your main application class:
static {
GlobalOpenTelemetry.get();
}
This will trigger injection of OtelSpanEvent via the main OpenTelemetryInstrumentation
Description
When running an application with the Java agent and support for OpenTelemetry enabled (
dd.trace.otel.enabled=true
) and callingaddEvent
orrecordException
on anio.opentelemetry.api.trace.Span
(support for this added in #7408), in certain cases it fails with the following error:Tested using the following versions:
Example
A minimal example that reproduces the error can be found below.
In the example, I use
@WithSpan
because it's an easy way to make the Java agent create a span (so thatSpan.current()
doesn't return a no-op span), however we're seeing the same problem in other scenarios as well.It should be noted that if
thisThrows
is called afterthisWorks
, no exception is thrown.App.java
build.gradle
The text was updated successfully, but these errors were encountered: