opentelemetry-dotnet-contrib
opentelemetry-dotnet-contrib copied to clipboard
HttpClient not setting error message when using CancellationToken
Component
OpenTelemetry.Instrumentation.Http
Package Version
Package Name | Version |
---|---|
OpenTelemetry.Api | 1.8.0 |
OpenTelemetry | 1.8.0 |
Runtime Version
net8.0
Description
HttpClient supports using the CancellationToken to cancel requests in-flight. The current implementation of the HttpHandlerDiagnosticListener will set an error status in OnStopActivity if the request was canceled and the comments specify that it relies on the OnException handler to set the span status and description. However, when using CancellationToken the OnException handler will not be raised (presumably because the TaskCanceledException that is triggered by a cancellation is already handled and does not bubble up to the OnException handler as you would expect). This means that telemetry exported will have an error status set, but there will be no error message or exception available on the span.
Steps to Reproduce
- Execute a long-running HTTP call via HttpClient
- Use the CancellationToken to cancel the request before it completes
Expected Result
I would expect to see some information regarding the nature of the error. It might not be needed to include the TaskCanceledException's full stacktrace here as that exception is 'by design', but there should at least be some feedback available on the span to indicate why the status was set to error.
Actual Result
There is no message or exception available
Additional Context
No response