psycopg connection context manager drops X-Ray tracing wrapper, so cursor execute calls are not traced
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 68/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- aws, python
- Lĩnh vực
- observability
Hướng nghiên cứu
Bắt đầu với phần tích hợp psycopg xoay quanh patch() và XRayTracedConn, sau đó tái hiện luồng with conn as c: được mô tả trong issue. Hoàn thành khi kết nối được truyền vào vẫn được bọc, cursor của nó được trace và execute() tạo ra subsegment cơ sở dữ liệu native mà không cần instrumentation thủ công.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- Python
- Star
- 340
- Fork
- 148
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của aws/aws-xray-sdk-python
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 1/100
aws/aws-xray-sdk-python#460 ·
-
Next releaseĐang mở
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 20/100
aws/aws-xray-sdk-python#457 · 1 reaction ·
-
mysql-connector 9.2.0 - TypeError: 'MySQLConnection' object is not iterableCó thể đã có người làm @reginaldalfret đã nhận 20 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
aws/aws-xray-sdk-python#453 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
aws/aws-xray-sdk-python#452 · 1 reaction ·
-
Bug: XRay SDK doesn't support pg8000 native driverCó thể làm lại được @leandrodamascena đã nhận 632 ngày trước và không có pull request nào đang mở. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
aws/aws-xray-sdk-python#451 · 2 bình luận · 1 reaction ·
Tất cả issue của aws/aws-xray-sdk-python
Issue tương tự
-
good first issue
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
btclib-org/btclib-node#1955 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation v0.9.2
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 72/100
khuisman/mcp-gee-sweet#1033 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
ossf/cve-bin-tool#5966 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 2 ngày
-
write_iceberg ignores the table's write.parquet.compression-codec propertyCó thể đã có người làm @YuangGao đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Eventual-Inc/Daft#7606 ·
Maintainer thường phản hồi trong vòng 1 ngày