Skip to content

aiohttp-client: Allow overriding of span status #1393

@nils-borrmann-y42

Description

@nils-borrmann-y42

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions