Exemple #1
0
        private static ProblemDetails AddTracingInfo(ProblemDetails problemDetails, HttpContext httpContext)
        {
            // ids collect in a straightforward manner because we haven't real world data
            var spanId = Activity.Current.SpanId.ToString();

            if (!string.IsNullOrEmpty(spanId))
            {
                problemDetails.AddSpanId(spanId);
            }

            var parentId = Activity.Current.ParentId;

            if (!string.IsNullOrEmpty(parentId))
            {
                problemDetails.AddParentId(parentId);
            }

            var traceId = Activity.Current.RootId;

            if (!string.IsNullOrEmpty(traceId))
            {
                problemDetails.AddTraceId(traceId);
            }

            var requestId = httpContext.TraceIdentifier;

            if (!string.IsNullOrEmpty(requestId))
            {
                problemDetails.AddRequestId(requestId);
            }

            problemDetails = AddExtensions(problemDetails, Activity.Current.Baggage.Select(kvp => (kvp.Key, (object)kvp.Value)));

            return(problemDetails);
        }