Skip to content

disable/trim MetricsHandler when System.Diagnostics.Metrics.Meter.IsSupported is false#114326

Merged
pavelsavara merged 24 commits into
dotnet:mainfrom
pavelsavara:browser_MetricsHandler_optional
Apr 15, 2025
Merged

disable/trim MetricsHandler when System.Diagnostics.Metrics.Meter.IsSupported is false#114326
pavelsavara merged 24 commits into
dotnet:mainfrom
pavelsavara:browser_MetricsHandler_optional

Conversation

@pavelsavara

@pavelsavara pavelsavara commented Apr 7, 2025

Copy link
Copy Markdown
Member
  • use System.Diagnostics.Metrics.Meter.IsSupported to disable/trim MetricsHandler
  • use System.Net.Http.EnableActivityPropagation to disable/trim DiagnosticsHandler

- use System.Diagnostics.Metrics.Meter.IsSupported
- call EventSource.EnableActivityTracker() when DiagnosticsHandler is enabled
@pavelsavara pavelsavara added this to the 10.0.0 milestone Apr 7, 2025
@pavelsavara pavelsavara self-assigned this Apr 7, 2025
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

@ManickaP

ManickaP commented Apr 7, 2025

Copy link
Copy Markdown
Member

cc @antonfirsov

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 11 out of 15 changed files in this pull request and generated 2 comments.

Files not reviewed (4)
  • src/libraries/System.Net.Http/src/ILLink/ILLink.Substitutions.xml: Language not supported
  • src/libraries/System.Net.Http/tests/FunctionalTests/System.Net.Http.Functional.Tests.csproj: Language not supported
  • src/libraries/System.Private.CoreLib/src/ILLink/ILLink.Descriptors.EventSource.xml: Language not supported
  • src/mono/sample/wasm/browser-advanced/Wasm.Advanced.Sample.csproj: Language not supported

Comment thread src/libraries/System.Net.Http/src/System/Net/Http/DiagnosticsHandler.cs Outdated
Comment thread src/libraries/System.Net.Http/src/System/Net/Http/DiagnosticsHandler.cs Outdated
pavelsavara and others added 2 commits April 7, 2025 17:22
…andler.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…andler.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>

@javiercn javiercn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

Comment thread src/libraries/System.Net.Http/src/System/Net/Http/DiagnosticsHandler.cs Outdated

@antonfirsov antonfirsov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the PR ensure that the SocketsHttpHandlerMetrics and the ConnectionMetrics types are also trimmed away when metrics are disabled?

Comment thread src/libraries/System.Net.Http/src/System/Net/Http/DiagnosticsHandler.cs Outdated
Comment thread src/libraries/System.Net.Http/src/System/Net/Http/DiagnosticsHandler.cs Outdated
@pavelsavara

pavelsavara commented Apr 11, 2025

Copy link
Copy Markdown
Member Author

I added tests. Trimming doesn't work. The constant is not being propagated. I don't know why.

Fixed. It works when there are no indirections between the trimmed property and methods that use them

# Conflicts:
#	src/libraries/System.Net.Http/src/System/Net/Http/GlobalHttpSettings.cs
@pavelsavara pavelsavara requested a review from antonfirsov April 11, 2025 09:32
Comment thread src/libraries/System.Net.Http/src/System/Net/Http/GlobalHttpSettings.cs Outdated

@antonfirsov antonfirsov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM modulo small suggestion. Thanks!

Edit: Just noticed MetricsHandlerTrimmedTest.cs is failing, will check this again after the fix.

pavelsavara and others added 2 commits April 15, 2025 08:18
…andler/ConnectionPool/HttpConnectionWaiter.cs

Co-authored-by: Anton Firszov <antonfir@gmail.com>
@pavelsavara pavelsavara merged commit d0e6ce8 into dotnet:main Apr 15, 2025
@pavelsavara pavelsavara deleted the browser_MetricsHandler_optional branch April 15, 2025 12:07
@github-actions github-actions Bot locked and limited conversation to collaborators May 16, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants