Class ExecutorAdviceHelper

java.lang.Object
io.opentelemetry.javaagent.bootstrap.executors.ExecutorAdviceHelper

public final class ExecutorAdviceHelper extends Object
Advice helper methods for concurrent executor (e.g. ExecutorService) instrumentations.
  • Method Details

    • shouldPropagateContext

      public static boolean shouldPropagateContext(io.opentelemetry.context.Context context, @Nullable Object task)
      Check if context should be propagated to the passed task. This method must be called before each attachContextToTask(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)
      Associate context with passed task using virtualField. Once the context is attached, TaskAdviceHelper can be used to make that context current during task execution.
    • cleanUpAfterSubmit

      public static void cleanUpAfterSubmit(@Nullable PropagatedContext propagatedContext, @Nullable Throwable throwable)
      Clean up propagatedContext in 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.