Skip to content
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

Handle empty statement in psycopg instrumentation #2644

Merged
merged 6 commits into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#2612](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2612))
- `opentelemetry-instrumentation-system-metrics` Permit to use psutil 6.0+.
([#2630](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2630))
- `opentelemetry-instrumentation-psycopg` Bugfix: Handle empty statement. ([#2644](https://github.com/open-telemetry/opentelemetry-python-contrib/pull/2644))
xrmx marked this conversation as resolved.
Show resolved Hide resolved

### Added

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,8 @@ def get_operation_name(self, cursor, args):
if isinstance(statement, Composed):
statement = statement.as_string(cursor)

if isinstance(statement, str):
# `statement` can be empty string. See #2643
xrmx marked this conversation as resolved.
Show resolved Hide resolved
if isinstance(statement, str) and statement != "":
xrmx marked this conversation as resolved.
Show resolved Hide resolved
# Strip leading comments so we get the operation name.
return self._leading_comment_remover.sub("", statement).split()[0]

Expand Down