New and improved kestrel.connection.duration
tags: error.type
and protocol error
#56164
Labels
api-approved
API was approved in API review, it can be implemented
area-networking
Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions
Background and Motivation
See #53358. We want
error.type
to provide a low-cardinality reason for why a connection was closed in error scenarios.Proposed API
kestrel.connection.duration
is a histogram counter. A timer starts when a connection starts, and the timer ends and is recorded when the connection ends. Because of this, there is the opportunity to provide information about why the connection ended.I propose two changes:
http.connection.protocol_error_code
. An issue to discuss on OTEL semantic conventions: Addhttp.connection.protocol_error_code
to connection duration metric open-telemetry/semantic-conventions#1135. If the tag likely won't be standardized, then it could be prefixed withkestrel.
.error.type
tag to the close reason.error.type
isn't set for non-error reasons, e.g. the transport closing.error.type
reason will mostly come from the HTTP layer, but HTTPS middleware can set a status if the connection failed the HTTPS handshakeerror.type
value then it takes priority over the reason (basically, the first value set toerror.type
is what's used)error.type
follow the standard OTEL naming standard for enums: snake case. e.g.app_shutdown
.error.type
value of_OTHER
(similar to other OTEL enums that have a set range of values).Usage Examples
Someone wants to monitor incoming HTTP connections to the server.
kestrel.connection.duration
to seeerror.type
values.Alternative Designs
The connection end reason could also always be set to its own tag, e.g.
kestrel.connection.end_reason
. In that case, it could include non-error values. However, there are few non-error connection end reasons. And error reasons would also be set toerror.type
. It doesn't seem valuable to me to have both tags when people are likely focused on connection errors.kestrel.connection.end_reason
could be added in the future if there is demand for it.Risks
Ensure that Kestrel tags match future OTEL semantic conventions around connections.
The text was updated successfully, but these errors were encountered: