Skip to content

Commit ed27f25

Browse files
SylvainJugemznet
authored andcommitted
make grizzly indy-ready (open-telemetry#14860)
1 parent c2320ed commit ed27f25

File tree

3 files changed

+18
-15
lines changed

3 files changed

+18
-15
lines changed

instrumentation/grizzly-2.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/grizzly/FilterChainContextInstrumentation.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,15 +53,15 @@ public static void onExit(@Advice.Enter Scope scope) {
5353
public static class WriteAdvice {
5454

5555
@Advice.OnMethodEnter(suppress = Throwable.class)
56-
public static void onEnter(@Advice.Local("otelCallDepth") CallDepth callDepth) {
57-
callDepth = CallDepth.forClass(FilterChainContext.class);
56+
public static CallDepth onEnter() {
57+
CallDepth callDepth = CallDepth.forClass(FilterChainContext.class);
5858
callDepth.getAndIncrement();
59+
return callDepth;
5960
}
6061

6162
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
6263
public static void onExit(
63-
@Advice.This FilterChainContext filterChainContext,
64-
@Advice.Local("otelCallDepth") CallDepth callDepth) {
64+
@Advice.This FilterChainContext filterChainContext, @Advice.Enter CallDepth callDepth) {
6565
// When exiting the outermost call to write clear context & request from filter chain context.
6666
// Write makes a copy of the current filter chain context and passes it on. In older versions
6767
// new and old filter chain context share the attributes, but in newer versions the attributes

instrumentation/grizzly-2.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/grizzly/FilterInstrumentation.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge;
1818
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
1919
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
20+
import javax.annotation.Nullable;
2021
import net.bytebuddy.asm.Advice;
2122
import net.bytebuddy.description.type.TypeDescription;
2223
import net.bytebuddy.matcher.ElementMatcher;
@@ -52,22 +53,17 @@ public void transform(TypeTransformer transformer) {
5253
public static class HandleReadAdvice {
5354

5455
@Advice.OnMethodEnter(suppress = Throwable.class)
55-
public static void onEnter(
56-
@Advice.This BaseFilter it,
57-
@Advice.Argument(0) FilterChainContext ctx,
58-
@Advice.Local("otelScope") Scope scope) {
56+
public static Scope onEnter(
57+
@Advice.This BaseFilter it, @Advice.Argument(0) FilterChainContext ctx) {
5958
if (Java8BytecodeBridge.currentSpan().getSpanContext().isValid()) {
60-
return;
59+
return null;
6160
}
62-
6361
Context context = GrizzlyStateStorage.getContext(ctx);
64-
if (context != null) {
65-
scope = context.makeCurrent();
66-
}
62+
return context != null ? context.makeCurrent() : null;
6763
}
6864

6965
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
70-
public static void onExit(@Advice.This BaseFilter it, @Advice.Local("otelScope") Scope scope) {
66+
public static void onExit(@Advice.This BaseFilter it, @Advice.Enter @Nullable Scope scope) {
7167
if (scope != null) {
7268
scope.close();
7369
}

instrumentation/grizzly-2.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/grizzly/GrizzlyInstrumentationModule.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@
1111
import com.google.auto.service.AutoService;
1212
import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule;
1313
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
14+
import io.opentelemetry.javaagent.extension.instrumentation.internal.ExperimentalInstrumentationModule;
1415
import java.util.List;
1516
import net.bytebuddy.matcher.ElementMatcher;
1617

1718
@AutoService(InstrumentationModule.class)
18-
public class GrizzlyInstrumentationModule extends InstrumentationModule {
19+
public class GrizzlyInstrumentationModule extends InstrumentationModule
20+
implements ExperimentalInstrumentationModule {
1921
public GrizzlyInstrumentationModule() {
2022
super("grizzly", "grizzly-2.3");
2123
}
@@ -36,4 +38,9 @@ public List<TypeInstrumentation> typeInstrumentations() {
3638
new HttpHandlerInstrumentation(),
3739
new FilterChainContextInstrumentation());
3840
}
41+
42+
@Override
43+
public boolean isIndyReady() {
44+
return true;
45+
}
3946
}

0 commit comments

Comments
 (0)