psycopg connection context manager drops X-Ray tracing wrapper, so cursor execute calls are not traced
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 68/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- aws, python
- Ambito
- observability
Direzione di ricerca
Inizia con l’integrazione di psycopg intorno a patch() e XRayTracedConn, quindi riproduci il flusso with conn as c: descritto nell’issue. Il lavoro è completato quando la connessione inserita rimane avvolta, il suo cursore viene tracciato ed execute() produce il sottosegmento nativo del database senza strumentazione manuale.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
I am seeing a gap in the psycopg integration for aws-xray-sdk.
When patching psycopg succeeds, psycopg.connect() returns an XRayTracedConn proxy as expected. However, if the connection is used as a context manager with with conn as c:, the object returned from enter is the raw psycopg Connection, not the X-Ray wrapper. As a result, c.cursor(...) returns a raw psycopg Cursor, and execute() calls do not produce X-Ray subsegments.
Observed behavior
patch(("psycopg",), raise_errors=True) succeeds
psycopg.connect() returns aws_xray_sdk.ext.dbapi2.XRayTracedConn
entering the connection context manager unwraps the proxy
cursor() on that entered object returns psycopg.Cursor
execute() on the cursor is not traced
if I create an explicit subsegment manually, that subsegment appears in X-Ray, which confirms the request has a valid segment and the DB code path is running
Expected behavior
The psycopg X-Ray wrapper should preserve tracing across the connection context manager
with conn as c: should still return a wrapped connection, or otherwise ensure cursors created from the entered object are still traced
execute() should generate the native DB subsegment without needing manual instrumentation
Reproduction
Install aws-xray-sdk 2.15.0
Install psycopg 3.3.4 and psycopg-pool 3.2.7
Call patch(("psycopg",), raise_errors=True)
Call psycopg.connect(...)
Use the connection in a with block
Create a cursor and execute a query
Observe that the cursor is raw psycopg.Cursor and no DB subsegment is emitted
Environment details
aws-xray-sdk 2.15.0
psycopg 3.3.4
psycopg-pool 3.2.7
Python 3.12
Running in AWS Lambda
- Lingua principale
- Python
- Stelle
- 339
- Fork
- 147
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Guida per i contributori
Apri la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di aws/aws-xray-sdk-python
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 1/100
aws/aws-xray-sdk-python#460 ·
-
Next release Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 20/100
aws/aws-xray-sdk-python#457 · 1 reazione ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
aws/aws-xray-sdk-python#453 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
aws/aws-xray-sdk-python#452 · 1 reazione ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
aws/aws-xray-sdk-python#451 · 2 commenti · 1 reazione ·
Tutte le issue di aws/aws-xray-sdk-python
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
stephrobert/dsoxlab#238 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
sublimehq/package_control#1780 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
nwg-piotr/nwg-displays#145 ·