Package com.amazonaws.xray.contexts
Class SegmentContextExecutors
- java.lang.Object
-
- com.amazonaws.xray.contexts.SegmentContextExecutors
-
public final class SegmentContextExecutors extends java.lang.ObjectExecutors that will mount a segment before running a command. When switching threads, for example when instrumenting an asynchronous application, it is recommended to use one of theseExecutors to make sure callbacks have the trace segment available.DynamoDbAsyncClient client = DynamoDbAsyncClient.create(); client.getItem(request).thenComposeAsync(response -> { // If we did not provide the segment context executor, this request would not be traced correctly. return client.getItem(request2); }, SegmentContextExecutors.newSegmentContextExecutor()); *
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.util.concurrent.ExecutornewSegmentContextExecutor()Returns a newExecutorwhich will run any tasks with the current segment mounted.static java.util.concurrent.ExecutornewSegmentContextExecutor(@Nullable Segment segment)Returns a newExecutorwhich will run any tasks with the providedSegmentmounted.static java.util.concurrent.ExecutornewSegmentContextExecutor(AWSXRayRecorder recorder, @Nullable Segment segment)Returns a newExecutorwhich will run any tasks with the providedSegmentmounted in the providedAWSXRayRecorder.
-
-
-
Method Detail
-
newSegmentContextExecutor
public static java.util.concurrent.Executor newSegmentContextExecutor()
Returns a newExecutorwhich will run any tasks with the current segment mounted.
-
newSegmentContextExecutor
public static java.util.concurrent.Executor newSegmentContextExecutor(@Nullable Segment segment)
Returns a newExecutorwhich will run any tasks with the providedSegmentmounted. Ifsegmentisnull, the executor is a no-op.
-
newSegmentContextExecutor
public static java.util.concurrent.Executor newSegmentContextExecutor(AWSXRayRecorder recorder, @Nullable Segment segment)
Returns a newExecutorwhich will run any tasks with the providedSegmentmounted in the providedAWSXRayRecorder. Ifsegmentisnull, the executor is a no-op.
-
-