Skip to content

Commit

Permalink
Add db.system to the span data for mongo db. (#2042)
Browse files Browse the repository at this point in the history
  • Loading branch information
antonpirker authored Apr 27, 2023
1 parent 06381de commit bc55cd3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sentry_sdk/integrations/pymongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import copy

from sentry_sdk import Hub
from sentry_sdk.consts import SPANDATA
from sentry_sdk.hub import _should_send_default_pii
from sentry_sdk.integrations import DidNotEnable, Integration
from sentry_sdk.tracing import Span
Expand Down Expand Up @@ -119,10 +120,11 @@ def started(self, event):
except TypeError:
pass

data = {"operation_ids": {}} # type: Dict[str, Dict[str, Any]]
data = {"operation_ids": {}} # type: Dict[str, Any]

data["operation_ids"]["operation"] = event.operation_id
data["operation_ids"]["request"] = event.request_id
data[SPANDATA.DB_SYSTEM] = "mongodb"

try:
lsid = command.pop("lsid")["id"]
Expand Down
2 changes: 2 additions & 0 deletions tests/integrations/pymongo/test_pymongo.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from sentry_sdk import capture_message, start_transaction
from sentry_sdk.consts import SPANDATA
from sentry_sdk.integrations.pymongo import PyMongoIntegration, _strip_pii

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

Expand Down

0 comments on commit bc55cd3

Please sign in to comment.