Skip to content

Commit 82d7058

Browse files
committed
ref: Prepend label to SQL span description
1 parent cc68a77 commit 82d7058

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

sentry_sdk/integrations/django/__init__.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,9 @@ def execute(self, sql, params=None):
312312
if hub.get_integration(DjangoIntegration) is None:
313313
return
314314

315-
with record_sql_queries(hub, [format_sql(sql, params, self.cursor)]):
315+
with record_sql_queries(
316+
hub, [format_sql(sql, params, self.cursor)], label="Django: "
317+
):
316318
return real_execute(self, sql, params)
317319

318320
def executemany(self, sql, param_list):
@@ -321,7 +323,9 @@ def executemany(self, sql, param_list):
321323
return
322324

323325
with record_sql_queries(
324-
hub, [format_sql(sql, params, self.cursor) for params in param_list]
326+
hub,
327+
[format_sql(sql, params, self.cursor) for params in param_list],
328+
label="Django: ",
325329
):
326330
return real_executemany(self, sql, param_list)
327331

sentry_sdk/tracing.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -190,14 +190,16 @@ def get_trace_context(self):
190190

191191

192192
@contextlib.contextmanager
193-
def record_sql_queries(hub, queries):
193+
def record_sql_queries(hub, queries, label=""):
194194
if not queries:
195195
yield None
196196
else:
197+
strings = [label]
197198
for query in queries:
198199
hub.add_breadcrumb(message=query, category="query")
200+
strings.append(query)
199201

200-
description = concat_strings(queries)
202+
description = concat_strings(strings)
201203
with hub.span(op="db.statement", description=description) as span:
202204
yield span
203205

0 commit comments

Comments
 (0)