public void TestXRayConfigureNetframeworkTraceEFRequestsDefault()
        {
            var xrayAutoInstrumentationOptions = XRayConfiguration.Register();

            AppSettings.Reset();
            Assert.IsTrue(xrayAutoInstrumentationOptions.TraceEFRequests);
        }
Exemplo n.º 2
0
        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 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);
        }
        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);
        }
Exemplo n.º 9
0
        /// <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);
        }