Skip to content

Commit

Permalink
Add db.system data to redis db spans (#2038)
Browse files Browse the repository at this point in the history
  • Loading branch information
AbhiPrasad authored Apr 25, 2023
1 parent feed2d8 commit 727a3d1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion sentry_sdk/integrations/redis.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from __future__ import absolute_import

from sentry_sdk import Hub
from sentry_sdk.consts import OP
from sentry_sdk.consts import OP, SPANDATA
from sentry_sdk.hub import _should_send_default_pii
from sentry_sdk.utils import (
SENSITIVE_DATA_SUBSTITUTE,
Expand Down Expand Up @@ -63,6 +63,7 @@ def sentry_patched_execute(self, *args, **kwargs):
"redis.commands",
{"count": len(self.command_stack), "first_ten": commands},
)
span.set_data(SPANDATA.DB_SYSTEM, "redis")

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

Expand Down
4 changes: 3 additions & 1 deletion tests/integrations/redis/test_redis.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import mock

from sentry_sdk import capture_message, start_transaction
from sentry_sdk.consts import SPANDATA
from sentry_sdk.integrations.redis import RedisIntegration

from fakeredis import FakeStrictRedis
Expand Down Expand Up @@ -53,7 +54,8 @@ def test_redis_pipeline(sentry_init, capture_events, is_transaction):
"redis.commands": {
"count": 3,
"first_ten": ["GET 'foo'", "SET 'bar' 1", "SET 'baz' 2"],
}
},
SPANDATA.DB_SYSTEM: "redis",
}
assert span["tags"] == {
"redis.transaction": is_transaction,
Expand Down
4 changes: 3 additions & 1 deletion tests/integrations/rediscluster/test_rediscluster.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import pytest
from sentry_sdk import capture_message
from sentry_sdk.consts import SPANDATA
from sentry_sdk.api import start_transaction
from sentry_sdk.integrations.redis import RedisIntegration

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

0 comments on commit 727a3d1

Please sign in to comment.