Closed
Description
While we include a decent amount of information about a request in the RequestStart
event, we provide almost no information about what happened with the response (outside of timestamps/latency info for various steps during a request).
void RequestStart(string scheme, string host, int port, string pathAndQuery, byte versionMajor, byte versionMinor, HttpVersionPolicy versionPolicy);
void RequestFailed();
We've heard from customers moving from .NET Framework where they could get information like the response status code from the System.Diagnostics.Eventing.FrameworkEventSource
provider, e.g.:
GetResponseStart
id: 9223372032565852628
uri: https://httpbin.org/ip
success: True
synchronous: False
GetResponseStop
id: 9223372032565852628
success: True
synchronous: False
statusCode: 200
I propose we include more information on the following (existing) System.Net.Http
events:
- Status code on
RequestStop
.-void RequestStop() +void RequestStop(int statusCode)
- Status code on
ResponseHeadersStop
.ResponseHeadersStop
in addition toRequestStop
because we may not have a status code available inRequestStop
in failure cases, and because a singleRequestStart
may span multiple actual requests internally due to redirects (or custom user handler logic such as retries). Having a status code on theRequestStop
is still valuable for users that just care about the result of the HttpClient call, without diving into details of what happened as part of that call. See 003e675#r103790748 for more discussion about this.-void ResponseHeadersStop() +void ResponseHeadersStop(int statusCode)
- Exception message & stack trace on
RequestFailed
.If we decide on an error code system as part of [API Proposal]: Support error codes for HttpRequestException #76644, we could include that information as a second parameter, or we could rely on the error code becoming a part of the-void RequestFailed(); +void RequestFailed(string exception);
HttpRequestException
's message. @antonfirsov is including theHttpRequestError
in the message string something you've considered?
The remaining set of potential improvements is now tracked by #85729.