Skip to content

Commit

Permalink
Merge branch 'master' into tiktoken_opt_in
Browse files Browse the repository at this point in the history
  • Loading branch information
sentrivana authored Jul 15, 2024
2 parents a1b35d8 + 84a2afc commit 42c7c3b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion sentry_sdk/integrations/pymongo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import copy
import json

import sentry_sdk
from sentry_sdk.consts import SPANSTATUS, SPANDATA, OP
Expand Down Expand Up @@ -154,7 +155,7 @@ def started(self, event):
if not should_send_default_pii():
command = _strip_pii(command)

query = "{}".format(command)
query = json.dumps(command, default=str)
span = sentry_sdk.start_span(
op=OP.DB,
description=query,
Expand Down
8 changes: 4 additions & 4 deletions tests/integrations/pymongo/test_pymongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ def test_transactions(sentry_init, capture_events, mongo_server, with_pii):
assert insert_success["tags"]["db.operation"] == "insert"
assert insert_fail["tags"]["db.operation"] == "insert"

assert find["description"].startswith("{'find")
assert insert_success["description"].startswith("{'insert")
assert insert_fail["description"].startswith("{'insert")
assert find["description"].startswith('{"find')
assert insert_success["description"].startswith('{"insert')
assert insert_fail["description"].startswith('{"insert')

assert find["tags"][SPANDATA.DB_MONGODB_COLLECTION] == "test_collection"
assert insert_success["tags"][SPANDATA.DB_MONGODB_COLLECTION] == "test_collection"
Expand Down Expand Up @@ -117,7 +117,7 @@ def test_breadcrumbs(sentry_init, capture_events, mongo_server, with_pii):
(crumb,) = event["breadcrumbs"]["values"]

assert crumb["category"] == "query"
assert crumb["message"].startswith("{'find")
assert crumb["message"].startswith('{"find')
if with_pii:
assert "1" in crumb["message"]
else:
Expand Down

0 comments on commit 42c7c3b

Please sign in to comment.