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 AWSXRayRecorderbuild()Constructs and returns an AWSXRayRecorder with the provided configuration.static java.util.Optional<ContextMissingStrategy>contextMissingStrategyFromEnvironmentVariable()static java.util.Optional<ContextMissingStrategy>contextMissingStrategyFromSystemProperty()static AWSXRayRecorderdefaultRecorder()static AWSXRayRecorderBuilderstandard()AWSXRayRecorderBuilderwithContextMissingStrategy(ContextMissingStrategy contextMissingStrategy)Prepares this builder to build an instance ofAWSXRayRecorderwith the provided context missing strategy.AWSXRayRecorderBuilderwithDefaultPlugins()Adds all implemented plugins to the builder instance rather than requiring them to be individually added.AWSXRayRecorderBuilderwithEmitter(Emitter emitter)AWSXRayRecorderBuilderwithFastIdGenerator()Prepares this builder to build anAWSXRayRecorderwhich uses a fast but cryptographically insecure random number generator for generating random IDs.AWSXRayRecorderBuilderwithForcedTraceIdGeneration()Prepares this builder to build anAWSXRayRecorderwhich creates Trace ID for all Segments even for NoOpSegments or not sampled ones that usually include include a static invalid TraceID.AWSXRayRecorderBuilderwithPlugin(Plugin plugin)Adds a plugin to the list of plugins which the builder will execute at build time.AWSXRayRecorderBuilderwithPrioritizationStrategy(PrioritizationStrategy prioritizationStrategy)AWSXRayRecorderBuilderwithSamplingStrategy(SamplingStrategy samplingStrategy)AWSXRayRecorderBuilderwithSecureIdGenerator()Prepares this builder to build anAWSXRayRecorderwhich uses a cryptographically secure random generator for generating random IDs.AWSXRayRecorderBuilderwithSegmentContextResolverChain(SegmentContextResolverChain segmentContextResolverChain)AWSXRayRecorderBuilderwithSegmentListener(SegmentListener segmentListener)Adds a SegmentListener to the list of segment listeners that will be attached to the recorder at build time.AWSXRayRecorderBuilderwithStreamingStrategy(StreamingStrategy streamingStrategy)AWSXRayRecorderBuilderwithThrowableSerializationStrategy(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
AWSXRayRecorderusing 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 ofAWSXRayRecorderwith the provided context missing strategy. This value will be overriden atbuild()time if either the environment variable with keyAWS_XRAY_CONTEXT_MISSINGor system property with keycom.amazonaws.xray.strategy.contextMissingStrategyare set to a valid value.- Parameters:
contextMissingStrategy- the context missing strategy to be used if both the environment variable with keyAWS_XRAY_CONTEXT_MISSINGor system property with keycom.amazonaws.xray.strategy.contextMissingStrategyare 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 anAWSXRayRecorderwhich 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 anAWSXRayRecorderwhich 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 anAWSXRayRecorderwhich 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
-
-