Skip to content
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

Allow listening to TaskCanceled exceptions on HTTP client instrumentation #1793

Open
tiagonapoli opened this issue Oct 25, 2021 · 2 comments
Labels
comp:instrumentation.http Things related to OpenTelemetry.Instrumentation.Http enhancement New feature or request

Comments

@tiagonapoli
Copy link

Feature Request

Is your feature request related to a problem?

I would like to add custom tags when timeouts happen on clients using the auto instrumentation, but currently when a HTTP Request is canceled and the request fails neither OnStopActivity nor OnException are called using the options.Enrich hook.

It seems this happens because when a Task is canceled the onStopActivity is called (and it handles tasks canceled):
https://github.com/open-telemetry/opentelemetry-dotnet/blob/884b224508351a65ab260c404fad5e25b341db97/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs#L160-L178

And since there is no response the onStopActivity will not be called:
https://github.com/open-telemetry/opentelemetry-dotnet/blob/884b224508351a65ab260c404fad5e25b341db97/src/OpenTelemetry.Instrumentation.Http/Implementation/HttpHandlerDiagnosticListener.cs#L180-L198

Describe the solution you'd like:

Maybe OnStopActivity or OnException could be called signaling the timeout?

@tiagonapoli tiagonapoli added the enhancement New feature or request label Oct 25, 2021
@tiagonapoli tiagonapoli changed the title Allow listening to TaskCanceled exceptions on HTTP requests Allow listening to TaskCanceled exceptions on HTTP client instrumentation Oct 25, 2021
@iliar-turdushev
Copy link

We've got a similar ask. We adopted OpenTelemetry.Instrumentation.Http 1.0.0-rc9.14 and EnrichWithHttpRequestMessage, EnrichWithHttpResponseMessage, and EnrichWithException to populate custom tags. We were using handlers EnrichWithHttpResponseMessage or EnrichWithException to execute some "final" logic supposed to be executed at request's end. But since none of these handlers were executed when a request was cancelled (timed out) we ended up with activities that didn't contain data being populated at request's end.

Executing either EnrichWithHttpResponseMessage or EnrichWithException when a request is cancelled (timed out) would solve our problem.

cc @dpk83

@dpk83
Copy link

dpk83 commented Apr 24, 2023

@cijothomas @reyang

@vishweshbankwar vishweshbankwar transferred this issue from open-telemetry/opentelemetry-dotnet May 14, 2024
@Kielek Kielek added the comp:instrumentation.http Things related to OpenTelemetry.Instrumentation.Http label May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:instrumentation.http Things related to OpenTelemetry.Instrumentation.Http enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants