Add context propagation debug info in ContextPropagatingRunnable (#9339)
This commit is contained in:
parent
b2fcb76a66
commit
57e957d7a0
|
@ -56,6 +56,15 @@ public final class ContextPropagationDebug {
|
|||
return THREAD_PROPAGATION_DEBUGGER;
|
||||
}
|
||||
|
||||
public static Context addDebugInfo(Context context, Object carrier) {
|
||||
if (ContextPropagationDebug.isThreadPropagationDebuggerEnabled()) {
|
||||
context =
|
||||
ContextPropagationDebug.appendLocations(
|
||||
context, new Exception().getStackTrace(), carrier);
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
public static Context appendLocations(
|
||||
Context context, StackTraceElement[] locations, Object carrier) {
|
||||
ContextPropagationDebug propagationDebug = ContextPropagationDebug.getPropagations(context);
|
||||
|
|
|
@ -7,6 +7,7 @@ package io.opentelemetry.javaagent.bootstrap.executors;
|
|||
|
||||
import io.opentelemetry.context.Context;
|
||||
import io.opentelemetry.context.Scope;
|
||||
import io.opentelemetry.instrumentation.api.internal.ContextPropagationDebug;
|
||||
|
||||
public final class ContextPropagatingRunnable implements Runnable {
|
||||
|
||||
|
@ -27,7 +28,7 @@ public final class ContextPropagatingRunnable implements Runnable {
|
|||
|
||||
private ContextPropagatingRunnable(Runnable delegate, Context context) {
|
||||
this.delegate = delegate;
|
||||
this.context = context;
|
||||
this.context = ContextPropagationDebug.addDebugInfo(context, delegate);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -62,10 +62,7 @@ public final class ExecutorAdviceHelper {
|
|||
}
|
||||
}
|
||||
|
||||
if (ContextPropagationDebug.isThreadPropagationDebuggerEnabled()) {
|
||||
context =
|
||||
ContextPropagationDebug.appendLocations(context, new Exception().getStackTrace(), task);
|
||||
}
|
||||
context = ContextPropagationDebug.addDebugInfo(context, task);
|
||||
propagatedContext.setContext(context);
|
||||
return propagatedContext;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue