Skip to content

Starlette instrumentation can have ordering issues #3476

Open
@anuraaga

Description

@anuraaga

Currently, starlette instrumentation uses a class override pattern which can have ordering issues that cause autoinstrumentation to not apply.

https://github.com/open-telemetry/opentelemetry-python-contrib/blob/main/instrumentation/opentelemetry-instrumentation-starlette/src/opentelemetry/instrumentation/starlette/__init__.py#L287

In practice, I see most users manually instrument the app because of this, for example here

https://github.com/YunosukeY/otel-and-a2a-sample/blob/main/server.py#L47

I think it should be possible to switch to wrapping the __init__ method without replacement which can usually solve such ordering issues.

/cc @xrmx was interested in this (I hope :) )

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions