A telemetry initializer that will set the correlation context for all telemetry items in web application.
Inheritance: Microsoft.ApplicationInsights.Web.Implementation.WebTelemetryInitializerBase
        private AspNetDiagnosticTelemetryModule CreateModule(string rootIdHeaderName = null, string parentIdHeaderName = null)
        {
            var initializer = new Web.OperationCorrelationTelemetryInitializer();

            if (rootIdHeaderName != null)
            {
                initializer.RootOperationIdHeaderName = rootIdHeaderName;
            }

            if (parentIdHeaderName != null)
            {
                initializer.ParentOperationIdHeaderName = parentIdHeaderName;
            }

            this.configuration.TelemetryInitializers.Add(new Extensibility.OperationCorrelationTelemetryInitializer());

            AspNetDiagnosticTelemetryModule result = new AspNetDiagnosticTelemetryModule();

            var requestModule = new RequestTrackingTelemetryModule()
            {
                EnableChildRequestTrackingSuppression = false
            };

            var exceptionModule = new ExceptionTrackingTelemetryModule();

            requestModule.Initialize(this.configuration);
            exceptionModule.Initialize(this.configuration);

            TelemetryModules.Instance.Modules.Add(requestModule);
            TelemetryModules.Instance.Modules.Add(exceptionModule);

            result.Initialize(this.configuration);

            return(result);
        }
Exemple #2
0
        public void DefaultHeadersOperationCorrelationTelemetryInitializerAreSet()
        {
            var initializer = new OperationCorrelationTelemetryInitializer();

            Assert.AreEqual(RequestResponseHeaders.StandardParentIdHeader, initializer.ParentOperationIdHeaderName);
            Assert.AreEqual(RequestResponseHeaders.StandardRootIdHeader, initializer.RootOperationIdHeaderName);
        }
        public void DefaultHeadersOperationCorrelationTelemetryInitializerAreNotSetByDefault()
        {
            var initializer = new OperationCorrelationTelemetryInitializer();

            Assert.IsNull(initializer.ParentOperationIdHeaderName);
            Assert.IsNull(initializer.RootOperationIdHeaderName);
        }
Exemple #4
0
        public void CustomHeadersOperationCorrelationTelemetryInitializerAreSetProperly()
        {
            var initializer = new OperationCorrelationTelemetryInitializer();

            initializer.ParentOperationIdHeaderName = "myParentHeader";
            initializer.RootOperationIdHeaderName   = "myRootHeader";

            Assert.AreEqual("myParentHeader", ActivityHelpers.ParentOperationIdHeaderName);
            Assert.AreEqual("myRootHeader", ActivityHelpers.RootOperationIdHeaderName);

            Assert.AreEqual("myParentHeader", initializer.ParentOperationIdHeaderName);
            Assert.AreEqual("myRootHeader", initializer.RootOperationIdHeaderName);
        }
Exemple #5
0
        public void InitializeDoesNotThrowWhenHttpContextIsNull()
        {
            var source = new OperationCorrelationTelemetryInitializer();

            source.Initialize(new RequestTelemetry());
        }
 public void InitializeDoesNotThrowWhenHttpContextIsNull()
 {
     var source = new OperationCorrelationTelemetryInitializer();
     source.Initialize(new RequestTelemetry());
 }