-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Inject W3C headers in netfx HTTP diagnostics hook #35880
Conversation
@vancem could you please have a look? |
if (e.MoveNext()) | ||
// do not inject header if it was injected already | ||
// perhaps tracing systems wants to override it | ||
if (request.Headers[TraceParentHeaderName] == null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Above the code uses request.Headers.Get(id)
and here it's using request.Headers[id]
. IIRC, one just calls the other, but is there a reason for the different access pattern?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, no particular reason, thanks for noticing it
StringBuilder baggage = new StringBuilder(); | ||
do | ||
request.Headers.Add(TraceParentHeaderName, activity.Id); | ||
if (activity.TraceStateString != null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Accessing TraceStateString looks like an O(N) operation. Seems like it should be cached into a local rather than accessing it twice, once to check for null and the other to add it.
{ | ||
// do not inject header if it was injected already | ||
// perhaps tracing systems wants to override it | ||
if (request.Headers[RequestIdHeaderName] == null) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Same question/comment about Get vs indexer
* Inject W3C headers in Http Desktop hook * do not inject headers if they were injected before * check that w3c headers are empty when format is Hierarchical * review comments Commit migrated from dotnet/corefx@dee28e2
* Inject W3C headers in Http Desktop hook * do not inject headers if they were injected before * check that w3c headers are empty when format is Hierarchical * review comments Commit migrated from dotnet/corefx@dee28e2
Depending on the Activity.IdFormat we want to inject W3C distributed tracing headers or Request-Id headers.
This change implements this and also prevents injection of any of the correlation headers if it was injected before e.g. by tracing system or explicitly in the app code.