Exemplo n.º 1
0
        private static SpanContext ExtractPropagatedContext(IPropagator propagator, HttpRequest request)
        {
            try
            {
                // extract propagation details from http headers
                var requestHeaders = request.Headers;

                if (requestHeaders != null)
                {
                    var headersCollection = new DictionaryHeadersCollection();

                    foreach (var header in requestHeaders)
                    {
                        string   key    = header.Key;
                        string[] values = header.Value.ToArray();

                        if (key != null && values.Length > 0)
                        {
                            headersCollection.Add(key, values);
                        }
                    }

                    return(propagator.Extract(headersCollection));
                }
            }
            catch (Exception ex)
            {
                Log.Error(ex, "Error extracting propagated HTTP headers.");
            }

            return(null);
        }
Exemplo n.º 2
0
        public ISpanContext Extract <TCarrier>(IFormat <TCarrier> format, TCarrier carrier)
        {
            if ((format == BuiltinFormats.TextMap || format == BuiltinFormats.HttpHeaders) &&
                carrier is ITextMap textMap)
            {
                return(_propagator.Extract(textMap));
            }

            throw new ZipkinFormatException(
                      $"Unrecognized carrier format [{format}]. Only ITextMap is supported by this driver.");
        }
Exemplo n.º 3
0
        public global::OpenTracing.ISpanContext Extract(object carrier)
        {
            var map = carrier as ITextMap;

            if (map == null)
            {
                throw new ArgumentException("Carrier should have type ITextMap", nameof(carrier));
            }

            IHeadersCollection headers = new TextMapHeadersCollection(map);
            var propagationContext     = _propagator.Extract(headers);

            return(new OpenTracingSpanContext(propagationContext));
        }
Exemplo n.º 4
0
        /// <inheritdoc />
        public ISpanContext Extract <TCarrier>(IFormat <TCarrier> format, TCarrier carrier)
        {
            var ctx = _propagator.Extract(format, carrier);

            if (_options.EnableMetaEventLogging)
            {
                this.BuildSpan(LightStepConstants.MetaEvent.ExtractOperation)
                .IgnoreActiveSpan()
                .WithTag(LightStepConstants.MetaEvent.MetaEventKey, true)
                .WithTag(LightStepConstants.MetaEvent.SpanIdKey, ctx.SpanId)
                .WithTag(LightStepConstants.MetaEvent.TraceIdKey, ctx.TraceId)
                .WithTag(LightStepConstants.MetaEvent.PropagationFormatKey, format.GetType().ToString())
                .Start()
                .Finish();
            }
            return(ctx);
        }
 public static SpanContext Extract(this IPropagator propagator, IHeadersCollection headers)
 {
     return(propagator.Extract(headers, ExtractFromHeadersCollection));
 }
Exemplo n.º 6
0
 /// <inheritdoc />
 public ISpanContext Extract <TCarrier>(IFormat <TCarrier> format, TCarrier carrier)
 {
     return(_propagator.Extract(format, carrier));
 }