Trim more Http DiagnosticsHandler code#39525
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
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. |
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: