Skip to content

Commit 27d68c4

Browse files
0Caloriesarjenzorgdoc
authored andcommitted
ref(pymongo): Remove redundant command name in query description (getsentry#3189)
The query command is already included as the first key within the command JSON, so query spans end up having the command twice in the desription.
1 parent d3b72e9 commit 27d68c4

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

sentry_sdk/integrations/pymongo.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def started(self, event):
155155
if not should_send_default_pii():
156156
command = _strip_pii(command)
157157

158-
query = "{} {}".format(event.command_name, command)
158+
query = "{}".format(command)
159159
span = sentry_sdk.start_span(op=op, description=query)
160160

161161
for tag, value in tags.items():

tests/integrations/pymongo/test_pymongo.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,9 @@ def test_transactions(sentry_init, capture_events, mongo_server, with_pii):
7171
assert insert_success["tags"]["db.operation"] == "insert"
7272
assert insert_fail["tags"]["db.operation"] == "insert"
7373

74-
assert find["description"].startswith("find {")
75-
assert insert_success["description"].startswith("insert {")
76-
assert insert_fail["description"].startswith("insert {")
74+
assert find["description"].startswith("{'find")
75+
assert insert_success["description"].startswith("{'insert")
76+
assert insert_fail["description"].startswith("{'insert")
7777
if with_pii:
7878
assert "1" in find["description"]
7979
assert "2" in insert_success["description"]
@@ -113,7 +113,7 @@ def test_breadcrumbs(sentry_init, capture_events, mongo_server, with_pii):
113113
(crumb,) = event["breadcrumbs"]["values"]
114114

115115
assert crumb["category"] == "query"
116-
assert crumb["message"].startswith("find {")
116+
assert crumb["message"].startswith("{'find")
117117
if with_pii:
118118
assert "1" in crumb["message"]
119119
else:

0 commit comments

Comments
 (0)