public void TestXRayConfigureNetstandard() { // Register the configurations from appsettings.json file in the unittest folder // Register the following items, if provided, for AWS XRay .Net Core SDK // "DisableXRayTracing" : bool // "SamplingRuleManifest" : string // "AWSXRayPlugins" : string // "AwsServiceHandlerManifest" : string // "UseRuntimeErrors" : bool // "CollectSqlQueries" : bool // AND register the following items, if provided, for Auto-instrumentation SDK // "ServiceName" : string // "DaemonAddress" : string // "TraceHttpRequests" : bool // "TraceAWSRequests" : bool // "TraceSqlRequests" : bool // "TraceEFReqeusts" : bool var xrayAutoInstrumentationoptions = XRayConfiguration.Register(); var _recorder = AWSXRayRecorder.Instance; Assert.IsFalse(_recorder.XRayOptions.IsXRayTracingDisabled); Assert.IsTrue(_recorder.XRayOptions.UseRuntimeErrors); Assert.IsFalse(_recorder.XRayOptions.CollectSqlQueries); Assert.AreEqual("UnittestSample", xrayAutoInstrumentationoptions.ServiceName); Assert.AreEqual("127.0.0.1:2000", xrayAutoInstrumentationoptions.DaemonAddress); Assert.IsTrue(xrayAutoInstrumentationoptions.TraceHttpRequests); Assert.IsFalse(xrayAutoInstrumentationoptions.TraceAWSRequests); Assert.IsTrue(xrayAutoInstrumentationoptions.TraceSqlRequests); Assert.IsFalse(xrayAutoInstrumentationoptions.TraceEFRequests); }
public void TestUseRuntimeErrorsTrue() { IConfiguration configuration = BuildConfiguration("UseRuntimeErrorsTrue.json"); _xRayOptions = XRayConfiguration.GetXRayOptions(configuration); Assert.IsTrue(_xRayOptions.UseRuntimeErrors); }
public void TestUseRuntimeErrorsDefaultsTrue_WhenNotSpecifiedInJson() { IConfiguration configuration = BuildConfiguration("DisabledXRayMissing.json"); _xRayOptions = XRayConfiguration.GetXRayOptions(configuration); Assert.IsTrue(_xRayOptions.UseRuntimeErrors); }
public void TestXRayConfigureNetframeworkTraceEFRequestsDefault() { var xrayAutoInstrumentationOptions = XRayConfiguration.Register(); AppSettings.Reset(); Assert.IsTrue(xrayAutoInstrumentationOptions.TraceEFRequests); }
public void TestXRayConfigureNetframeworkDaemonAddressDefault() { var xrayAutoInstrumentationOptions = XRayConfiguration.Register(); AppSettings.Reset(); Assert.AreEqual("127.0.0.1:2000", xrayAutoInstrumentationOptions.DaemonAddress); }
public void TestXRayConfigureNetframeworkServiceNameDefault() { var xrayAutoInstrumentationOptions = XRayConfiguration.Register(); AppSettings.Reset(); Assert.AreEqual("DefaultService", xrayAutoInstrumentationOptions.ServiceName); }
/// <summary> /// Initializes provided instance of the <see cref="AWSXRayRecorder" /> class with /// the instance of <see cref="IConfiguration" />. /// </summary> /// <param name="configuration">Instance of <see cref="IConfiguration"/>.</param> /// <param name="recorder">Instance of <see cref="AWSXRayRecorder"/>.</param> public static void InitializeInstance(IConfiguration configuration, AWSXRayRecorder recorder) { XRayOptions xRayOptions = XRayConfiguration.GetXRayOptions(configuration); recorder.XRayOptions = xRayOptions; recorder = new AWSXRayRecorderBuilder().WithPluginsFromConfig(xRayOptions).Build(recorder); }
public void TestXRayConfigureNetframeworkTraceEFRequestsInvalid() { ConfigurationManager.AppSettings["TraceSqlRequests"] = "invalid"; var xrayAutoInstrumentationOptions = XRayConfiguration.Register(); AppSettings.Reset(); Assert.IsTrue(xrayAutoInstrumentationOptions.TraceEFRequests); }
public void TestXRayConfigureNetframeworkTraceAWSRequestsFalse() { ConfigurationManager.AppSettings["TraceAWSRequests"] = "false"; var xrayAutoInstrumentationOptions = XRayConfiguration.Register(); AppSettings.Reset(); Assert.IsFalse(xrayAutoInstrumentationOptions.TraceAWSRequests); }
public void TestXRayConfigureNetframeworkDaemonAddress() { ConfigurationManager.AppSettings["DaemonAddress"] = "1.2.3.4:2000"; var xrayAutoInstrumentationOptions = XRayConfiguration.Register(); AppSettings.Reset(); Assert.AreEqual("1.2.3.4:2000", xrayAutoInstrumentationOptions.DaemonAddress); }
public void TestXRayConfigureNetframeworkServiceName() { ConfigurationManager.AppSettings["ServiceName"] = "UnittestSample"; var xrayAutoInstrumentationOptions = XRayConfiguration.Register(); AppSettings.Reset(); Assert.AreEqual("UnittestSample", xrayAutoInstrumentationOptions.ServiceName); }
/// <summary> /// Initializes a new instance of the <see cref="AWSXRayRecorder" /> class /// with given instance of <see cref="IConfiguration" />. /// </summary> /// <param name="configuration">Instance of <see cref="IConfiguration"/>.</param> public static void InitializeInstance(IConfiguration configuration) { XRayOptions xRayOptions = XRayConfiguration.GetXRayOptions(configuration); var recorderBuilder = GetBuilder(xRayOptions); Instance = recorderBuilder.Build(xRayOptions); }
public void TestCollecSqlQueriesTrue() { IConfiguration configuration = BuildConfiguration("CollectSqlQueriesTrue.json"); _xRayOptions = XRayConfiguration.GetXRayOptions(configuration); AWSXRayRecorder.InitializeInstance(configuration); Assert.IsTrue(_xRayOptions.CollectSqlQueries); }
public void TestCollectSqlQueriesFalse_WhenNotSpecifiedInJson() { IConfiguration configuration = BuildConfiguration("DisabledXRayMissing.json"); _xRayOptions = XRayConfiguration.GetXRayOptions(configuration); AWSXRayRecorder.InitializeInstance(configuration); Assert.IsFalse(_xRayOptions.CollectSqlQueries); }
public void TestConfigurationIsNull() { IConfiguration configuration = BuildConfiguration("NoXRaySection.json"); _xRayOptions = XRayConfiguration.GetXRayOptions(configuration); Assert.IsFalse(_xRayOptions.IsXRayTracingDisabled); Assert.IsNull(_xRayOptions.AwsServiceHandlerManifest); Assert.IsNull(_xRayOptions.PluginSetting); Assert.IsNull(_xRayOptions.SamplingRuleManifest); }
public void TestXRaySectionMissing() // No "Xray" section in the json { IConfiguration configuration = null; _xRayOptions = XRayConfiguration.GetXRayOptions(configuration); Assert.IsFalse(_xRayOptions.IsXRayTracingDisabled); Assert.IsNull(_xRayOptions.AwsServiceHandlerManifest); Assert.IsNull(_xRayOptions.PluginSetting); Assert.IsNull(_xRayOptions.SamplingRuleManifest); }
public void TestUseRuntimeErrorsDefaultsTrue_WhenNotSpecifiedInJson() { IConfiguration configuration = BuildConfiguration("DisabledXRayMissing.json"); _xRayOptions = XRayConfiguration.GetXRayOptions(configuration); AWSXRayRecorder.InitializeInstance(configuration); Assert.IsTrue(_xRayOptions.UseRuntimeErrors); Assert.AreEqual(AWSXRayRecorder.Instance.ContextMissingStrategy, Core.Strategies.ContextMissingStrategy.RUNTIME_ERROR); }
public void TestUseRuntimeErrorsTrue() { IConfiguration configuration = BuildConfiguration("UseRuntimeErrorsTrue.json"); _xRayOptions = XRayConfiguration.GetXRayOptions(configuration); AWSXRayRecorder.InitializeInstance(configuration); Assert.IsTrue(_xRayOptions.UseRuntimeErrors); Assert.AreEqual(AWSXRayRecorder.Instance.ContextMissingStrategy, Core.Strategies.ContextMissingStrategy.RUNTIME_ERROR); }
/// <summary> /// Initializes provided instance of the <see cref="AWSXRayRecorder" /> class with /// the instance of <see cref="IConfiguration" />. /// </summary> /// <param name="configuration">Instance of <see cref="IConfiguration"/>.</param> /// <param name="recorder">Instance of <see cref="AWSXRayRecorder"/>.</param> public static void InitializeInstance(IConfiguration configuration, AWSXRayRecorder recorder) { XRayOptions xRayOptions = XRayConfiguration.GetXRayOptions(configuration); recorder.XRayOptions = xRayOptions; var recorderBuilder = GetBuilder(xRayOptions); recorder = recorderBuilder.Build(recorder); Instance = recorder; }
/// <summary> /// Initializes provided instance of the <see cref="AWSXRayRecorder" /> class with /// the instance of <see cref="IConfiguration" />. /// </summary> /// <param name="configuration">Instance of <see cref="IConfiguration"/>.</param> /// <param name="recorder">Instance of <see cref="AWSXRayRecorder"/>.</param> public static void InitializeInstance(IConfiguration configuration = null, AWSXRayRecorder recorder = null) { XRayOptions xRayOptions = XRayConfiguration.GetXRayOptions(configuration); var recorderBuilder = GetBuilder(xRayOptions); if (recorder != null) { recorder.XRayOptions = xRayOptions; recorder = recorderBuilder.Build(recorder); } else { recorder = recorderBuilder.Build(xRayOptions); } Instance = recorder; }
/// <summary> /// Initializes provided instance of the <see cref="AWSXRayRecorder" /> class with /// the instance of <see cref="IConfiguration" />. /// </summary> /// <param name="configuration">Instance of <see cref="IConfiguration"/>.</param> /// <param name="recorder">Instance of <see cref="AWSXRayRecorder"/>.</param> public static void InitializeInstance(IConfiguration configuration = null, AWSXRayRecorder recorder = null) { XRayOptions xRayOptions = XRayConfiguration.GetXRayOptions(configuration); var recorderBuilder = GetBuilder(xRayOptions); if (recorder != null) { _logger.DebugFormat("Using custom X-Ray recorder."); recorder.XRayOptions = xRayOptions; recorder = recorderBuilder.Build(recorder); } else { _logger.DebugFormat("Using default X-Ray recorder."); recorder = recorderBuilder.Build(xRayOptions); } Instance = recorder; }
/// <summary> /// Initialize AWSXRayRecorder instance, register configurations and tracing handlers /// </summary> internal static void InitializeAspNet() { if (!AWSXRayRecorder.IsCustomRecorder) // If custom recorder is not set { AWSXRayRecorder.Instance.SetTraceContext(new HybridContextContainer()); // configure Trace Context } _recorder = AWSXRayRecorder.Instance; // Register configurations var xrayAutoInstrumentationOptions = XRayConfiguration.Register(); _recorder.SetDaemonAddress(xrayAutoInstrumentationOptions.DaemonAddress); if (GetSegmentNamingStrategy() == null) // ensures only one time initialization among many HTTPApplication instances { var serviceName = xrayAutoInstrumentationOptions.ServiceName; InitializeAspNet(new FixedSegmentNamingStrategy(serviceName)); } // Initialize tracing handlers for Asp.Net platform AspNetTracingHandlers.Initialize(xrayAutoInstrumentationOptions); }