-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Add standard tags to HttpClient native trace instrumentation #104251
Conversation
src/libraries/System.Net.Http/src/System/Net/Http/DiagnosticsHandler.cs
Outdated
Show resolved
Hide resolved
@antonfirsov - Are you planning to add support for this? |
@antonfirsov @vishweshbankwar are there plans to add a feature in the runtime or OTel SDK to enable enrichment of the activity? Using a custom |
@vishweshbankwar does that text mean that the tags should be passed to |
That part would stay same. |
@joegoldman2 enrichment capability will be hopefully added to System.Net.Http in .NET 10. The OTel SDK already exposes callbacks for for that. |
My goals for getting this in (without Enrichment) is so that the instrumentation libraries are not needed for the basic scenarios, especially being able to do auto-instrumentation out of process via EventPipe, such as with .NET Monitor. In that scenario, we want the Activities to have the OTel data directly on them, so when its collected, it has everything that is needed. In that scenario, the application will not have referenced the OTel libraries or setup OTel etc. |
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/DiagnosticsHandler.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/DiagnosticsHandler.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.
This looks pretty good to me. A couple things to consider called out in comments inline. Thanks @antonfirsov!
src/libraries/System.Net.Http/tests/UnitTests/DiagnosticsHelperTest.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http/src/System/Net/Http/DiagnosticsHandler.cs
Outdated
Show resolved
Hide resolved
Thanks for the additional context! |
src/libraries/System.Net.Http/src/System/Net/Http/DiagnosticsHandler.cs
Outdated
Show resolved
Hide resolved
🥇 Thanks! Just noticed: could we also set display name to method? (the one in the
|
@lmolkova does that count as a breaking change? |
src/libraries/System.Net.Http/tests/FunctionalTests/DiagnosticsTests.cs
Outdated
Show resolved
Hide resolved
The OperationName is still the same, but more importantly - did anyone use plain HTTP client instrumentation before? Adding @vishweshbankwar in case he has any thoughts. |
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
Agree with @lmolkova. In general, I have only seen OperationName being used in older SDKs which won't be impacted with this. |
OTel instrumentation library would continue to exist and provide enrichment/filtering. In terms of implementation, it will no longer need to set tags/status on activity. |
/azp run runtime-libraries-coreclr outerloop |
Azure Pipelines successfully started running 1 pipeline(s). |
…otnet#104251)" This reverts commit c7fa446.
Add the following standard tags to the HTTP Request Activities started in DelegatingHandler:
Stable attributes not being added for now, they are not being included by the OTel SDK either:
Just like in #103769,
url.full
is being redacted by removing UserInfo and the query string, while exposing aSystem.Net.Http.DisableQueryRedaction
switch for opting-out from the latter. This is equivalent to the built-in redaction of OTel SDK, except that the query string is being replaced by a single*
instead of replacing values only (key1=*&key2=*
), since this is more performant.Given that the vast majority of current users of HttpClient's distributed tracing relies on the OTel SDK, this redaction technique should not regress those users. In .NET 10 we plan to implement something configurable.
Contributes to #93019, except the enrichment and the propagator aspects which are no longer realistic to address for .NET 9.
@vishweshbankwar note that this is breaking the SDK, since it should now conditionally compile against .NET 9+ so it doesn't double job adding tags. PTAL if it meets your expectations.
cc @samsp-msft @noahfalk
PS: For Aspire dashboard output see #104251 (comment)