Skip to content

Commit bc55cd3

Browse files
authored
Add db.system to the span data for mongo db. (getsentry#2042)
1 parent 06381de commit bc55cd3

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

sentry_sdk/integrations/pymongo.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import copy
33

44
from sentry_sdk import Hub
5+
from sentry_sdk.consts import SPANDATA
56
from sentry_sdk.hub import _should_send_default_pii
67
from sentry_sdk.integrations import DidNotEnable, Integration
78
from sentry_sdk.tracing import Span
@@ -119,10 +120,11 @@ def started(self, event):
119120
except TypeError:
120121
pass
121122

122-
data = {"operation_ids": {}} # type: Dict[str, Dict[str, Any]]
123+
data = {"operation_ids": {}} # type: Dict[str, Any]
123124

124125
data["operation_ids"]["operation"] = event.operation_id
125126
data["operation_ids"]["request"] = event.request_id
127+
data[SPANDATA.DB_SYSTEM] = "mongodb"
126128

127129
try:
128130
lsid = command.pop("lsid")["id"]

tests/integrations/pymongo/test_pymongo.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from sentry_sdk import capture_message, start_transaction
2+
from sentry_sdk.consts import SPANDATA
23
from sentry_sdk.integrations.pymongo import PyMongoIntegration, _strip_pii
34

45
from mockupdb import MockupDB, OpQuery
@@ -55,6 +56,7 @@ def test_transactions(sentry_init, capture_events, mongo_server, with_pii):
5556
"net.peer.port": str(mongo_server.port),
5657
}
5758
for span in find, insert_success, insert_fail:
59+
assert span["data"][SPANDATA.DB_SYSTEM] == "mongodb"
5860
for field, value in common_tags.items():
5961
assert span["tags"][field] == value
6062

0 commit comments

Comments
 (0)