Skip to content

Commit 727a3d1

Browse files
authored
Add db.system data to redis db spans (#2038)
1 parent feed2d8 commit 727a3d1

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

sentry_sdk/integrations/redis.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import absolute_import
22

33
from sentry_sdk import Hub
4-
from sentry_sdk.consts import OP
4+
from sentry_sdk.consts import OP, SPANDATA
55
from sentry_sdk.hub import _should_send_default_pii
66
from sentry_sdk.utils import (
77
SENSITIVE_DATA_SUBSTITUTE,
@@ -63,6 +63,7 @@ def sentry_patched_execute(self, *args, **kwargs):
6363
"redis.commands",
6464
{"count": len(self.command_stack), "first_ten": commands},
6565
)
66+
span.set_data(SPANDATA.DB_SYSTEM, "redis")
6667

6768
return old_execute(self, *args, **kwargs)
6869

tests/integrations/redis/test_redis.py

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

33
from sentry_sdk import capture_message, start_transaction
4+
from sentry_sdk.consts import SPANDATA
45
from sentry_sdk.integrations.redis import RedisIntegration
56

67
from fakeredis import FakeStrictRedis
@@ -53,7 +54,8 @@ def test_redis_pipeline(sentry_init, capture_events, is_transaction):
5354
"redis.commands": {
5455
"count": 3,
5556
"first_ten": ["GET 'foo'", "SET 'bar' 1", "SET 'baz' 2"],
56-
}
57+
},
58+
SPANDATA.DB_SYSTEM: "redis",
5759
}
5860
assert span["tags"] == {
5961
"redis.transaction": is_transaction,

tests/integrations/rediscluster/test_rediscluster.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import pytest
22
from sentry_sdk import capture_message
3+
from sentry_sdk.consts import SPANDATA
34
from sentry_sdk.api import start_transaction
45
from sentry_sdk.integrations.redis import RedisIntegration
56

@@ -71,7 +72,8 @@ def test_rediscluster_pipeline(sentry_init, capture_events):
7172
"redis.commands": {
7273
"count": 3,
7374
"first_ten": ["GET 'foo'", "SET 'bar' 1", "SET 'baz' 2"],
74-
}
75+
},
76+
SPANDATA.DB_SYSTEM: "redis",
7577
}
7678
assert span["tags"] == {
7779
"redis.transaction": False, # For Cluster, this is always False

0 commit comments

Comments
 (0)