SetCorrelationContextForWebRequest() static private method

Populates WebRequest using the operation context in telemetry item.
static private SetCorrelationContextForWebRequest ( Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry dependencyTelemetry, WebRequest webRequest ) : void
dependencyTelemetry Microsoft.ApplicationInsights.DataContracts.DependencyTelemetry Dependency telemetry item.
webRequest System.Net.WebRequest Http web request.
return void
コード例 #1
0
        public void SetCorrelationContextForWebRequestSetsHeaders()
        {
            var webRequest = WebRequest.Create(new Uri("http://bing.com"));
            var telemetry  = new DependencyTelemetry();

            telemetry.Id = "Id";
            telemetry.Context.Operation.Id = "RootId";

            WebRequestDependencyTrackingHelpers.SetCorrelationContextForWebRequest(telemetry, webRequest);
            var rootId      = webRequest.Headers[RequestResponseHeaders.StandardRootIdHeader];
            var operationId = webRequest.Headers[RequestResponseHeaders.StandardParentIdHeader];

            Assert.AreEqual("RootId", rootId);
            Assert.AreEqual("Id", operationId);
        }
コード例 #2
0
        public void SetCorrelationContextForWebRequestDoesNotFailWithNullWebRequest()
        {
            var telemetry = new DependencyTelemetry();

            WebRequestDependencyTrackingHelpers.SetCorrelationContextForWebRequest(telemetry, null);
        }
コード例 #3
0
        public void SetCorrelationContextForWebRequestFailsWithNullTelemetry()
        {
            var webRequest = WebRequest.Create(new Uri("http://bing.com"));

            WebRequestDependencyTrackingHelpers.SetCorrelationContextForWebRequest(null, webRequest);
        }