-
Notifications
You must be signed in to change notification settings - Fork 660
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
Refactor TracedConnectionProxy #1097
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9467bd0
to
7455ba9
Compare
lzchen
reviewed
May 26, 2022
...tion/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/__init__.py
Show resolved
Hide resolved
...tion/opentelemetry-instrumentation-dbapi/src/opentelemetry/instrumentation/dbapi/__init__.py
Outdated
Show resolved
Hide resolved
lzchen
approved these changes
Jun 7, 2022
Closed
ocelotl
added a commit
that referenced
this pull request
Feb 10, 2023
ocelotl
added a commit
to ocelotl/opentelemetry-python-contrib
that referenced
this pull request
Feb 10, 2023
Several issues have arisen from this bugfix, reverting here until a better solution can be found. Fixes open-telemetry#1658
ocelotl
added a commit
to ocelotl/opentelemetry-python-contrib
that referenced
this pull request
Feb 10, 2023
Several issues have arisen from this bugfix, reverting here until a better solution can be found. Fixes open-telemetry#1658
ocelotl
added a commit
to ocelotl/opentelemetry-python-contrib
that referenced
this pull request
Feb 12, 2023
Several issues have arisen from this bugfix, reverting here until a better solution can be found. Fixes open-telemetry#1658
shalevr
added a commit
to shalevr/opentelemetry-python-contrib
that referenced
this pull request
Feb 23, 2023
…/github.com/shalevr/opentelemetry-python-contrib into Change-metrics-tests-to-work-with-test_base * 'Change-metrics-tests-to-work-with-test_base' of https://github.com/shalevr/opentelemetry-python-contrib: Fix issue with Flask instrumentation when a request spawn children threads and copies the request context (open-telemetry#1654) Add connection attributes to sqlalchemy connect span (open-telemetry#1608) Add boto3sqs to docs (open-telemetry#1666) Audit and test opentelemetry-instrumentation-elasticsearch NoOpTracer… (open-telemetry#1616) Copy change log updates from release/v1.16.x-0.37bx (open-telemetry#1683) Update version to 1.17.0.dev/0.38b0.dev (open-telemetry#1677) Fix CI Failure (open-telemetry#1680) Add better debugging if hatch subprocess fails (open-telemetry#1672) Add confluent kafka docs (open-telemetry#1668) Support aio_pika 9 (open-telemetry#1670) Audit and test opentelemetry-instrumentation-wsgi NoOpTracerProvider (open-telemetry#1610) bot (open-telemetry#1667) Add commit method for ConfluentKafkaInstrumentor's ProxiedConsumer (open-telemetry#1656) Revert open-telemetry#1097 (open-telemetry#1660) Audit and test opentelemetry-instrumentation-django NoOpTracerProvider (open-telemetry#1611) Audit and test opentelemetry-instrumentation-aiohttp-client NoOpTrace… (open-telemetry#1612) Audit and test opentelemetry-instrumentation-flask NoOpTracerProvider (open-telemetry#1614) Audit and test opentelemetry-instrumentation-dbapi NoOpTracerProvider (open-telemetry#1607)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1077
Fixing this issue is a bit complicated:
Here it is suggested that we may monkey patch the
register_types
function instead of wrapping the connection/cursor. The problem with this approach is that it may be necessary to do this kind of patching in private modules of the Psycopg2 library that may change paths unexpectedly (since they are private), causing our instrumentation to be breakable with any release of Psycopg2.@owais suggests here that we should patch the classes themselves instead of wrapping to avoid problems with type checking. I understand the point but I think this approach also has the problem that it may require importing from private modules to patch effectively.
The particular issue here happens because
PyObject_TypeCheck
is used in Psycopg2register_types
and this type checking implemented in C is more restrictive thanisinstance
(wrapt.ObjectProxy
objects passes anisinstance
check against the type of the wrapped object).The solution implemented here is able to pass the
PyObject_TypeCheck
because the connection created dynamically inherits from the class of the original connection, somethingwrapt.ObjectProxy
does not.