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

aiohttp-client: Allow overriding of span status #1393

Closed
nils-borrmann-y42 opened this issue Oct 20, 2022 · 2 comments · Fixed by #1394
Closed

aiohttp-client: Allow overriding of span status #1393

nils-borrmann-y42 opened this issue Oct 20, 2022 · 2 comments · Fixed by #1394
Labels
bug Something isn't working

Comments

@nils-borrmann-y42
Copy link
Contributor

nils-borrmann-y42 commented Oct 20, 2022

Version 0.34b0

In the aiohttp-client instrumentation, the response_hook is called before setting the status and the status_code of the span. This means the user cannot set a custom status on the span, as it will be immediately overridden by the default value.

In my specific usecase I am making requests as a cache, where a cache-miss returns a 404 response. These spans are than tagged with the StatusCode.ERROR, which is a bit annoying to me as these responses are completely expected and accepted. Therefore I would like to override the StatusCode on those requests in the response_hook.

I am happy to provide a fix for this.

What is the expected behavior?
reponse_hook should be called after setting the span status, to allow for overriding it.

What is the actual behavior?
reponse_hook is called before setting the span status

Additional context
I compared this with the httpx and requests instrumentation. In those instrumentations, overriding the status in the hook is possible.

@srikanthccv
Copy link
Member

@nils-borrmann-y42
Copy link
Contributor Author

It's because the semantic conventions enforce it for the HTTP clients open-telemetry/opentelemetry-specification@main/specification/trace/semantic_conventions/http.md#status.

Which is fine, but otel could still let the user decide to override it in specific cases (which is what most other implementations already do).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants