open-telemetry / open-telemetry/opentelemetry-python-contrib
Use NonRecordingSpan for disabling instrumentation
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 1.1k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 16
Description
Is your feature request related to a problem?
Adding excluded URLs for instrumentation does not prevent child span from sending. E.g. we have a health endpoint that checks the DB connection using the "select 1;" query. Adding "health" to excluded URLs removes HTTP span from tracing but DB instrumentation still creates span without root.
Describe the solution you'd like
Disabling instrumentation (e.g. for excluded URLs ) should create NonRecordingSpan instead of not creating span at all.
Describe alternatives you've considered
Implement "suppest instrumentation" key for all instrumentations, but that seems unlikely. This also means that inside the health-check method, we need to add "suppest instrumentation" manually. NonRecordingSpan seems a much better option.
Additional context
We are using aiohttp, flask and fastapi servers and sqlalchemy orm. We are open to contributing if maintainers would accept with feature.
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 by tracing how excluded URLs disable instrumentation in the aiohttp, Flask, and FastAPI integrations, then inspect how SQLAlchemy instrumentation obtains its parent span. Confirm the intended OpenTelemetry behavior for a NonRecordingSpan and identify tests covering excluded URLs. Done means excluded requests provide a non-recording context so child database spans are not exported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- fastapi, flask, python, sqlalchemy
- Domain
- backend, observability
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100