-
Notifications
You must be signed in to change notification settings - Fork 689
fixed: asyncpg connection params are a namedtuple #3253
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
Conversation
.../opentelemetry-instrumentation-asyncpg/src/opentelemetry/instrumentation/asyncpg/__init__.py
Outdated
Show resolved
Hide resolved
.../opentelemetry-instrumentation-asyncpg/src/opentelemetry/instrumentation/asyncpg/__init__.py
Show resolved
Hide resolved
Thanks @privatwolke for revisiting this especially with the added test coverage. To get this check to pass, please could you run |
@tammy-baylis-swi - thanks for the quick review! I've updated the PR with the suggested changes and also added additional tests for the |
d9c87a1
to
0059e86
Compare
.../opentelemetry-instrumentation-asyncpg/src/opentelemetry/instrumentation/asyncpg/__init__.py
Show resolved
Hide resolved
Thanks for those! I've added more suggestions and just triggered another ci/cd run. Please have another look. |
2aeb4ad
to
8038c76
Compare
Follow-up on the apparently abbandonned open-telemetry#2114. The asyncpg instrumentation attempts to fall back on using the database name as the span name in case the first argument to the instrumented method is falsey. This has probably never worked since asyncpg defines the `_params` attribute as an instance of `ConnectionParams` (https://github.com/MagicStack/asyncpg/blob/master/asyncpg/connection.py#L62) which is a NamedTuple instance and thus don't define `get`. The proper way of safely accessing properties on a NamedTuple is using `getattr`. The only case that I've actually found which triggers this branch is if the supplied query is an empty string. This is something that causes an `AttributeError` for `Connection.execute` but is fine for `fetch()`, `fetchval()`, `fetchrow()` and `executemany()`. The tests have been expanded to check these cases. Also, more status code validation has been added where it was missing.
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.
Thank you @privatwolke ! Lgtm. We'll need more reviews from a repo Maintainer; feel free to bring this PR up in Slack and/or the Python SIG meeting (every Thurs 9am PT)
@xrmx Thanks for approving this, but I think something went wrong with the automerge. Should I rebase my branch on the base branch? |
Follow-up on the apparently abbandonned #2114.
Closes #2114
Description
The asyncpg instrumentation attempts to fall back on using the database name as the span name in case the first argument to the instrumented method is falsey.
Any attempt to do so results in errors simliar to this (truncated traceback):
This has probably never worked since asyncpg defines the
_params
attribute as an instance ofConnectionParams
(https://github.com/MagicStack/asyncpg/blob/master/asyncpg/connection.py#L62) which is a NamedTuple instance and thus don't define
get
. The proper way of safely accessing properties on a NamedTuple is usinggetattr
.The only case that I've actually found which triggers this branch is if the supplied query is an empty string. This is something that causes an
AttributeError
forConnection.execute
but is fine forfetch()
,fetchval()
,fetchrow()
andexecutemany()
.The tests have been expanded to check these cases. Also, more status code validation has been added where it was missing.
Type of change
Please delete options that are not relevant.
How Has This Been Tested?
Does This PR Require a Core Repo Change?
Checklist:
See contributing.md for styleguide, changelog guidelines, and more.