-
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
Missing overrides in LoggingHttpMessageHandler and LoggingScopeHttpMessageHandler #85143
Conversation
Tagging subscribers to this area: @dotnet/ncl Issue Detailsadd missing overrides in LoggingHttpMessageHandler and LoggingScopeHttpMessageHandler (#85104)
|
@dotnet-policy-service agree |
src/libraries/Microsoft.Extensions.Http/src/Logging/LoggingHttpMessageHandler.cs
Outdated
Show resolved
Hide resolved
@mphelt thanks for your contribution! |
I've added them, but I didn't thought of it initially, as none of the base classes has those conditions - how are they different? @Wraith2 |
var shouldRedactHeaderValue = _options?.ShouldRedactHeaderValue ?? _shouldNotRedactHeaderValue; | ||
|
||
// Not using a scope here because we always expect this to be at the end of the pipeline, thus there's | ||
// not really anything to surround. | ||
Log.RequestStart(_logger, request, shouldRedactHeaderValue); | ||
var stopwatch = ValueStopwatch.StartNew(); | ||
var response = base.Send(request, cancellationToken); | ||
Log.RequestEnd(_logger, response, stopwatch.GetElapsedTime(), shouldRedactHeaderValue); | ||
|
||
return response; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we deduplicate this logic between Send
and SendAsync
(same for LoggingScopeHttpMessageHandler
)?
E.g. by extracting it to a helper method
private async Task<HttpResponseMessage> SendAsyncCore(HttpRequestMessage request, bool async, CancellationToken cancellationToken)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a few comments regarding the code style used in this repo, otherwise looks good, thanks.
Unfortunately I had to add #if NET5_0_OR_GREATER directives inside useAsync ? ... : ... - is there a cleaner way to do that?
I think it's okay as-is.
src/libraries/Microsoft.Extensions.Http/src/Logging/LoggingHttpMessageHandler.cs
Outdated
Show resolved
Hide resolved
src/libraries/Microsoft.Extensions.Http/src/Logging/LoggingHttpMessageHandler.cs
Outdated
Show resolved
Hide resolved
src/libraries/Microsoft.Extensions.Http/src/Logging/LoggingHttpMessageHandler.cs
Outdated
Show resolved
Hide resolved
src/libraries/Microsoft.Extensions.Http/src/Logging/LoggingHttpMessageHandler.cs
Outdated
Show resolved
Hide resolved
src/libraries/Microsoft.Extensions.Http/src/Logging/LoggingScopeHttpMessageHandler.cs
Outdated
Show resolved
Hide resolved
src/libraries/Microsoft.Extensions.Http/src/Logging/LoggingScopeHttpMessageHandler.cs
Outdated
Show resolved
Hide resolved
src/libraries/Microsoft.Extensions.Http/src/Logging/LoggingScopeHttpMessageHandler.cs
Outdated
Show resolved
Hide resolved
src/libraries/Microsoft.Extensions.Http/src/Logging/LoggingScopeHttpMessageHandler.cs
Outdated
Show resolved
Hide resolved
It's because previously only .NET Standard 2.0 API surface was used, which includes only async send: https://learn.microsoft.com/en-us/dotnet/api/system.net.http.delegatinghandler.sendasync?view=netstandard-2.0 -- because Microsoft.Extensions.Http is compiled for .NET Standard 2.0.
This would be adding the helper method to the public surface, which should go through API review process: https://github.com/dotnet/runtime/blob/main/docs/project/api-review-process.md |
@CarnaViire, thank you for explanation. Is there any way to re-run those failing checks? They seem to have failed for reasons not connected to this particular PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks!
Test failure is unrelated #85772 |
add missing overrides in LoggingHttpMessageHandler and LoggingScopeHttpMessageHandler
Fixes #85104