Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 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 @@ -15,6 +15,7 @@
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
import io.opentelemetry.javaagent.instrumentation.opentelemetryapi.context.AgentContextStorage;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.asm.Advice.AssignReturned;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;

Expand All @@ -41,9 +42,10 @@ public void transform(TypeTransformer transformer) {
@SuppressWarnings("unused")
public static class WrapRootAdvice {

@AssignReturned.ToReturned
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
public static void methodExit(@Advice.Return(readOnly = false) Context root) {
root = AgentContextStorage.wrapRootContext(root);
public static Context methodExit(@Advice.Return Context root) {
return AgentContextStorage.wrapRootContext(root);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import java.util.List;
import java.util.function.Function;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.asm.Advice.AssignReturned;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;

Expand All @@ -41,13 +42,16 @@ public void transform(TypeTransformer transformer) {
@SuppressWarnings("unused")
public static class AddWrapperAdvice {

@AssignReturned.ToReturned
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
public static void methodExit(
@Advice.Return(readOnly = false)
List<Function<? super ContextStorage, ? extends ContextStorage>> wrappers) {
public static List<Function<? super ContextStorage, ? extends ContextStorage>> methodExit(
@Advice.Return
List<Function<? super ContextStorage, ? extends ContextStorage>> originalWrappers) {
List<Function<? super ContextStorage, ? extends ContextStorage>> wrappers = originalWrappers;
wrappers = new ArrayList<>(wrappers);
// AgentContextStorage wrapper doesn't delegate, so needs to be the innermost wrapper
wrappers.add(0, AgentContextStorage.wrap());
return wrappers;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
import io.opentelemetry.javaagent.instrumentation.opentelemetryapi.context.AgentContextStorage;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.asm.Advice.AssignReturned;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;

Expand Down Expand Up @@ -44,12 +45,11 @@ public static boolean methodEnter() {
return true;
}

@AssignReturned.ToReturned
@Advice.OnMethodExit(suppress = Throwable.class)
public static void methodExit(
@Advice.Argument(0) Context context, @Advice.Return(readOnly = false) boolean result) {
result =
InstrumentationUtil.shouldSuppressInstrumentation(
AgentContextStorage.getAgentContext(context));
public static boolean methodExit(@Advice.Argument(0) Context context) {
return InstrumentationUtil.shouldSuppressInstrumentation(
AgentContextStorage.getAgentContext(context));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,9 @@ public List<String> agentPackagesToHide() {
// when they haven't been injected
return Collections.singletonList("io.opentelemetry.javaagent.instrumentation.opentelemetryapi");
}

@Override
public boolean isIndyReady() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
import java.util.logging.Logger;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.asm.Advice.AssignReturned;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;

Expand Down Expand Up @@ -58,11 +59,10 @@ public static Object onEnter() {
return null;
}

@AssignReturned.ToReturned
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class)
public static void methodExit(
@Advice.Return(readOnly = false)
application.io.opentelemetry.api.OpenTelemetry openTelemetry) {
openTelemetry = ApplicationOpenTelemetry.INSTANCE;
public static application.io.opentelemetry.api.OpenTelemetry methodExit() {
return ApplicationOpenTelemetry.INSTANCE;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
import io.opentelemetry.javaagent.instrumentation.opentelemetryapi.trace.Bridging;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.asm.Advice.AssignReturned;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;

Expand All @@ -40,13 +41,11 @@ public static boolean methodEnter() {
return false;
}

@AssignReturned.ToReturned
@Advice.OnMethodExit
public static void methodExit(
@Advice.Argument(0) SpanContext applicationSpanContext,
@Advice.Return(readOnly = false) Span applicationSpan) {
applicationSpan =
Bridging.toApplication(
io.opentelemetry.api.trace.Span.wrap(Bridging.toAgent(applicationSpanContext)));
public static Span methodExit(@Advice.Argument(0) SpanContext applicationSpanContext) {
return Bridging.toApplication(
io.opentelemetry.api.trace.Span.wrap(Bridging.toAgent(applicationSpanContext)));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer;
import io.opentelemetry.javaagent.instrumentation.opentelemetryapi.context.AgentContextStorage;
import net.bytebuddy.asm.Advice;
import net.bytebuddy.asm.Advice.AssignReturned;
import net.bytebuddy.description.type.TypeDescription;
import net.bytebuddy.matcher.ElementMatcher;

Expand All @@ -31,12 +32,11 @@ public void transform(TypeTransformer transformer) {
@SuppressWarnings("unused")
public static class TestAdvice {

@AssignReturned.ToReturned
@Advice.OnMethodExit(suppress = Throwable.class)
public static void onExit(
@Advice.Argument(0) Context context, @Advice.Return(readOnly = false) boolean result) {
result =
InstrumentationUtil.shouldSuppressInstrumentation(
AgentContextStorage.getAgentContext(context));
public static boolean onExit(@Advice.Argument(0) Context context) {
return InstrumentationUtil.shouldSuppressInstrumentation(
AgentContextStorage.getAgentContext(context));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,9 @@ public String getModuleGroup() {
public List<TypeInstrumentation> typeInstrumentations() {
return singletonList(new TestInstrumentation());
}

@Override
public boolean isIndyReady() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,9 @@ public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() {
public String getModuleGroup() {
return "opentelemetry-api-bridge";
}

@Override
public boolean isIndyReady() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,9 @@ public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() {
public String getModuleGroup() {
return "opentelemetry-api-bridge";
}

@Override
public boolean isIndyReady() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,9 @@ public List<TypeInstrumentation> typeInstrumentations() {
public String getModuleGroup() {
return "opentelemetry-api-bridge";
}

@Override
public boolean isIndyReady() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,4 +39,9 @@ public List<TypeInstrumentation> typeInstrumentations() {
public String getModuleGroup() {
return "opentelemetry-api-bridge";
}

@Override
public boolean isIndyReady() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,9 @@ public List<TypeInstrumentation> typeInstrumentations() {
public String getModuleGroup() {
return "opentelemetry-api-bridge";
}

@Override
public boolean isIndyReady() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,9 @@ public List<TypeInstrumentation> typeInstrumentations() {
public String getModuleGroup() {
return "opentelemetry-api-bridge";
}

@Override
public boolean isIndyReady() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,9 @@ public List<TypeInstrumentation> typeInstrumentations() {
public String getModuleGroup() {
return "opentelemetry-api-bridge";
}

@Override
public boolean isIndyReady() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,9 @@ public List<TypeInstrumentation> typeInstrumentations() {
public String getModuleGroup() {
return "opentelemetry-api-bridge";
}

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