Package com.amazonaws.xray.contexts
Class SegmentContextExecutors
java.lang.Object
com.amazonaws.xray.contexts.SegmentContextExecutors
Executor
s 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 these Executor
s 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
Modifier and TypeMethodDescriptionstatic Executor
Returns a newExecutor
which will run any tasks with the current segment mounted.static Executor
newSegmentContextExecutor
(@Nullable Segment segment) static Executor
newSegmentContextExecutor
(AWSXRayRecorder recorder, @Nullable Segment segment) Returns a newExecutor
which will run any tasks with the providedSegment
mounted in the providedAWSXRayRecorder
.
-
Method Details
-
newSegmentContextExecutor
Returns a newExecutor
which will run any tasks with the current segment mounted. -
newSegmentContextExecutor
-
newSegmentContextExecutor
public static Executor newSegmentContextExecutor(AWSXRayRecorder recorder, @Nullable Segment segment) Returns a newExecutor
which will run any tasks with the providedSegment
mounted in the providedAWSXRayRecorder
. Ifsegment
isnull
, the executor is a no-op.
-