open-telemetry / open-telemetry/opentelemetry-python-contrib
Add query blacklist for database instrumentations (similar to exclude_urls for server instrumentors)
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 1.1k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 16
Description
I have a service that uses aiopg, aiohttp-client and aiohttp-server instrumentations. I have a middleware in aiohttp to generate the server traces. I want to be able to prevent the aiopg auto-instrumentation from generating traces for specific queries, or if the query is being run when there is no parent trace (avoid having aiopg traces at the top level).
Is your feature request related to a problem?
I have a health endpoint which runs SELECT 1 to check the database connectivity from time to time. I want to be able to bypass that. I can skip it in the middleware, but the aiopg instrumentation will still pick it up.
Describe the solution you'd like
Queries are traced only if there is a parent trace present. Otherwise they are just discarded.
Describe alternatives you've considered
Skipping specific queries. This has a lot of drawbacks but may be potentially simpler to implement.
Additional context
Queries inside of python are rarely at the top level. Normally there is something else wrapping that: A standalone process, some kind of entrypoint, an http server. A flag to generate traces only if there is a parent trace would provide a lot of flexibility.
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 examining the aiopg instrumentation and how aiohttp-server handles its exclude_urls configuration. Trace how database queries are recorded with and without a parent trace, including the health-check SELECT 1 case. Done means queries without a parent trace can be discarded and the requested query-filtering behavior is covered by tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, python
- Domain
- database
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100