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); }
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."); }
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)); }
/// <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)); }
/// <inheritdoc /> public ISpanContext Extract <TCarrier>(IFormat <TCarrier> format, TCarrier carrier) { return(_propagator.Extract(format, carrier)); }