Skip to content

Commit a6cd497

Browse files
committed
opentelemetry-instrumentation-sqlalchemy: Fix exception on empty query
1 parent 21a35b6 commit a6cd497

File tree

1 file changed

+3
-3
lines changed
  • instrumentation/opentelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy

1 file changed

+3
-3
lines changed

instrumentation/opentelemetry-instrumentation-sqlalchemy/src/opentelemetry/instrumentation/sqlalchemy/engine.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,9 @@ def _operation_name(self, db_name, statement):
239239
# For some very special cases it might not record the correct statement if the SQL
240240
# dialect is too weird but in any case it shouldn't break anything.
241241
# Strip leading comments so we get the operation name.
242-
parts.append(
243-
self._leading_comment_remover.sub("", statement).split()[0]
244-
)
242+
split_query = self._leading_comment_remover.sub("", statement).split()
243+
if split_query:
244+
parts.append(split_query[0])
245245
if db_name:
246246
parts.append(db_name)
247247
if not parts:

0 commit comments

Comments
 (0)