-
Notifications
You must be signed in to change notification settings - Fork 678
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix psycopg2 instrument_connection AttributeError #3043
base: main
Are you sure you want to change the base?
Fix psycopg2 instrument_connection AttributeError #3043
Conversation
354d085
to
7871734
Compare
7871734
to
fa46143
Compare
fa46143
to
a0c9940
Compare
instrumentation/opentelemetry-instrumentation-psycopg2/tests/test_psycopg2_integration.py
Show resolved
Hide resolved
5bd1e94
to
b591b0a
Compare
instrumentation/opentelemetry-instrumentation-psycopg2/README.rst
Outdated
Show resolved
Hide resolved
Co-authored-by: Riccardo Magliocchetti <[email protected]>
...pentelemetry-instrumentation-psycopg2/src/opentelemetry/instrumentation/psycopg2/__init__.py
Outdated
Show resolved
Hide resolved
...pentelemetry-instrumentation-psycopg2/src/opentelemetry/instrumentation/psycopg2/__init__.py
Show resolved
Hide resolved
|
||
# Save cursor_factory in instrumentor map because | ||
# psycopg2 connection type does not allow arbitrary attrs | ||
self._otel_cursor_factories[connection] = connection.cursor_factory |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't use the set of cursor factories for anything? Don't we need to check if the factory is in the set already or is that part of the TODO? I'd rather have the whole duplicate functionality there or you can leave it for a different PR but remove the set for now since it doesn't seem to be doing anything.
0a1360d
to
680b0f5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find the name of the tests very confusing but yeah, better double spans than a crash I guess
Description
Removes the attempt to set attribute
connection._is_instrumented_by_opentelemetry
becausepsycopg2.extensions.connection
does not allow setting of extra attributes and we getAttributeError
. SimilarAttributeError
also happened with setattr forconnection._otel_orig_cursor_factory
so also removed.Adds todos to re-add checks for connection-already-being-instrumented later, as discussed:
Fixes #2522
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
tox -e py312-test-instrumentation-psycopg2
Psycopg2Instrumentor.instrument_connection
Psycopg2Instrumentor.instrument
Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.