Skip to content

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

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

Merged
merged 24 commits into from
Apr 15, 2025

Conversation

pavelsavara
Copy link
Member

@pavelsavara pavelsavara commented Apr 7, 2025

  • 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
Copy link
Contributor

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

@ManickaP
Copy link
Member

ManickaP commented Apr 7, 2025

cc @antonfirsov

Copy link
Contributor

@Copilot Copilot AI left a comment

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

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>
Copy link
Member

@javiercn javiercn left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Member

@antonfirsov antonfirsov left a comment

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?

@pavelsavara
Copy link
Member Author

pavelsavara commented Apr 11, 2025

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
Copy link
Member

@antonfirsov antonfirsov left a comment

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
141 of 151 checks passed
@pavelsavara pavelsavara deleted the browser_MetricsHandler_optional branch April 15, 2025 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants