public static AWSXRayRecorder BuildAWSXRayRecorder(ISamplingStrategy samplingStrategy = null, ISegmentEmitter segmentEmitter = null, string daemonAddress = null, ITraceContext traceContext = null) { AWSXRayRecorderBuilder builder = new AWSXRayRecorderBuilder(); if (samplingStrategy != null) { builder.WithSamplingStrategy(samplingStrategy); } if (segmentEmitter != null) { builder.WithSegmentEmitter(segmentEmitter); } if (!string.IsNullOrEmpty(daemonAddress)) { builder.WithDaemonAddress(daemonAddress); } if (traceContext != null) { builder.WithTraceContext(traceContext); } var result = builder.Build(); return(result); }
private static AWSXRayRecorder BuildAWSXRayRecorder() { var builder = new AWSXRayRecorderBuilder() .WithSamplingStrategy(new TestSamplingStrategy()); var result = builder.Build(); return(result); }
public void TestSetContextMissingUsingConfiguration2() // Contextmissing startegy not set { #if NET45 AppSettings.Reset(); AWSXRayRecorderBuilder builder = new AWSXRayRecorderBuilder().WithContextMissingStrategyFromAppSettings(); #else AWSXRayRecorderBuilder builder = new AWSXRayRecorderBuilder().WithContextMissingStrategyFromConfig(_xRayOptions); #endif AWSXRayRecorder recorder = builder.Build(); Assert.AreEqual(ContextMissingStrategy.RUNTIME_ERROR, recorder.ContextMissingStrategy); // Default context missing strategy is set }
public void TestSetContextMissingUsingConfiguration1() // Contextmissing startegy set to log error from configuration { #if NET45 ConfigurationManager.AppSettings[UseRuntimeErrors] = "false"; AppSettings.Reset(); AWSXRayRecorderBuilder builder = new AWSXRayRecorderBuilder().WithContextMissingStrategyFromAppSettings(); #else _xRayOptions.UseRuntimeErrors = false; AWSXRayRecorderBuilder builder = new AWSXRayRecorderBuilder().WithContextMissingStrategyFromConfig(_xRayOptions); #endif AWSXRayRecorder recorder = builder.Build(); Assert.AreEqual(ContextMissingStrategy.LOG_ERROR, recorder.ContextMissingStrategy); }
public void TestSetContextMissingUsingConfiguration3() // Contextmissing startegy is set through environment and configurations { Environment.SetEnvironmentVariable(AWSXRayRecorder.EnvironmentVariableContextMissingStrategy, "LOG_ERROR"); #if NET45 ConfigurationManager.AppSettings[UseRuntimeErrors] = "true"; AppSettings.Reset(); AWSXRayRecorderBuilder builder = new AWSXRayRecorderBuilder().WithContextMissingStrategyFromAppSettings(); #else _xRayOptions.UseRuntimeErrors = true; AWSXRayRecorderBuilder builder = new AWSXRayRecorderBuilder().WithContextMissingStrategyFromConfig(_xRayOptions); #endif AWSXRayRecorder recorder = builder.Build(); Assert.AreEqual(ContextMissingStrategy.LOG_ERROR, recorder.ContextMissingStrategy); // Preference given to environment variable Environment.SetEnvironmentVariable(AWSXRayRecorder.EnvironmentVariableContextMissingStrategy, null); }