Package com.amazonaws.xray
Class AWSXRayRecorderBuilder
java.lang.Object
com.amazonaws.xray.AWSXRayRecorderBuilder
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Constructs and returns an AWSXRayRecorder with the provided configuration.static Optional<ContextMissingStrategy>
static Optional<ContextMissingStrategy>
static AWSXRayRecorder
static AWSXRayRecorderBuilder
standard()
withContextMissingStrategy
(ContextMissingStrategy contextMissingStrategy) Prepares this builder to build an instance ofAWSXRayRecorder
with the provided context missing strategy.Adds all implemented plugins to the builder instance rather than requiring them to be individually added.withEmitter
(Emitter emitter) Prepares this builder to build anAWSXRayRecorder
which uses a fast but cryptographically insecure random number generator for generating random IDs.Prepares this builder to build anAWSXRayRecorder
which creates Trace ID for all Segments even for NoOpSegments or not sampled ones that usually include include a static invalid TraceID.withPlugin
(Plugin plugin) Adds a plugin to the list of plugins which the builder will execute at build time.withPrioritizationStrategy
(PrioritizationStrategy prioritizationStrategy) withSamplingStrategy
(SamplingStrategy samplingStrategy) Prepares this builder to build anAWSXRayRecorder
which uses a cryptographically secure random generator for generating random IDs.withSegmentContextResolverChain
(SegmentContextResolverChain segmentContextResolverChain) withSegmentListener
(SegmentListener segmentListener) Adds a SegmentListener to the list of segment listeners that will be attached to the recorder at build time.withStreamingStrategy
(StreamingStrategy streamingStrategy) withThrowableSerializationStrategy
(ThrowableSerializationStrategy throwableSerializationStrategy)
-
Method Details
-
contextMissingStrategyFromEnvironmentVariable
-
contextMissingStrategyFromSystemProperty
-
standard
- Returns:
- A new builder instance with all defaults set.
-
defaultRecorder
- Returns:
- An instance of
AWSXRayRecorder
using theDefaultSamplingStrategy
,DefaultPrioritizationStrategy
, along with other default strategies and settings.
-
withPlugin
Adds a plugin to the list of plugins which the builder will execute at build time. This method is execution-order sensitive. Values overriden by plugins later in the list will be kept (e.g. origin).- Parameters:
plugin
- the plugin to add- Returns:
- the builder instance, for chaining
-
withSamplingStrategy
-
withStreamingStrategy
-
withPrioritizationStrategy
public AWSXRayRecorderBuilder withPrioritizationStrategy(PrioritizationStrategy prioritizationStrategy) -
withThrowableSerializationStrategy
public AWSXRayRecorderBuilder withThrowableSerializationStrategy(ThrowableSerializationStrategy throwableSerializationStrategy) -
withEmitter
-
withSegmentContextResolverChain
public AWSXRayRecorderBuilder withSegmentContextResolverChain(SegmentContextResolverChain segmentContextResolverChain) -
withSegmentListener
Adds a SegmentListener to the list of segment listeners that will be attached to the recorder at build time.- Parameters:
segmentListener
- the SegmentListener to add- Returns:
- the builder instance, for chaining
-
withContextMissingStrategy
public AWSXRayRecorderBuilder withContextMissingStrategy(ContextMissingStrategy contextMissingStrategy) Prepares this builder to build an instance ofAWSXRayRecorder
with the provided context missing strategy. This value will be overriden atbuild()
time if either the environment variable with keyAWS_XRAY_CONTEXT_MISSING
or system property with keycom.amazonaws.xray.strategy.contextMissingStrategy
are set to a valid value.- Parameters:
contextMissingStrategy
- the context missing strategy to be used if both the environment variable with keyAWS_XRAY_CONTEXT_MISSING
or system property with keycom.amazonaws.xray.strategy.contextMissingStrategy
are not set to a valid value- Returns:
- the builder instance, for chaining
- See Also:
-
withDefaultPlugins
Adds all implemented plugins to the builder instance rather than requiring them to be individually added. The recorder will only reflect metadata from plugins that are enabled, which is checked in the build method below.- Returns:
- The builder instance, for chaining
-
withFastIdGenerator
Prepares this builder to build anAWSXRayRecorder
which uses a fast but cryptographically insecure random number generator for generating random IDs. This option should be preferred unless your application relies on AWS X-Ray trace IDs being generated from a cryptographically secure random number source.- See Also:
-
withSecureIdGenerator
Prepares this builder to build anAWSXRayRecorder
which uses a cryptographically secure random generator for generating random IDs. Unless your application relies on AWS X-Ray trace IDs being generated from a cryptographically secure random number source, you should prefer to use the fast ID generator.- See Also:
-
withForcedTraceIdGeneration
Prepares this builder to build anAWSXRayRecorder
which creates Trace ID for all Segments even for NoOpSegments or not sampled ones that usually include include a static invalid TraceID. This could be useful for example in case the Trace ID is logged to be able to aggregate all logs from a single request -
build
Constructs and returns an AWSXRayRecorder with the provided configuration.- Returns:
- a configured instance of AWSXRayRecorder
-