open-telemetry / open-telemetry/opentelemetry-python-contrib
Starlette instrumentation can have ordering issues
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 1.1k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 16
Description
Currently, starlette instrumentation uses a class override pattern which can have ordering issues that cause autoinstrumentation to not apply.
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 :) )
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in instrumentation/opentelemetry-instrumentation-starlette/src/opentelemetry/instrumentation/starlette/init.py around line 287 and inspect the current class override pattern. Compare it with the proposed approach of wrapping init without replacement, using the linked server.py example as context. Done means autoinstrumentation applies reliably despite ordering, reducing the need for manual instrumentation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- observability
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100