Class ExecutorAdviceHelper
java.lang.Object
io.opentelemetry.javaagent.bootstrap.executors.ExecutorAdviceHelper
Advice helper methods for concurrent executor (e.g.
ExecutorService) instrumentations.-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> PropagatedContextattachContextToTask(io.opentelemetry.context.Context context, io.opentelemetry.instrumentation.api.util.VirtualField<T, PropagatedContext> virtualField, T task) Associatecontextwith passedtaskusingvirtualField.static <T> voidcleanPropagatedContext(io.opentelemetry.instrumentation.api.util.VirtualField<T, PropagatedContext> virtualField, T task) Clean context attached to the given task.static voidcleanUpAfterSubmit(PropagatedContext propagatedContext, Throwable throwable) Clean uppropagatedContextin case of any submission errors.static booleanshouldPropagateContext(io.opentelemetry.context.Context context, Object task) Check ifcontextshould be propagated to the passedtask.
-
Method Details
-
shouldPropagateContext
public static boolean shouldPropagateContext(io.opentelemetry.context.Context context, @Nullable Object task) Check ifcontextshould be propagated to the passedtask. This method must be called before eachattachContextToTask(Context, VirtualField, Object)call to ensure that unwanted tasks are not instrumented. -
attachContextToTask
public static <T> PropagatedContext attachContextToTask(io.opentelemetry.context.Context context, io.opentelemetry.instrumentation.api.util.VirtualField<T, PropagatedContext> virtualField, T task) Associatecontextwith passedtaskusingvirtualField. Once the context is attached,TaskAdviceHelpercan be used to make that context current duringtaskexecution. -
cleanUpAfterSubmit
public static void cleanUpAfterSubmit(@Nullable PropagatedContext propagatedContext, @Nullable Throwable throwable) Clean uppropagatedContextin case of any submission errors. Call this method after the submission method has exited. -
cleanPropagatedContext
public static <T> void cleanPropagatedContext(io.opentelemetry.instrumentation.api.util.VirtualField<T, PropagatedContext> virtualField, T task) Clean context attached to the given task.
-