Class AWSXRayRecorderBuilder


  • public class AWSXRayRecorderBuilder
    extends java.lang.Object
    • 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.
      • 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
      • 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 of AWSXRayRecorder with the provided context missing strategy. This value will be overriden at build() time if either the environment variable with key AWS_XRAY_CONTEXT_MISSING or system property with key com.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 key AWS_XRAY_CONTEXT_MISSING or system property with key com.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 an AWSXRayRecorder 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 an AWSXRayRecorder 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 an AWSXRayRecorder 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