protected override SpanContext Extract(ITextMap carrier) { SpanContext context = null; Dictionary <string, string> baggage = null; string debugId = null; foreach (var entry in carrier) { // TODO there should be no lower-case here string key = entry.Key.ToLowerInvariant(); if (string.Equals(key, _contextKey, StringComparison.Ordinal)) { context = SpanContext.ContextFromString(DecodedValue(entry.Value)); } else if (string.Equals(key, Constants.DebugIdHeaderKey, StringComparison.Ordinal)) { debugId = DecodedValue(entry.Value); } else if (key.StartsWith(_baggagePrefix, StringComparison.Ordinal)) { if (baggage == null) { baggage = new Dictionary <string, string>(); } baggage[Keys.UnprefixedKey(key, _baggagePrefix)] = DecodedValue(entry.Value); } } if (context == null) { if (debugId != null) { return(SpanContext.WithDebugId(debugId)); } return(null); } if (baggage == null) { return(context); } return(context.WithBaggage(baggage)); }