Expose wrapHandlersPipeline parameter in AddExtendedHttpClientLogging API#7231
Merged
Expose wrapHandlersPipeline parameter in AddExtendedHttpClientLogging API#7231
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR exposes the wrapHandlersPipeline parameter in the AddExtendedHttpClientLogging API, allowing callers to control whether the HTTP logging handler wraps the entire handler pipeline or is placed at the point of invocation. This addresses issue #5744 where latency context was being lost when retrieved outside the handlers pipeline, and implements the API proposal from issue #5924.
Changes:
- Added three new overloads to
AddExtendedHttpClientLoggingthat accept abool wrapHandlersPipelineparameter, matching the design of the runtime'sAddLoggermethod - Added comprehensive tests verifying that latency information is correctly populated with both
wrapHandlersPipeline: trueandfalsevalues - Updated the internal implementation to pass the
wrapHandlersPipelineparameter through to theAddLoggercall
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| src/Libraries/Microsoft.Extensions.Http.Diagnostics/Logging/HttpClientLoggingHttpClientBuilderExtensions.cs | Adds three new public API overloads with wrapHandlersPipeline parameter and updates internal implementation to accept and pass through this parameter |
| test/Libraries/Microsoft.Extensions.Http.Diagnostics.Tests/Latency/HttpClientLatencyTelemetryExtensionsTest.cs | Adds four new tests verifying latency info population with different parameter combinations and when latency telemetry is not configured |
...icrosoft.Extensions.Http.Diagnostics/Logging/HttpClientLoggingHttpClientBuilderExtensions.cs
Show resolved
Hide resolved
...icrosoft.Extensions.Http.Diagnostics/Logging/HttpClientLoggingHttpClientBuilderExtensions.cs
Show resolved
Hide resolved
...icrosoft.Extensions.Http.Diagnostics/Logging/HttpClientLoggingHttpClientBuilderExtensions.cs
Show resolved
Hide resolved
...rosoft.Extensions.Http.Diagnostics.Tests/Latency/HttpClientLatencyTelemetryExtensionsTest.cs
Outdated
Show resolved
Hide resolved
…ency/HttpClientLatencyTelemetryExtensionsTest.cs Co-authored-by: Copilot <[email protected]>
...icrosoft.Extensions.Http.Diagnostics/Logging/HttpClientLoggingHttpClientBuilderExtensions.cs
Show resolved
Hide resolved
...icrosoft.Extensions.Http.Diagnostics/Logging/HttpClientLoggingHttpClientBuilderExtensions.cs
Show resolved
Hide resolved
...icrosoft.Extensions.Http.Diagnostics/Logging/HttpClientLoggingHttpClientBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
...rosoft.Extensions.Http.Diagnostics.Tests/Latency/HttpClientLatencyTelemetryExtensionsTest.cs
Outdated
Show resolved
Hide resolved
...rosoft.Extensions.Http.Diagnostics.Tests/Latency/HttpClientLatencyTelemetryExtensionsTest.cs
Outdated
Show resolved
Hide resolved
...rosoft.Extensions.Http.Diagnostics.Tests/Latency/HttpClientLatencyTelemetryExtensionsTest.cs
Show resolved
Hide resolved
...rosoft.Extensions.Http.Diagnostics.Tests/Latency/HttpClientLatencyTelemetryExtensionsTest.cs
Outdated
Show resolved
Hide resolved
...icrosoft.Extensions.Http.Diagnostics/Logging/HttpClientLoggingHttpClientBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
...icrosoft.Extensions.Http.Diagnostics/Logging/HttpClientLoggingHttpClientBuilderExtensions.cs
Show resolved
Hide resolved
...aries/Microsoft.Extensions.Http.Diagnostics.Tests/Logging/HttpClientLoggingExtensionsTest.cs
Show resolved
Hide resolved
evgenyfedorov2
approved these changes
Feb 10, 2026
...icrosoft.Extensions.Http.Diagnostics/Logging/HttpClientLoggingHttpClientBuilderExtensions.cs
Show resolved
Hide resolved
...icrosoft.Extensions.Http.Diagnostics/Logging/HttpClientLoggingHttpClientBuilderExtensions.cs
Show resolved
Hide resolved
...aries/Microsoft.Extensions.Http.Diagnostics.Tests/Logging/HttpClientLoggingExtensionsTest.cs
Outdated
Show resolved
Hide resolved
...aries/Microsoft.Extensions.Http.Diagnostics.Tests/Logging/HttpClientLoggingExtensionsTest.cs
Show resolved
Hide resolved
iliar-turdushev
approved these changes
Feb 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As per following API review, these changes allow you to control the wrapHandlersPipeline variable in the AddExtendedHttpClientLogging API. This should fix a bug in which latency context is getting lost when retrieved outside a handlers pipeline
Microsoft Reviewers: Open in CodeFlow