public void BeginRequest(HttpContext httpContext, HostingApplication.Context context)
 {
     if (httpContext.Request.Headers.ContainsKey(CorrelationVectorPropagationDelegates.HeaderName))
     {
         httpContext.SetCorrelationVector(
             CorrelationVector.Extend(httpContext.Request.Headers[CorrelationVectorPropagationDelegates.HeaderName][0]));
     }
 }
コード例 #2
0
        public static Task <HttpResponseMessage> SendAsync(
            this HttpClient httpClient,
            CorrelationVector correlationVector,
            HttpRequestMessage requestMessage)
        {
            requestMessage.Properties.Add(
                CorrelationVectorPropagationDelegates.HttpRequestMessagePropertyName,
                correlationVector);

            return(httpClient.SendAsync(requestMessage));
        }
コード例 #3
0
        public static void FromHttpRequestMessageProperty(HttpRequestMessage requestMessage)
        {
            if (requestMessage.Properties.ContainsKey(HttpRequestMessagePropertyName))
            {
                CorrelationVector correlationVector =
                    requestMessage.Properties[HttpRequestMessagePropertyName] as CorrelationVector;

                if (correlationVector != null)
                {
                    requestMessage.Headers.Add(HeaderName, correlationVector.Increment());
                }
            }
        }
コード例 #4
0
        public override void ActivityStarted()
        {
            CorrelationVectorExtension parentExtension =
                Activity.Parent?.GetActivityExtension <CorrelationVectorExtension>();

            if (!string.IsNullOrEmpty(_externalCorrelationVectorParent))
            {
                this.CorrelationVector = CorrelationVector.Extend(_externalCorrelationVectorParent);
            }
            else if (parentExtension != null)
            {
                this.CorrelationVector = parentExtension.CorrelationVector;
            }
            else
            {
                this.CorrelationVector = new CorrelationVector();
            }
        }
コード例 #5
0
 public static void SetCorrelationVector(this HttpContext httpContext, CorrelationVector correlationVector)
 {
     httpContext.Items.Add(typeof(CorrelationVector), correlationVector);
 }