Skip to content

Commit d1ec928

Browse files
authored
Handle empty statement in psycopg instrumentation
Fixes #2643
1 parent 58a6d3a commit d1ec928

File tree

1 file changed

+2
-1
lines changed
  • instrumentation/opentelemetry-instrumentation-psycopg/src/opentelemetry/instrumentation/psycopg

1 file changed

+2
-1
lines changed

instrumentation/opentelemetry-instrumentation-psycopg/src/opentelemetry/instrumentation/psycopg/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,8 @@ def get_operation_name(self, cursor, args):
269269
if isinstance(statement, Composed):
270270
statement = statement.as_string(cursor)
271271

272-
if isinstance(statement, str):
272+
# `statement` can be empty string. See #2643
273+
if isinstance(statement, str) and statement != "":
273274
# Strip leading comments so we get the operation name.
274275
return self._leading_comment_remover.sub("", statement).split()[0]
275276

0 commit comments

Comments
 (0)