-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Consume DistributedContextPropagator APIs in DiagnosticsHandler #55392
Conversation
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change. |
Tagging subscribers to this area: @dotnet/ncl Issue DetailsOpening the PR early to avoid blocking on the official implementation of #50658.
Side effects:
No-merge: Fixes #35337 cc: @tarekgh @noahfalk @shirhatti
|
Just FYI, #55384 is another PR touching |
3d2d361
to
f893939
Compare
Updated to use the actual implementation now that #55419 is merged. |
src/libraries/System.Diagnostics.DiagnosticSource/tests/PropagatorTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http/src/System/Net/Http/DiagnosticsHandler.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http/src/System/Net/Http/BrowserHttpHandler/SocketsHttpHandler.cs
Show resolved
Hide resolved
src/libraries/System.Net.Http/tests/FunctionalTests/DiagnosticsTests.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http/src/System/Net/Http/DiagnosticsHandler.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http/src/System/Net/Http/HttpClientHandler.cs
Outdated
Show resolved
Hide resolved
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.
LGTM
@@ -58,6 +86,16 @@ internal static bool IsEnabled() | |||
throw new ArgumentNullException(nameof(request), SR.net_http_handler_norequest); | |||
} | |||
|
|||
// Since we are reusing the request message instance on redirects, clear any existing headers | |||
// Do so before writing DiagnosticListener events as instrumentations use those to inject headers | |||
if (request.WasRedirected() && _propagatorFields is HeaderDescriptor[] fields) |
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.
As I recall OpenTelemetry defines Fields as a hint about which fields would be inspected but not a guarantee. In particular they left the door open that some protocol would have field names dynamically determined so it would be impossible to provide an exhaustive list. Of course in practice I am not aware of any propagator implementation that does this.
If we want to do this we should probably clarify in our API comments that our definition of Fields is strict and we don't support the dynamic shenanigans that OT left the door open to.
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.
If we want to do this we should probably clarify in our API comments that our definition of Fields is strict and we don't support the dynamic shenanigans that OT left the door open to.
That would be my preference.
I can't think of a different approach that wouldn't break some scenarios. For example doing the check inside the setter callback and removing the header there instead is too late since instrumentations like AI/Otel may try to add headers before us - we really have to clear the headers in advance.
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.
@tarekgh - making sure you see this : )
09e7902
to
aa21a9a
Compare
aa21a9a
to
0828c85
Compare
0828c85
to
c6bd75e
Compare
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.
LGTM!
@@ -9,6 +9,7 @@ | |||
using System.Security.Cryptography.X509Certificates; | |||
using System.Threading; | |||
using System.Threading.Tasks; | |||
using System.Diagnostics; |
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.
using System.Diagnostics; | |
using System.Diagnostics; | |
|
cc: @CarnaViire |
…debugger_custom_views * 'main' of github.com:thaystg/runtime: (125 commits) [wasm] [debugger] Support method calls (dotnet#55458) [debugger] Fix debugging after hot reloading (dotnet#55599) Inliner: Extend IL limit for profiled call-sites, allow inlining for switches. (dotnet#55478) DiagnosticSourceEventSource supports base class properties (dotnet#55613) [mono] Fix race during mono_image_storage_open (dotnet#55201) [mono] Add wrapper info for native func wrappers. (dotnet#55602) H/3 and Quic AppContext switch (dotnet#55332) Compression.ZipFile support for Unix Permissions (dotnet#55531) [mono] Fix skipping of static methods during IMT table construction. (dotnet#55610) Combine System.Private.Xml TrimmingTests projects (dotnet#55606) fix name conflict with Configuration class (dotnet#55597) Finish migrating RSAOpenSsl from RSA* to EVP_PKEY* Disable generic math (dotnet#55540) Obsolete CryptoConfig.EncodeOID (dotnet#55592) Address System.Net.Http.WinHttpHandler's nullable warnings targeting .NETCoreApp (dotnet#54995) Enable Http2_MultipleConnectionsEnabled_ConnectionLimitNotReached_ConcurrentRequestsSuccessfullyHandled (dotnet#55572) Fix Task.WhenAny failure mode when passed ICollection of zero tasks (dotnet#55580) Consume DistributedContextPropagator in DiagnosticsHandler (dotnet#55392) Add property ordering feature (dotnet#55586) Reduce subtest count in Reflection (dotnet#55537) ...
InjectHeaders
logic inDiagnosticsHandler
with a call toDistributedContextPropagator.Inject
which adds a lot of configurability to the userPassThroughPropagator
or a custom propagator addresses Add an option to HttpClient's default DiagnosticHandler so that it does not create an Activity #41072NoOutputPropagator
addresses HttpClient automatically adds Request-Id HTTP header #35337DiagnosticsHandler
into theSocketsHttpHandler
handler chainSocketsHttpHandler
instances Customized SocketsHttpHandler does not support diagnostics tracking #31261DiagnosticsHandler
beforeRedirectHandler
lights up propagation for redirect requests HttpHandlerDiagnosticListener does not send second chain of events if the request was autoredirected on netfx in W3C mode #40777Side effects:
DiagnosticsHandler
intoSocketsHttpHandler
, any custom instance lights up for distributed tracing when moving to 6.0 by defaultNoOutputPropagator
or theActivityHeadersPropagator
property on the handler)SocketsHttpHandler
instance was created on its own / withinHttpClientHandler
.Fixes #35337
Fixes #41072
Fixes #40777
Fixes #31261
Fixes #55556
cc: @tarekgh @noahfalk @shirhatti