コード例 #1
0
        public SpanContext Extract <T>(T carrier, Func <T, string, IEnumerable <string> > getter)
        {
            if (carrier == null)
            {
                throw new ArgumentNullException(nameof(carrier));
            }

            if (getter == null)
            {
                throw new ArgumentNullException(nameof(getter));
            }

            var traceId = PropagationHelpers.ParseTraceId(carrier, getter, B3HttpHeaderNames.B3TraceId, Log);

            if (traceId == TraceId.Zero)
            {
                // a valid traceId is required to use distributed tracing
                return(null);
            }

            var spanId           = ParseHexUInt64(carrier, getter, B3HttpHeaderNames.B3SpanId);
            var samplingPriority = ParseB3Sampling(carrier, getter);

            return(new SpanContext(traceId, spanId, samplingPriority));
        }
コード例 #2
0
 public static string ParseString(this IHeadersCollection headers, string headerName)
 {
     return(PropagationHelpers.ParseString(headers, (carrier, header) => carrier.GetValues(header), headerName));
 }