open-telemetry / open-telemetry/opentelemetry-python-contrib
Psycopg2Instrumentor doesn't work for cursors with non-default cursor_factory
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 1.1k
- Forks
- 1.1k
- Avg merge
- 4d 15h
- Merged PRs (30d)
- 16
Description
When wrapping the connection, the default cursor_factory is set for the connection, but the connection is returned as is rather than a proxy. Therefore, when a cursor is created with the connection_factory argument passed, the instrumentation does not happen.
Steps to reproduce
Set up the Psycopg2Instrumentor, create a cursor passing the cursor_factory argument, and run a query.
What is the expected behavior?
Spans produced/exported
What is the actual behavior?
No spans produced/exported
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
Inspect the linked psycopg2 instrumentation code in instrumentation/opentelemetry-instrumentation-psycopg2/src/opentelemetry/instrumentation/psycopg2/init.py, especially lines 126-141, and reproduce the case using a cursor_factory argument. Done means queries made through that cursor produce and export spans, matching the expected behavior described in the issue.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, python
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100