Пример #1
0
        public static bool TryExtractCorrelationContext(this HttpRequest request, out ICorrelationContext correlationContext)
        {
            if (request == null)
            {
                correlationContext = null;
                return(false);
            }

            correlationContext = new DefaultCorrelationContext
            {
                MessageId = request.Headers.GetHeaderValue(DeimosConstants.MessageIdHeader),
                EnvoyCorrelationContext = new DefaultEnvoyCorrelationContextContext
                {
                    Flags         = request.Headers.GetHeaderValue(DeimosConstants.EnvoyFlagsHeader),
                    Sampled       = request.Headers.GetHeaderValue(DeimosConstants.EnvoySampledHeader),
                    RequestId     = request.Headers.GetHeaderValue(DeimosConstants.RequestIdHeader),
                    SpanId        = request.Headers.GetHeaderValue(DeimosConstants.EnvoySpanIdHeader),
                    TraceId       = request.Headers.GetHeaderValue(DeimosConstants.EnvoyTraceIdHeader),
                    OtSpanContext = request.Headers.GetHeaderValue(DeimosConstants.EnvoyOutgoingSpanContext),
                    ParentSpanId  = request.Headers.GetHeaderValue(DeimosConstants.EnvoyParentSpanIdHeader)
                }
            };

            return(true);
        }
Пример #2
0
        public static bool TryExtractCorrelationContext(this HttpResponseMessage message, out ICorrelationContext correlationContext)
        {
            if (message == null)
            {
                correlationContext = null;
                return(false);
            }

            correlationContext = new DefaultCorrelationContext
            {
                MessageId = message.Headers.GetValues(DeimosConstants.MessageIdHeader).FirstOrDefault(),
                EnvoyCorrelationContext = new DefaultEnvoyCorrelationContextContext
                {
                    Flags         = message.Headers.GetValues(DeimosConstants.EnvoyFlagsHeader).FirstOrDefault(),
                    Sampled       = message.Headers.GetValues(DeimosConstants.EnvoySampledHeader).FirstOrDefault(),
                    RequestId     = message.Headers.GetValues(DeimosConstants.RequestIdHeader).FirstOrDefault(),
                    SpanId        = message.Headers.GetValues(DeimosConstants.EnvoySpanIdHeader).FirstOrDefault(),
                    TraceId       = message.Headers.GetValues(DeimosConstants.EnvoyTraceIdHeader).FirstOrDefault(),
                    OtSpanContext = message.Headers.GetValues(DeimosConstants.EnvoyOutgoingSpanContext).FirstOrDefault(),
                    ParentSpanId  = message.Headers.GetValues(DeimosConstants.EnvoyParentSpanIdHeader).FirstOrDefault()
                }
            };
            return(true);
        }