/** * @return A new builder instance with all defaults set. */ public static AWSXRayRecorderBuilder standard() { return new AWSXRayRecorderBuilder(); }
/** * @return An instance of {@code AWSXRayRecorder} using the {@link com.amazonaws.xray.strategy.sampling.DefaultSamplingStrategy}, {@link com.amazonaws.xray.strategy.DefaultPrioritizationStrategy}, along with other default strategies and settings. */ public static AWSXRayRecorder defaultRecorder() { return standard().build(); }
public static Optional<ContextMissingStrategy> contextMissingStrategyFromSystemProperty() { String contextMissingStrategyOverrideValue = System.getProperty(ContextMissingStrategy.CONTEXT_MISSING_STRATEGY_SYSTEM_PROPERTY_OVERRIDE_KEY); return getContextMissingStrategy(contextMissingStrategyOverrideValue); }
public AWSXRayRecorder() { samplingStrategy = new DefaultSamplingStrategy(); streamingStrategy = new DefaultStreamingStrategy(); prioritizationStrategy = new DefaultPrioritizationStrategy(); throwableSerializationStrategy = new DefaultThrowableSerializationStrategy(); contextMissingStrategy = new DefaultContextMissingStrategy(); Optional<ContextMissingStrategy> environmentContextMissingStrategy = AWSXRayRecorderBuilder.contextMissingStrategyFromEnvironmentVariable(); Optional<ContextMissingStrategy> systemContextMissingStrategy = AWSXRayRecorderBuilder.contextMissingStrategyFromSystemProperty(); if (environmentContextMissingStrategy.isPresent()) { logger.info("Overriding contextMissingStrategy. Environment variable " + ContextMissingStrategy.CONTEXT_MISSING_STRATEGY_ENVIRONMENT_VARIABLE_OVERRIDE_KEY + " has value: \"" + System.getenv(ContextMissingStrategy.CONTEXT_MISSING_STRATEGY_ENVIRONMENT_VARIABLE_OVERRIDE_KEY) + "\"."); contextMissingStrategy = environmentContextMissingStrategy.get(); } else if (systemContextMissingStrategy.isPresent()) { logger.info("Overriding contextMissingStrategy. System property " + ContextMissingStrategy.CONTEXT_MISSING_STRATEGY_SYSTEM_PROPERTY_OVERRIDE_KEY + " has value: \"" + System.getProperty(ContextMissingStrategy.CONTEXT_MISSING_STRATEGY_SYSTEM_PROPERTY_OVERRIDE_KEY) + "\"."); contextMissingStrategy = systemContextMissingStrategy.get(); } segmentContextResolverChain = new SegmentContextResolverChain(); segmentContextResolverChain.addResolver(new LambdaSegmentContextResolver()); segmentContextResolverChain.addResolver(new ThreadLocalSegmentContextResolver()); awsRuntimeContext = new ConcurrentHashMap<>(); awsRuntimeContext.put("xray", SDK_VERSION_INFORMATION); serviceRuntimeContext = new ConcurrentHashMap<>(); serviceRuntimeContext.putAll(RUNTIME_INFORMATION); try { emitter = new DefaultEmitter(); } catch (SocketException e) { throw new RuntimeException("Unable to instantiate AWSXRayRecorder: ", e); } }
samplingRequest.setServiceType(AWSXRayRecorderBuilder.defaultRecorder().getOrigin());
public AWSXRayRecorder() { samplingStrategy = new DefaultSamplingStrategy(); streamingStrategy = new DefaultStreamingStrategy(); prioritizationStrategy = new DefaultPrioritizationStrategy(); throwableSerializationStrategy = new DefaultThrowableSerializationStrategy(); contextMissingStrategy = new DefaultContextMissingStrategy(); Optional<ContextMissingStrategy> environmentContextMissingStrategy = AWSXRayRecorderBuilder.contextMissingStrategyFromEnvironmentVariable(); Optional<ContextMissingStrategy> systemContextMissingStrategy = AWSXRayRecorderBuilder.contextMissingStrategyFromSystemProperty(); if (environmentContextMissingStrategy.isPresent()) { logger.info("Overriding contextMissingStrategy. Environment variable " + ContextMissingStrategy.CONTEXT_MISSING_STRATEGY_ENVIRONMENT_VARIABLE_OVERRIDE_KEY + " has value: \"" + System.getenv(ContextMissingStrategy.CONTEXT_MISSING_STRATEGY_ENVIRONMENT_VARIABLE_OVERRIDE_KEY) + "\"."); contextMissingStrategy = environmentContextMissingStrategy.get(); } else if (systemContextMissingStrategy.isPresent()) { logger.info("Overriding contextMissingStrategy. System property " + ContextMissingStrategy.CONTEXT_MISSING_STRATEGY_SYSTEM_PROPERTY_OVERRIDE_KEY + " has value: \"" + System.getProperty(ContextMissingStrategy.CONTEXT_MISSING_STRATEGY_SYSTEM_PROPERTY_OVERRIDE_KEY) + "\"."); contextMissingStrategy = systemContextMissingStrategy.get(); } segmentContextResolverChain = new SegmentContextResolverChain(); segmentContextResolverChain.addResolver(new LambdaSegmentContextResolver()); segmentContextResolverChain.addResolver(new ThreadLocalSegmentContextResolver()); awsRuntimeContext = new ConcurrentHashMap<>(); awsRuntimeContext.put("xray", SDK_VERSION_INFORMATION); serviceRuntimeContext = new ConcurrentHashMap<>(); serviceRuntimeContext.putAll(RUNTIME_INFORMATION); try { emitter = new DefaultEmitter(); } catch (SocketException e) { throw new RuntimeException("Unable to instantiate AWSXRayRecorder: ", e); } }
client.setThrowableSerializationStrategy(throwableSerializationStrategy); if (null != contextMissingStrategy && !AWSXRayRecorderBuilder.contextMissingStrategyFromEnvironmentVariable().isPresent() && !AWSXRayRecorderBuilder.contextMissingStrategyFromSystemProperty().isPresent()) { client.setContextMissingStrategy(contextMissingStrategy);
/** * @return An instance of {@code AWSXRayRecorder} using the {@link com.amazonaws.xray.strategy.sampling.DefaultSamplingStrategy}, {@link com.amazonaws.xray.strategy.DefaultPrioritizationStrategy}, along with other default strategies and settings. */ public static AWSXRayRecorder defaultRecorder() { return standard().build(); }
public static Optional<ContextMissingStrategy> contextMissingStrategyFromEnvironmentVariable() { String contextMissingStrategyOverrideValue = System.getenv(ContextMissingStrategy.CONTEXT_MISSING_STRATEGY_ENVIRONMENT_VARIABLE_OVERRIDE_KEY); return getContextMissingStrategy(contextMissingStrategyOverrideValue); }
/** * @return A new builder instance with all defaults set. */ public static AWSXRayRecorderBuilder standard() { return new AWSXRayRecorderBuilder(); }
client.setThrowableSerializationStrategy(throwableSerializationStrategy); if (null != contextMissingStrategy && !AWSXRayRecorderBuilder.contextMissingStrategyFromEnvironmentVariable().isPresent() && !AWSXRayRecorderBuilder.contextMissingStrategyFromSystemProperty().isPresent()) { client.setContextMissingStrategy(contextMissingStrategy);
public static Optional<ContextMissingStrategy> contextMissingStrategyFromSystemProperty() { String contextMissingStrategyOverrideValue = System.getProperty(ContextMissingStrategy.CONTEXT_MISSING_STRATEGY_SYSTEM_PROPERTY_OVERRIDE_KEY); return getContextMissingStrategy(contextMissingStrategyOverrideValue); }
public static Optional<ContextMissingStrategy> contextMissingStrategyFromEnvironmentVariable() { String contextMissingStrategyOverrideValue = System.getenv(ContextMissingStrategy.CONTEXT_MISSING_STRATEGY_ENVIRONMENT_VARIABLE_OVERRIDE_KEY); return getContextMissingStrategy(contextMissingStrategyOverrideValue); }