Fix VerifyError in examples/distro servlet instrumentation
MODIFY
examples/distro/instrumentation/build.gradle
examples/distro/instrumentation/build.gradle
@@ -11,6 +11,7 @@ subprojects {
dependencies {
compileOnly("io.opentelemetry:opentelemetry-sdk:${versions.opentelemetry}")
+ compileOnly("io.opentelemetry.javaagent:opentelemetry-javaagent-api:${versions.opentelemetryJavaagent}")
compileOnly("io.opentelemetry.javaagent:opentelemetry-javaagent-tooling:${versions.opentelemetryJavaagent}")
compileOnly deps.bytebuddy

MODIFY
examples/distro/instrumentation/servlet-3/src/main/java/com/example/javaagent/instrumentation/DemoServlet3InstrumentationModule.java
examples/distro/instrumentation/servlet-3/src/main/java/com/example/javaagent/instrumentation/DemoServlet3InstrumentationModule.java
@@ -9,14 +9,14 @@ import static net.bytebuddy.matcher.ElementMatchers.named;
import static net.bytebuddy.matcher.ElementMatchers.takesArgument;
import com.google.auto.service.AutoService;
-import io.opentelemetry.api.trace.Span;
+import io.opentelemetry.javaagent.instrumentation.api.Java8BytecodeBridge;
import io.opentelemetry.javaagent.tooling.InstrumentationModule;
import io.opentelemetry.javaagent.tooling.TypeInstrumentation;
+import io.opentelemetry.javaagent.tooling.bytebuddy.matcher.ClassLoaderMatcher;
import java.util.List;
import java.util.Map;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletResponse;
-import io.opentelemetry.javaagent.tooling.bytebuddy.matcher.ClassLoaderMatcher;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.method.MethodDescription;
import net.bytebuddy.description.type.TypeDescription;
@@ -79,7 +79,8 @@ public final class DemoServlet3InstrumentationModule extends InstrumentationModu
HttpServletResponse httpServletResponse = (HttpServletResponse) response;
if (!httpServletResponse.containsHeader("X-server-id")) {
httpServletResponse
- .addHeader("X-server-id", Span.current().getSpanContext().getTraceId());
+ .addHeader("X-server-id",
+ Java8BytecodeBridge.currentSpan().getSpanContext().getTraceId());
}
}

Fix VerifyError in examples/distro servlet instrumentation (#2319)