internal SpanContext( TraceId traceId, SpanId spanId, SpanId parentId, SpanContextFlags flags, IReadOnlyDictionary <string, string> baggage, string debugId) { TraceId = traceId; SpanId = spanId; ParentId = parentId; Flags = flags; Baggage = baggage ?? throw new ArgumentNullException(nameof(baggage)); DebugId = debugId; }
protected override SpanContext Extract(ITextMap carrier) { long? traceId = null; long? spanId = null; long? parentId = 0L; // Conventionally, parent id == 0 means the root span SpanContextFlags flags = SpanContextFlags.None; foreach (var entry in carrier) { if (string.Equals(entry.Key, SampledName, StringComparison.OrdinalIgnoreCase)) { string value = entry.Value; if (string.Equals(value, "1", StringComparison.Ordinal) || string.Equals(value, "true", StringComparison.OrdinalIgnoreCase)) { flags |= SpanContextFlags.Sampled; } } else if (string.Equals(entry.Key, TraceIdName, StringComparison.OrdinalIgnoreCase)) { traceId = HexCodec.LowerHexToUnsignedLong(entry.Value); } else if (string.Equals(entry.Key, ParentSpanIdName, StringComparison.OrdinalIgnoreCase)) { parentId = HexCodec.LowerHexToUnsignedLong(entry.Value); } else if (string.Equals(entry.Key, SpanIdName, StringComparison.OrdinalIgnoreCase)) { spanId = HexCodec.LowerHexToUnsignedLong(entry.Value); } else if (string.Equals(entry.Key, FlagsName, StringComparison.OrdinalIgnoreCase)) { if (string.Equals(entry.Value, "1", StringComparison.OrdinalIgnoreCase)) { flags |= SpanContextFlags.Debug; } } } if (traceId != null && parentId != null && spanId != null) { return(new SpanContext(new TraceId(traceId.Value), new SpanId(spanId.Value), new SpanId(parentId.Value), flags)); } return(null); }
protected override SpanContext Extract(ITextMap carrier) { TraceId? traceId = null; SpanId? spanId = null; SpanId parentId = new SpanId(0); // Conventionally, parent id == 0 means the root span SpanContextFlags flags = SpanContextFlags.None; foreach (var entry in carrier) { if (string.Equals(entry.Key, SampledName, StringComparison.OrdinalIgnoreCase)) { string value = entry.Value; if (string.Equals(value, "1", StringComparison.Ordinal) || string.Equals(value, "true", StringComparison.OrdinalIgnoreCase)) { flags |= SpanContextFlags.Sampled; } } else if (string.Equals(entry.Key, TraceIdName, StringComparison.OrdinalIgnoreCase)) { traceId = TraceId.FromString(entry.Value); } else if (string.Equals(entry.Key, ParentSpanIdName, StringComparison.OrdinalIgnoreCase)) { parentId = SpanId.FromString(entry.Value); } else if (string.Equals(entry.Key, SpanIdName, StringComparison.OrdinalIgnoreCase)) { spanId = SpanId.FromString(entry.Value); } else if (string.Equals(entry.Key, FlagsName, StringComparison.OrdinalIgnoreCase)) { if (string.Equals(entry.Value, "1", StringComparison.OrdinalIgnoreCase)) { flags |= SpanContextFlags.Debug; } } } if (traceId != null && spanId != null) { return(new SpanContext(traceId.Value, spanId.Value, parentId, flags)); } return(null); }
public SpanContext(TraceId traceId, SpanId spanId, SpanId parentId, SpanContextFlags flags) : this(traceId, spanId, parentId, flags, EmptyBaggage, debugId : null) { }
public SpanContext WithFlags(SpanContextFlags flags) { return(new SpanContext(TraceId, SpanId, ParentId, flags, Baggage, DebugId)); }