-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
HttpClientHandler request metrics #87319
Conversation
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change. |
Tagging subscribers to this area: @dotnet/ncl Issue DetailsInitial implementation for request metrics from #84978 doing most of the work in an internal Deviations from the spec in #84978:
Remaining work:
|
src/libraries/System.Net.Http/src/System/Net/Http/MetricsHandler.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http/src/System/Net/Http/MetricsHandler.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http/src/System/Net/Http/MetricsHandler.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http/src/System/Net/Http/MetricsHandler.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http/src/System/Net/Http/MetricsHandler.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http/src/System/Net/Http/Metrics/HttpMetricsEnrichmentContext.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http/src/System/Net/Http/Metrics/HttpMetricsEnrichmentContext.cs
Outdated
Show resolved
Hide resolved
...libraries/System.Net.Http/src/System/Net/Http/Metrics/MetricsHttpRequestOptionsExtensions.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http/src/System/Net/Http/MetricsHandler.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http/src/System/Net/Http/MetricsHandler.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http/src/System/Net/Http/MetricsHandler.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http/src/System/Net/Http/MetricsHandler.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http/src/System/Net/Http/Metrics/HttpMetricsEnrichmentContext.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Net.Http/src/System/Net/Http/Metrics/HttpMetricsEnrichmentContext.cs
Outdated
Show resolved
Hide resolved
@noahfalk @MihaZupan continuing the discussion on perf here. Edit: I made a mistake in my concurrent benchmarks, and had to update them once again, see my next comment with updated results.
Note that this benchmark is an extreme scenario (no actual network IO, very small request/response, no header parsing ...) engineered to make the overhead well-measurable. In real life the differences may become very small. When it comes to the memory footprint of Enrichment, I think the easiest way to reduce it is to address #88750. |
These numbers look perfectly reasonable to me |
…d to avoid (likely environmental) failures on Android
This comment was marked as resolved.
This comment was marked as resolved.
@MihaZupan @noahfalk apologies, I made a mistake in my parallel benchmarks, they were doing stuff synchronously. Copying the updated results below. The overhead resulting from the presence of However, it looks like there is some contention over the pool in this extreme case. IMO it's not significant, should be even less noticeable in real-life cases and worth it bc of the the savings we make on memory footprint. main
PR - no pooling
PR - pooling
|
Thanks @antonfirsov - I'm glad to see there was no appreciable difference in the baseline vs. PR in the NoMetrics case. The revised benchmark also suggests much lower overhead switching from NoMetrics to Metrics which was nice. If networking team + @stephentoub is happy, I'm happy.
Yep I know this is a microbenchmark that is stressing the code at ~1M RPS. I don't imagine real world scenarios look quite that extreme but it does help measure how we impacted things. I could imagine a real world scenario where request latency is in the low ms range and parallelism is very high (>1000 concurrent requests). Although that combination still wouldn't be as stressful as the microbenchmark I'm guessing it could be 100K+ RPS which is not too far off. |
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
1 similar comment
This comment was marked as resolved.
This comment was marked as resolved.
/azp run runtime-extra-platforms |
Azure Pipelines successfully started running 1 pipeline(s). |
CI failures are unrelated, merging to unblock work depending on this. |
Initial implementation for request metrics from #84978 doing most of the work in an internal
MetricsHandler
, assuming API proposals #86281 and #86961 will be approved. Connection metrics shall be implemented asSocketsHttpHandler
internals in a way analogous to existing counters, I plan to do that in a separate PR.Deviations from the spec in #84978:
http-client-request-duration
:protocol
andstatus-code
are optional, since we cannot log them when the underlying handler throws without returning anHttpResponsMessage
http-client-current-requests
: noprotocol
tag, since there is no reliable way to report correct value after downgradeshttp-client-failed-requests
:protocol
is optional for the same reason as with current-requestsstatus-code
is optionally presentexception-name
, tag because it has little value on it's own (only 2 types of top-level exceptions are thrown). Instead, I prefer to add arequest-error
tag based on [API Proposal]: Support error codes for HttpRequestException #76644 when implementing that proposal.Remaining work:
HttpClientHandler
HttpResponseMessage.RequestFailedMetricsLogger
hack. If not, implement it in another way. See HttpClientHandler request metrics #87319 (comment)./cc @JamesNK @noahfalk @dpk83 @stephentoub
Fixes #86281, fixes #86961, contributes to #84978.