diff --git a/instrumentation/opentelemetry-instrumentation-psycopg/src/opentelemetry/instrumentation/psycopg/__init__.py b/instrumentation/opentelemetry-instrumentation-psycopg/src/opentelemetry/instrumentation/psycopg/__init__.py index 5d7054151a..4f529ae04a 100644 --- a/instrumentation/opentelemetry-instrumentation-psycopg/src/opentelemetry/instrumentation/psycopg/__init__.py +++ b/instrumentation/opentelemetry-instrumentation-psycopg/src/opentelemetry/instrumentation/psycopg/__init__.py @@ -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 + if isinstance(statement, str) and statement != "": # Strip leading comments so we get the operation name. return self._leading_comment_remover.sub("", statement).split()[0]