Skip to content

HTTP error inconsistencies in opentelemetry-instrumentation-aiohttp-server #4153

@agroebe

Description

@agroebe

Describe your environment

Package version: Version 0.60b1 of opentelemetry-instrumentation-aiohttp-server

What happened?

All exceptions used for web responses by AIOHTTP server are being transmitted as errors. However, exceptions such as web.HTTPFound are not indicitive of real errors.

For example, the mechanism to implement redirects is to raise a web.HTTPFound exception. More information in the docs: https://docs.aiohttp.org/en/stable/web_quickstart.html#redirects.

I suspect the impact is mostly isolated to this web.HTTPFound exception. However, technically AIOHTTP does expose exceptions for 2xx responses as well.

Steps to Reproduce

Implement a route that uses the web.HTTPFound exception to implement a redirect.

Expected Result

The instrumentation should not be transmitting mere HTTP redirects as errors.

The guidance outlined by the HTTP semantic conventions seem to confirm this intuition: https://opentelemetry.io/docs/specs/semconv/http/http-spans/#status.

Actual Result

The AIOHTTP server instrumentor transmits all instances of web.HTTPException with error semantics. Specifically, status is set on the span.

This can be seen in the source here: https://github.com/open-telemetry/opentelemetry-python-contrib/blob/v0.60b1/instrumentation/opentelemetry-instrumentation-aiohttp-server/src/opentelemetry/instrumentation/aiohttp_server/__init__.py#L440)

Additional context

The behavior of the instrumentation directly contradicts the guidance here:

Span Status MUST be left unset if HTTP status code was in the 1xx, 2xx or 3xx ranges, unless there was another error (e.g., network error receiving the response body; or 3xx codes with max redirects exceeded), in which case status MUST be set to Error.

Instead, it transmits ALL responses, even 2xx and 3xx, with status in the span.

Anecdotally, this is producing thousands of errors in the APM dashboard of our observability tool. However, of course, an HTTP 302 is not actually indicitive of an actual error.

Would you like to implement a fix?

None

Tip

React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it. Learn more here.

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