Repository navigation
[dotnet] Fix emitting of trace log messages from http client handler - #17069
Conversation
PR TypeBug fix Description
|
| Relevant files | |||
|---|---|---|---|
| Bug fix |
|
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||||
There was a problem hiding this comment.
Pull request overview
Updates the .NET HttpCommandExecutor HTTP pipeline so that trace-level HTTP request/response logging can be enabled (or disabled) at runtime via Log.SetLevel(...), instead of being decided only when the HttpClient is first created.
Changes:
- Always wraps the underlying
HttpClientHandlerwithDiagnosticsHttpHandlerinCreateHttpClient(). - Moves trace logging work in
DiagnosticsHttpHandler.SendAsync()behind runtime_logger.IsEnabled(LogEventLevel.Trace)checks (for both request and response).
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
dotnet/src/webdriver/Remote/HttpCommandExecutor.cs:259
- In CreateHttpClient(), the local
handlervariable is now always overwritten, and the wrapper is constructed withhttpClientHandlerinstead of the currenthandler. This is redundant today, and it also makes it easy to accidentally bypass additional handler wrapping added later. Consider either removing thehandlervariable entirely, or wrap the currenthandler(nothttpClientHandler).
HttpMessageHandler handler = new DiagnosticsHttpHandler(httpClientHandler, _logger);
var client = new HttpClient(handler);
client.DefaultRequestHeaders.UserAgent.ParseAdd(this.UserAgent);
Fixes the following issue:
💥 What does this PR do?
Always wrap default http client handler for remote commands execution by our special client handler, which always treats current log level in runtime.
🔄 Types of changes