Package com.amazonaws.xray
Class AWSXRayRecorderBuilder
- java.lang.Object
-
- com.amazonaws.xray.AWSXRayRecorderBuilder
-
public class AWSXRayRecorderBuilder extends java.lang.Object
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AWSXRayRecorder
build()
Constructs and returns an AWSXRayRecorder with the provided configuration.static java.util.Optional<ContextMissingStrategy>
contextMissingStrategyFromEnvironmentVariable()
static java.util.Optional<ContextMissingStrategy>
contextMissingStrategyFromSystemProperty()
static AWSXRayRecorder
defaultRecorder()
static AWSXRayRecorderBuilder
standard()
AWSXRayRecorderBuilder
withContextMissingStrategy(ContextMissingStrategy contextMissingStrategy)
Prepares this builder to build an instance ofAWSXRayRecorder
with the provided context missing strategy.AWSXRayRecorderBuilder
withDefaultPlugins()
Adds all implemented plugins to the builder instance rather than requiring them to be individually added.AWSXRayRecorderBuilder
withEmitter(Emitter emitter)
AWSXRayRecorderBuilder
withFastIdGenerator()
Prepares this builder to build anAWSXRayRecorder
which uses a fast but cryptographically insecure random number generator for generating random IDs.AWSXRayRecorderBuilder
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.AWSXRayRecorderBuilder
withPlugin(Plugin plugin)
Adds a plugin to the list of plugins which the builder will execute at build time.AWSXRayRecorderBuilder
withPrioritizationStrategy(PrioritizationStrategy prioritizationStrategy)
AWSXRayRecorderBuilder
withSamplingStrategy(SamplingStrategy samplingStrategy)
AWSXRayRecorderBuilder
withSecureIdGenerator()
Prepares this builder to build anAWSXRayRecorder
which uses a cryptographically secure random generator for generating random IDs.AWSXRayRecorderBuilder
withSegmentContextResolverChain(SegmentContextResolverChain segmentContextResolverChain)
AWSXRayRecorderBuilder
withSegmentListener(SegmentListener segmentListener)
Adds a SegmentListener to the list of segment listeners that will be attached to the recorder at build time.AWSXRayRecorderBuilder
withStreamingStrategy(StreamingStrategy streamingStrategy)
AWSXRayRecorderBuilder
withThrowableSerializationStrategy(ThrowableSerializationStrategy throwableSerializationStrategy)
-
-
-
Method Detail
-
contextMissingStrategyFromEnvironmentVariable
public static java.util.Optional<ContextMissingStrategy> contextMissingStrategyFromEnvironmentVariable()
-
contextMissingStrategyFromSystemProperty
public static java.util.Optional<ContextMissingStrategy> contextMissingStrategyFromSystemProperty()
-
standard
public static AWSXRayRecorderBuilder standard()
- Returns:
- A new builder instance with all defaults set.
-
defaultRecorder
public static AWSXRayRecorder defaultRecorder()
- Returns:
- An instance of
AWSXRayRecorder
using theDefaultSamplingStrategy
,DefaultPrioritizationStrategy
, along with other default strategies and settings.
-
withPlugin
public AWSXRayRecorderBuilder withPlugin(Plugin plugin)
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
public AWSXRayRecorderBuilder withSamplingStrategy(SamplingStrategy samplingStrategy)
-
withStreamingStrategy
public AWSXRayRecorderBuilder withStreamingStrategy(StreamingStrategy streamingStrategy)
-
withPrioritizationStrategy
public AWSXRayRecorderBuilder withPrioritizationStrategy(PrioritizationStrategy prioritizationStrategy)
-
withThrowableSerializationStrategy
public AWSXRayRecorderBuilder withThrowableSerializationStrategy(ThrowableSerializationStrategy throwableSerializationStrategy)
-
withEmitter
public AWSXRayRecorderBuilder withEmitter(Emitter emitter)
-
withSegmentContextResolverChain
public AWSXRayRecorderBuilder withSegmentContextResolverChain(SegmentContextResolverChain segmentContextResolverChain)
-
withSegmentListener
public AWSXRayRecorderBuilder withSegmentListener(SegmentListener segmentListener)
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:
ContextMissingStrategy
-
withDefaultPlugins
public AWSXRayRecorderBuilder 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
public AWSXRayRecorderBuilder 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()
-
withSecureIdGenerator
public AWSXRayRecorderBuilder 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:
withFastIdGenerator()
-
withForcedTraceIdGeneration
public AWSXRayRecorderBuilder 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
public AWSXRayRecorder build()
Constructs and returns an AWSXRayRecorder with the provided configuration.- Returns:
- a configured instance of AWSXRayRecorder
-
-