-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Trim more Http DiagnosticsHandler code #39525
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
Conversation
I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly one area label. |
Tagging subscribers to this area: @dotnet/ncl |
I like 4c690ff better as the prefered outcome is to have no trace of DiagnosticsHandler in the binary |
Question about 4c690ff: it creates the |
I don't believe so. That's the behavior change that I mentioned in the above summary:
If we still wanted to take that approach, I believe we can address this by splitting runtime/src/libraries/System.Net.Http/src/System/Net/Http/DiagnosticsHandler.cs Lines 26 to 31 in a366d63
Thoughts? |
I like it! It addresses the problem while it keeps the original behavior. 👍 |
Since the DiagnosticsHandler still gets instantiated in the HttpClientHandler, none of its overriden methods are getting trimmed. This leads to System.Diagnostics.DiagnosticListener still being preserved in a linked application. This fix is split DiagnosticsHandler.IsEnabled() into two methods: * IsGloballyEnabled() - checks the AppContext switch, and is replaced by the linker by a feature swtich. * IsEnabled() - which checks IsGloballyEnabled() and if there is an Activity or listener available. This allows all but the IsEnabled and IsGloballyEnabled methods to get trimmed on DiagnosticsHandler. Contributes to dotnet#38765
67a3fa2
to
9b09ad7
Compare
@ManickaP - I've updated the PR to use the above proposal. Let me know what you think. |
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, thanks.
Since the DiagnosticsHandler still gets instantiated in the HttpClientHandler, none of its overriden methods are getting trimmed. This leads to System.Diagnostics.DiagnosticListener still being preserved in a linked application. The fix is to split DiagnosticsHandler.IsEnabled() into two methods: * IsGloballyEnabled() - checks the AppContext switch, and is replaced by the linker by a feature swtich. * IsEnabled() - which checks IsGloballyEnabled() and if there is an Activity or listener available. This allows all but the IsEnabled and IsGloballyEnabled methods to get trimmed on DiagnosticsHandler. Contributes to dotnet#38765
Since the DiagnosticsHandler still gets instantiated in the HttpClientHandler, none of its overriden methods are getting trimmed. This leads to System.Diagnostics.DiagnosticListener still being preserved in a linked application.
This fix is split DiagnosticsHandler.IsEnabled() into two methods:
This allows all but the IsEnabled and IsGloballyEnabled methods to get trimmed on DiagnosticsHandler.
Contributes to #38765
This allows for ~20KB savings in the default Blazor WASM template app: