-
Notifications
You must be signed in to change notification settings - Fork 798
Labels
bugSomething isn't workingSomething isn't working
Description
Describe your environment
opentelemetry-instrumentation-psycopg2==0.45b0
psycopg2-binary==2.9.9
Steps to reproduce
Use Psycopg2Instrumentor().instrument_connection
. For example:
import psycopg2
from opentelemetry.instrumentation.psycopg2 import Psycopg2Instrumentor
connection = psycopg2.connect(database='database', user='user', password='secret', host='0.0.0.0', port=5432)
Psycopg2Instrumentor().instrument_connection(connection)
and run a database with:
docker run --name postgres \
-e POSTGRES_USER=user \
-e POSTGRES_PASSWORD=secret \
-e POSTGRES_DB=database \
-p 5432:5432 -d postgres
What is the actual behavior?
Traceback (most recent call last):
File "test.py", line 6, in <module>
Psycopg2Instrumentor().instrument_connection(connection)
File "/home/alex/work/logfire/.venv/lib/python3.12/site-packages/opentelemetry/instrumentation/psycopg2/__init__.py", line 164, in instrument_connection
connection._is_instrumented_by_opentelemetry = False
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'psycopg2.extensions.connection' object has no attribute '_is_instrumented_by_opentelemetry'
Additional context
Here's where the error happens:
Line 164 in 46d2ce6
connection._is_instrumented_by_opentelemetry = False |
The code seems tested here:
Line 210 in 46d2ce6
cnx = Psycopg2Instrumentor().instrument_connection(cnx) |
but it doesn't get the error because it's a mock connection.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working