Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,15 @@ public static void onExit(@Advice.Enter Scope scope) {
public static class WriteAdvice {

@Advice.OnMethodEnter(suppress = Throwable.class)
public static void onEnter(@Advice.Local("otelCallDepth") CallDepth callDepth) {
callDepth = CallDepth.forClass(FilterChainContext.class);
public static CallDepth onEnter() {
CallDepth callDepth = CallDepth.forClass(FilterChainContext.class);
callDepth.getAndIncrement();
return callDepth;
}

@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
public static void onExit(
@Advice.This FilterChainContext filterChainContext,
@Advice.Local("otelCallDepth") CallDepth callDepth) {
@Advice.This FilterChainContext filterChainContext, @Advice.Enter CallDepth callDepth) {
// When exiting the outermost call to write clear context & request from filter chain context.
// Write makes a copy of the current filter chain context and passes it on. In older versions
// new and old filter chain context share the attributes, but in newer versions the attributes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import io.opentelemetry.javaagent.bootstrap.Java8BytecodeBridge;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
import javax.annotation.Nullable;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;
Expand Down Expand Up @@ -52,22 +53,17 @@ public void transform(TypeTransformer transformer) {
public static class HandleReadAdvice {

@Advice.OnMethodEnter(suppress = Throwable.class)
public static void onEnter(
@Advice.This BaseFilter it,
@Advice.Argument(0) FilterChainContext ctx,
@Advice.Local("otelScope") Scope scope) {
public static Scope onEnter(
@Advice.This BaseFilter it, @Advice.Argument(0) FilterChainContext ctx) {
if (Java8BytecodeBridge.currentSpan().getSpanContext().isValid()) {
return;
return null;
}

Context context = GrizzlyStateStorage.getContext(ctx);
if (context != null) {
scope = context.makeCurrent();
}
return context != null ? context.makeCurrent() : null;
}

@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
public static void onExit(@Advice.This BaseFilter it, @Advice.Local("otelScope") Scope scope) {
public static void onExit(@Advice.This BaseFilter it, @Advice.Enter @Nullable Scope scope) {
if (scope != null) {
scope.close();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
import com.google.auto.service.AutoService;
import io.opentelemetry.javaagent.extension.instrumentation.InstrumentationModule;
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation;
import io.opentelemetry.javaagent.extension.instrumentation.internal.ExperimentalInstrumentationModule;
import java.util.List;
import net.bytebuddy.matcher.ElementMatcher;

@AutoService(InstrumentationModule.class)
public class GrizzlyInstrumentationModule extends InstrumentationModule {
public class GrizzlyInstrumentationModule extends InstrumentationModule
implements ExperimentalInstrumentationModule {
public GrizzlyInstrumentationModule() {
super("grizzly", "grizzly-2.3");
}
Expand All @@ -36,4 +38,9 @@ public List<TypeInstrumentation> typeInstrumentations() {
new HttpHandlerInstrumentation(),
new FilterChainContextInstrumentation());
}

@Override
public boolean isIndyReady() {
return true;
}
}