publicHttpContextFactory(IServiceProvider serviceProvider) { _defaultHttpContextFactory = new DefaultHttpContextFactory(serviceProvider); }
public HttpContext Create(IFeatureCollection featureCollection) { var context = _defaultHttpContextFactory.Create(featureCollection);
// If request header has traceparent, it follows the W3C Trace Context specification. // Else we generate traceparent from X--TraceId. if (context.Request.Headers.ContainsKey("traceparent")) { context.Items["Has-W3C-Trace-Context"] = true; return context; }
context.Items["Has-W3C-Trace-Context"] = false;
if (!context.Request.Headers.TryGetValue("X-TraceId", outvar traceId)) { return context; }
if (!Guid.TryParse(traceId, CultureInfo.InvariantCulture, outvar _)) { return context; }
if (!context.Request.Headers.TryGetValue("X-RequestId", outvar requestId)) { return context; }
if (!Guid.TryParse(requestId, CultureInfo.InvariantCulture, outvar _)) { return context; }