You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
I am also facing this same issue but for creating a cursor using the RealDictCursos cursor factory. cur = client.cursor(cursor_factory=psycopg2.extras.RealDictCursor)
No tracing is being submitted, but when I turn this off for the whole app (and comment out the breaking code now that it's getting tuples) I start seeing my traces appear.
Is there any fix for this or can anyone comment on this issue?
@AlexanderLW, @srikanthccv I have gone through the code. We have to add the {'cursor_factory': psycopg2.extras.RealDictCursor} in connection params.
you must have had conn_params in your code like below.
self._conn_parms = {'host': host, 'post': port, 'username': username, 'password': password, 'cursor_factory': psycopg2.extras.RealDictCursor}
It will fix the issue.
For more details, understand wrapped_connection method in python3.9/site-packages/opentelemetry/instrumentation/psycopg2/init.py
For anyone else that runs into this, I moved the cursor_factory to the connection, and then I had to remove the cursor_factory from any and all cursor declarations. Doing that allowed my traces to appear as I would expect.
opentelemetry-python-contrib/instrumentation/opentelemetry-instrumentation-psycopg2/src/opentelemetry/instrumentation/psycopg2/__init__.py
Lines 126 to 141 in 2ee2cf3
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 theconnection_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
The text was updated successfully, but these errors were encountered: