Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sentry_sdk/integrations/pymongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ def started(self, event: "CommandStartedEvent") -> None:
span_first_data = {
"db.operation.name": operation_name,
"db.collection.name": collection_name,
SPANDATA.DB_QUERY_TEXT: query,
"sentry.op": OP.DB,
"sentry.origin": PyMongoIntegration.origin,
**db_data,
Expand Down
4 changes: 4 additions & 0 deletions tests/integrations/pymongo/test_pymongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,9 @@ def test_segment_span_streaming(sentry_init, capture_items, mongo_server, with_p
assert insert_success["attributes"]["db.collection.name"] == "test_collection"
assert insert_fail["attributes"]["db.collection.name"] == "erroneous"

for span in find, insert_success, insert_fail:
assert span["attributes"][SPANDATA.DB_QUERY_TEXT] == span["name"]

if with_pii:
assert "1" in find["name"]
assert "2" in insert_success["name"]
Expand Down Expand Up @@ -247,6 +250,7 @@ def test_breadcrumbs_span_streaming(sentry_init, capture_items, mongo_server, wi
assert data["db.driver.name"] == "pymongo"
assert data["db.operation.name"] == "find"
assert data["db.collection.name"] == "test_collection"
assert data["db.query.text"] == crumb["message"]
assert data["sentry.op"] == "db"
assert data["sentry.origin"] == "auto.db.pymongo"
assert data[SPANDATA.SERVER_ADDRESS] == "localhost"
Expand Down
Loading