This repository was archived by the owner on Jan 23, 2023. It is now read-only.
Inject W3C headers in HTTP diagnostics handler#35882
Merged
vancem merged 4 commits intodotnet:masterfrom Mar 11, 2019
Merged
Conversation
davidsh
reviewed
Mar 8, 2019
| var diagnosticListenerObserver = new FakeDiagnosticListenerObserver(kvp => | ||
| { | ||
| if (kvp.Key.Equals("System.Net.Http.Request")) | ||
| { requestLogged = true; } |
Contributor
There was a problem hiding this comment.
This is not standard bracing style for CoreFx.
vancem
reviewed
Mar 8, 2019
| request.Headers.Add(DiagnosticsHandlerLoggingStrings.TraceStateHeaderName, currentActivity.TraceStateString); | ||
| } | ||
| } | ||
| else if(!request.Headers.Contains(DiagnosticsHandlerLoggingStrings.RequestIdHeaderName)) |
There was a problem hiding this comment.
Do you want the 'if' condition to have two terms in it?
As it is if the ID format is W3C AND you already have a TraceParent header, you ALSO try to add a RequestId header.
This is not what I would have expected. Feels like what you want is
if (currentActivity.IdFormat == ActivityIdFormat.W3C)
{
if (request.Headers.Contains(DiagnosticsHandlerLoggingStrings.TraceParentHeaderName))
{
request.Headers.Add(DiagnosticsHandlerLoggingStrings.TraceParentHeaderName, currentActivity.Id);
if (currentActivity.TraceStateString != null)
{
request.Headers.Add(DiagnosticsHandlerLoggingStrings.TraceStateHeaderName, currentActivity.TraceStateString);
}
}
}
else // Not W3C Format
{
if(!request.Headers.Contains(DiagnosticsHandlerLoggingStrings.RequestIdHeaderName))
{
request.Headers.Add(DiagnosticsHandlerLoggingStrings.RequestIdHeaderName, currentActivity.Id);
}
}
added 2 commits
March 8, 2019 12:15
vancem
approved these changes
Mar 11, 2019
|
This change, if you ignore the testing changes, is quite small and simply propagating the new W3C ids into HTTP headers. It is doing the analogous thing to what was done before or previous (hierarachical) IDs. This is new behavior that should be back-compat. Unless someone raises an objection I will merge this later today. |
picenka21
pushed a commit
to picenka21/runtime
that referenced
this pull request
Feb 18, 2022
* Inject W3C headers in corefx Htpp Diagnostics HAndler * Inject W3C headers if activity format is W3C * fix style and indentation * review: fix issue Commit migrated from dotnet/corefx@7314001
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depending on the Activity.IdFormat we want to inject W3C distributed tracing headers or Request-Id headers.