Skip to content

HTTP/3: Eliminate near-zero "wait for connection" telemetry signals #114083

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 15 commits into from
Apr 25, 2025

Conversation

antonfirsov
Copy link
Member

@antonfirsov antonfirsov commented Mar 31, 2025

We should only emit wait for connection activities, metrics and events when (1) there is no HTTP/3 connection (2) OpenOutboundStreamAsync() is expected to wait for available streams. When there is a usable connection in the pool, emitting near-zero spans is not consistent with telemetry for other HTTP versions and adds noise.

Fixes #104783.

@antonfirsov antonfirsov added this to the 10.0.0 milestone Mar 31, 2025
@antonfirsov antonfirsov requested review from ManickaP, a team and Copilot March 31, 2025 21:30
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.

Pull Request Overview

This pull request refactors the "wait for connection" telemetry logic for HTTP/3, ensuring such telemetry is only emitted for new connections where OpenOutboundStreamAsync() is expected to wait.

  • Updated test cases in MetricsTest.cs and DiagnosticsTests.cs to reflect the new telemetry behavior.
  • Refactored Http3Connection.SendAsync and associated telemetry tracking via a new WaitForHttp3ConnectionActivity structure.
  • Adjusted HttpConnectionPool.Http3.cs to integrate the new telemetry mechanism and removed obsolete timestamp parameters.

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/libraries/System.Net.Http/tests/FunctionalTests/MetricsTest.cs Added a test to ensure queue time is measured only for the first connection.
src/libraries/System.Net.Http/tests/FunctionalTests/DiagnosticsTests.cs Updated expected telemetry count in diagnostics tests.
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/Http3Connection.cs Refactored SendAsync to use WaitForHttp3ConnectionActivity and updated telemetry logic.
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectionPool/HttpConnectionWaiter.cs Added a comment to clarify custom telemetry behavior for HTTP/3 connections.
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectionPool/HttpConnectionPool.Http3.cs Switched to the new telemetry mechanism and removed obsolete parameters.
src/libraries/System.Net.Http/src/System/Net/Http/SocketsHttpHandler/ConnectionPool/ConnectionSetupDistributedTracing.cs Exposed a new method to check for telemetry listeners.

This comment was marked as outdated.

Copy link
Member

@ManickaP ManickaP left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!
:shipit:
If you don't merge it byt the end of the day because you're already OOF, I'll merge it myself.

@ManickaP
Copy link
Member

@pavelsavara Seems like your new test in https://github.com/dotnet/runtime/blob/main/src/libraries/System.Net.Http/tests/TrimmingTests/MetricsHandlerTrimmedTest.cs is failing on this PR. Would be able to help with resolving it?

@pavelsavara
Copy link
Member

Would be able to help with resolving it?

Probably the new code keeps the metrics classes alive.

You can run the test and see which dependencies are doing it by looking at artifacts\bin\trimmingTests\projects\System.Net.Http.TrimmingTests\MetricsHandlerTrimmedTest\win-x64\obj\Release\net10.0\win-x64\linked\linker-dependencies.xml

I suspect that the new code in WaitForHttp3ConnectionActivity is touching Settings._metrics without GlobalHttpSettings.MetricsHandler.IsGloballyEnabled guard. The trimmer is not very smart.

@pavelsavara
Copy link
Member

.\dotnet.cmd build src\libraries\System.Net.Http\tests\TrimmingTests\System.Net.Http.TrimmingTests.proj -c Release /p:TestTrimming=true

@antonfirsov
Copy link
Member Author

The trimmer issue should be fixed by cf00150. Good that #114326 included all the types in the trimming tests!

@antonfirsov
Copy link
Member Author

/azp run runtime-libraries-coreclr outerloop

Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@ManickaP ManickaP merged commit 87bf42d into dotnet:main Apr 25, 2025
78 of 93 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators May 25, 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.

[H/3] Distributed Tracing / Telemetry
3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy