diff --git a/sentry_sdk/integrations/redis.py b/sentry_sdk/integrations/redis.py index 3deae7483b..5c035e833d 100644 --- a/sentry_sdk/integrations/redis.py +++ b/sentry_sdk/integrations/redis.py @@ -191,6 +191,8 @@ def sentry_patched_execute_command(self, name, *args, **kwargs): description = description[: integration.max_data_size - len("...")] + "..." with hub.start_span(op=OP.DB_REDIS, description=description) as span: + span.set_data("db.system", "redis") + span.set_tag("redis.is_cluster", is_cluster) if name: diff --git a/tests/integrations/redis/test_redis.py b/tests/integrations/redis/test_redis.py index 657ba1527f..0267d1f940 100644 --- a/tests/integrations/redis/test_redis.py +++ b/tests/integrations/redis/test_redis.py @@ -61,6 +61,23 @@ def test_redis_pipeline(sentry_init, capture_events, is_transaction): } +def test_span_otel_data(sentry_init, capture_events): + sentry_init( + integrations=[RedisIntegration()], + traces_sample_rate=1.0, + ) + events = capture_events() + + connection = FakeStrictRedis() + with start_transaction(): + connection.set("somekey", 123) + + (event,) = events + (span,) = event["spans"] + assert "db.system" in span["data"] + assert span["data"]["db.system"] == "redis" + + def test_sensitive_data(sentry_init, capture_events): # fakeredis does not support the AUTH command, so we need to mock it with mock.patch(