Skip to content

Commit 6450132

Browse files
chore: Replace deprecated db.redis op with db.query (#7967)
1 parent 7ed3e35 commit 6450132

11 files changed

Lines changed: 43 additions & 41 deletions

File tree

‎MIGRATION_GUIDE.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ Span ops are now a smaller, framework-neutral set.
4343

4444
- The OpenAI integration now emits `gen_ai.chat` instead of `gen_ai.responses`.
4545
- The Cohere integration now emits `gen_ai.chat` instead of `ai.chat_completions.create.cohere`, and `gen_ai.embeddings` instead of `ai.embeddings.create.cohere`.
46+
- The Redis integration now emits `db.query` instead of `db.redis`.
4647
- The Django integration now emits `view.render` instead of `view.response.render`, `view` instead of `view.authenticate`, and `function` instead of `event.django`.
4748
- The Django, Starlette, Starlite, and Litestar integrations now emit `middleware` instead of `middleware.django`, `middleware.starlette`, `middleware.starlette.receive`, `middleware.starlette.send`, `middleware.starlite`, `middleware.starlite.receive`, `middleware.starlite.send`, `middleware.litestar`, `middleware.litestar.receive`, and `middleware.litestar.send`.
4849
- The ARQ, Celery, Django, Dramatiq, Huey, RQ, and Ray integrations now emit `queue.publish` and `queue.process` instead of `queue.submit.arq`, `queue.task.arq`, `queue.submit.celery`, `queue.task.celery`, `queue.submit.django`, `queue.task.dramatiq`, `queue.submit.huey`, `queue.task.huey`, `queue.task.rq`, `queue.submit.ray`, and `queue.task.ray`.

‎sentry_sdk/consts.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,6 +1334,7 @@ class OP:
13341334
DB = "db"
13351335
DB_CURSOR_ITERATOR = "db.cursor.iter"
13361336
DB_CURSOR_FETCH = "db.cursor.fetch"
1337+
DB_QUERY = "db.query"
13371338
DB_REDIS = "db.redis"
13381339
EVENT_DJANGO = "event.django"
13391340
FUNCTION = "function"

‎sentry_sdk/integrations/redis/_async_common.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ async def _sentry_execute(self: "Any", *args: "Any", **kwargs: "Any") -> "Any":
5959
name="redis.pipeline.execute",
6060
attributes={
6161
"sentry.origin": SPAN_ORIGIN,
62-
"sentry.op": OP.DB_REDIS,
62+
"sentry.op": OP.DB_QUERY,
6363
},
6464
)
6565

‎sentry_sdk/integrations/redis/_sync_common.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def sentry_patched_execute(self: "Any", *args: "Any", **kwargs: "Any") -> "Any":
5656
name="redis.pipeline.execute",
5757
attributes={
5858
"sentry.origin": SPAN_ORIGIN,
59-
"sentry.op": OP.DB_REDIS,
59+
"sentry.op": OP.DB_QUERY,
6060
},
6161
)
6262

‎sentry_sdk/integrations/redis/modules/queries.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def _compile_db_span_properties(
2323
description = _get_db_span_description(integration, redis_command, args)
2424

2525
properties = {
26-
"op": OP.DB_REDIS,
26+
"op": OP.DB_QUERY,
2727
"description": description,
2828
}
2929

‎tests/integrations/redis/asyncio/test_redis_asyncio.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import sentry_sdk
55
from sentry_sdk import capture_message
6-
from sentry_sdk.consts import SPANDATA
6+
from sentry_sdk.consts import OP, SPANDATA
77
from sentry_sdk.integrations.redis import RedisIntegration
88

99

@@ -60,7 +60,7 @@ async def test_async_redis_pipeline(sentry_init, capture_items):
6060
assert parent_span["name"] == "custom parent"
6161
assert pipeline_span["name"] == "redis.pipeline.execute"
6262
attrs = pipeline_span["attributes"]
63-
assert attrs["sentry.op"] == "db.redis"
63+
assert attrs["sentry.op"] == OP.DB_QUERY
6464
assert attrs[SPANDATA.DB_SYSTEM_NAME] == "redis"
6565
assert attrs[SPANDATA.DB_DRIVER_NAME] == "redis-py"
6666
assert attrs[SPANDATA.DB_NAMESPACE] == "0"

‎tests/integrations/redis/cluster/test_redis_cluster.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import sentry_sdk
77
from sentry_sdk import capture_message
8-
from sentry_sdk.consts import SPANDATA
8+
from sentry_sdk.consts import OP, SPANDATA
99
from sentry_sdk.integrations.redis import RedisIntegration
1010

1111

@@ -94,7 +94,7 @@ def test_rediscluster_basic(
9494
span = redis_spans[-1]
9595
assert span["name"] == description
9696
attrs = span["attributes"]
97-
assert attrs["sentry.op"] == "db.redis"
97+
assert attrs["sentry.op"] == OP.DB_QUERY
9898
assert attrs[SPANDATA.DB_SYSTEM_NAME] == "redis"
9999
assert attrs[SPANDATA.DB_DRIVER_NAME] == "redis-py"
100100
# ClusterNode converts localhost to 127.0.0.1
@@ -132,7 +132,7 @@ def test_rediscluster_pipeline(sentry_init, capture_items):
132132
pipeline_span = redis_spans[-1]
133133
assert pipeline_span["name"] == "redis.pipeline.execute"
134134
attrs = pipeline_span["attributes"]
135-
assert attrs["sentry.op"] == "db.redis"
135+
assert attrs["sentry.op"] == OP.DB_QUERY
136136
assert attrs[SPANDATA.DB_SYSTEM_NAME] == "redis"
137137
assert attrs[SPANDATA.DB_DRIVER_NAME] == "redis-py"
138138
# ClusterNode converts localhost to 127.0.0.1

‎tests/integrations/redis/cluster_asyncio/test_redis_cluster_asyncio.py‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
import sentry_sdk
55
from sentry_sdk import capture_message
6-
from sentry_sdk.consts import SPANDATA
6+
from sentry_sdk.consts import OP, SPANDATA
77
from sentry_sdk.integrations.redis import RedisIntegration
88
from tests.conftest import ApproxDict
99

@@ -96,7 +96,7 @@ async def test_async_basic(
9696
assert parent_span["name"] == "custom parent"
9797
assert redis_span["name"] == description
9898
attrs = redis_span["attributes"]
99-
assert attrs["sentry.op"] == "db.redis"
99+
assert attrs["sentry.op"] == OP.DB_QUERY
100100
assert attrs[SPANDATA.DB_SYSTEM_NAME] == "redis"
101101
assert attrs[SPANDATA.DB_DRIVER_NAME] == "redis-py"
102102
assert attrs[SPANDATA.SERVER_ADDRESS] == "127.0.0.1"
@@ -131,7 +131,7 @@ async def test_async_redis_pipeline(sentry_init, capture_items):
131131
assert parent_span["name"] == "custom parent"
132132
assert pipeline_span["name"] == "redis.pipeline.execute"
133133
attrs = pipeline_span["attributes"]
134-
assert attrs["sentry.op"] == "db.redis"
134+
assert attrs["sentry.op"] == OP.DB_QUERY
135135
assert attrs[SPANDATA.DB_SYSTEM_NAME] == "redis"
136136
assert attrs[SPANDATA.DB_DRIVER_NAME] == "redis-py"
137137
assert attrs[SPANDATA.SERVER_ADDRESS] == "127.0.0.1"

‎tests/integrations/redis/test_redis.py‎

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
import sentry_sdk
77
from sentry_sdk import capture_message
8-
from sentry_sdk.consts import SPANDATA
8+
from sentry_sdk.consts import OP, SPANDATA
99
from sentry_sdk.integrations.redis import RedisIntegration
1010

1111
MOCK_CONNECTION_POOL = mock.MagicMock()
@@ -70,7 +70,7 @@ def test_pii_data_redacted(
7070
assert parent["name"] == "custom parent"
7171
assert set1["name"] == "SET 'somekey1' [Filtered]"
7272
assert set1["attributes"][SPANDATA.DB_QUERY_TEXT] == "SET 'somekey1' [Filtered]"
73-
assert set1["attributes"]["sentry.op"] == "db.redis"
73+
assert set1["attributes"]["sentry.op"] == OP.DB_QUERY
7474
assert set2["name"] == "SET 'somekey2' [Filtered]"
7575
assert set2["attributes"][SPANDATA.DB_QUERY_TEXT] == "SET 'somekey2' [Filtered]"
7676
assert get["name"] == "GET 'somekey2'"
@@ -117,7 +117,7 @@ def test_data_collection_database_query_data(
117117
assert parent["name"] == "custom parent"
118118
assert set_span["name"] == expected_description
119119
assert set_span["attributes"][SPANDATA.DB_QUERY_TEXT] == expected_description
120-
assert set_span["attributes"]["sentry.op"] == "db.redis"
120+
assert set_span["attributes"]["sentry.op"] == OP.DB_QUERY
121121

122122

123123
def test_no_data_truncation_by_default(sentry_init, capture_items):
@@ -147,7 +147,7 @@ def test_no_data_truncation_by_default(sentry_init, capture_items):
147147
assert (
148148
set1["attributes"][SPANDATA.DB_QUERY_TEXT] == f"SET 'somekey1' '{long_string}'"
149149
)
150-
assert set1["attributes"]["sentry.op"] == "db.redis"
150+
assert set1["attributes"]["sentry.op"] == OP.DB_QUERY
151151
assert set2["name"] == f"SET 'somekey2' '{short_string}'"
152152
assert (
153153
set2["attributes"][SPANDATA.DB_QUERY_TEXT] == f"SET 'somekey2' '{short_string}'"
@@ -219,7 +219,7 @@ def test_db_connection_attributes_client(sentry_init, capture_items):
219219
assert parent_span["name"] == "custom parent"
220220
assert redis_span["name"] == "GET 'foobar'"
221221
attrs = redis_span["attributes"]
222-
assert attrs["sentry.op"] == "db.redis"
222+
assert attrs["sentry.op"] == OP.DB_QUERY
223223
assert attrs[SPANDATA.DB_QUERY_TEXT] == "GET 'foobar'"
224224
assert attrs[SPANDATA.DB_SYSTEM_NAME] == "redis"
225225
assert attrs[SPANDATA.DB_DRIVER_NAME] == "redis-py"
@@ -252,7 +252,7 @@ def test_db_connection_attributes_pipeline(sentry_init, capture_items):
252252
assert parent_span["name"] == "custom parent"
253253
assert pipeline_span["name"] == "redis.pipeline.execute"
254254
attrs = pipeline_span["attributes"]
255-
assert attrs["sentry.op"] == "db.redis"
255+
assert attrs["sentry.op"] == OP.DB_QUERY
256256
assert attrs[SPANDATA.DB_SYSTEM_NAME] == "redis"
257257
assert attrs[SPANDATA.DB_DRIVER_NAME] == "redis-py"
258258
assert attrs[SPANDATA.DB_NAMESPACE] == "1"

‎tests/integrations/redis/test_redis_cache_module.py‎

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from fakeredis import FakeRedis
66

77
import sentry_sdk
8-
from sentry_sdk.consts import SPANDATA
8+
from sentry_sdk.consts import OP, SPANDATA
99
from sentry_sdk.integrations.redis import RedisIntegration
1010
from sentry_sdk.integrations.redis.utils import _get_safe_key, _key_as_string
1111
from sentry_sdk.utils import parse_version
@@ -33,7 +33,7 @@ def test_no_cache_basic(sentry_init, capture_items):
3333
assert len(items) == 2
3434
db_span, parent_span = items[0].payload, items[1].payload
3535
assert parent_span["name"] == "custom parent"
36-
assert db_span["attributes"]["sentry.op"] == "db.redis"
36+
assert db_span["attributes"]["sentry.op"] == OP.DB_QUERY
3737

3838

3939
def test_cache_basic(sentry_init, capture_items):
@@ -65,25 +65,25 @@ def test_cache_basic(sentry_init, capture_items):
6565
payloads = [item.payload for item in items]
6666

6767
# hget: db only (HGET is not a cache command)
68-
assert payloads[0]["attributes"]["sentry.op"] == "db.redis"
68+
assert payloads[0]["attributes"]["sentry.op"] == OP.DB_QUERY
6969
assert payloads[0]["attributes"][SPANDATA.DB_OPERATION_NAME] == "HGET"
7070

7171
# get: db then cache.get
72-
assert payloads[1]["attributes"]["sentry.op"] == "db.redis"
72+
assert payloads[1]["attributes"]["sentry.op"] == OP.DB_QUERY
7373
assert payloads[1]["attributes"][SPANDATA.DB_OPERATION_NAME] == "GET"
7474
assert payloads[2]["attributes"]["sentry.op"] == "cache.get"
7575
assert payloads[2]["attributes"][SPANDATA.DB_QUERY_TEXT] == "GET 'mycachekey'"
7676

7777
# set: db then cache.put
78-
assert payloads[3]["attributes"]["sentry.op"] == "db.redis"
78+
assert payloads[3]["attributes"]["sentry.op"] == OP.DB_QUERY
7979
assert payloads[3]["attributes"][SPANDATA.DB_OPERATION_NAME] == "SET"
8080
assert payloads[4]["attributes"]["sentry.op"] == "cache.put"
8181
assert (
8282
payloads[4]["attributes"][SPANDATA.DB_QUERY_TEXT] == "SET 'mycachekey1' 'bla'"
8383
)
8484

8585
# setex: db then cache.put
86-
assert payloads[5]["attributes"]["sentry.op"] == "db.redis"
86+
assert payloads[5]["attributes"]["sentry.op"] == OP.DB_QUERY
8787
assert payloads[5]["attributes"][SPANDATA.DB_OPERATION_NAME] == "SETEX"
8888
assert payloads[6]["attributes"]["sentry.op"] == "cache.put"
8989
assert (
@@ -92,7 +92,7 @@ def test_cache_basic(sentry_init, capture_items):
9292
)
9393

9494
# mget: db then cache.get
95-
assert payloads[7]["attributes"]["sentry.op"] == "db.redis"
95+
assert payloads[7]["attributes"]["sentry.op"] == OP.DB_QUERY
9696
assert payloads[7]["attributes"][SPANDATA.DB_OPERATION_NAME] == "MGET"
9797
assert payloads[8]["attributes"]["sentry.op"] == "cache.get"
9898
assert (
@@ -129,25 +129,25 @@ def test_cache_keys(sentry_init, capture_items):
129129
payloads = [item.payload for item in items]
130130

131131
# somethingelse: db only
132-
assert payloads[0]["attributes"]["sentry.op"] == "db.redis"
132+
assert payloads[0]["attributes"]["sentry.op"] == OP.DB_QUERY
133133
assert payloads[0]["name"] == "GET 'somethingelse'"
134134

135135
# blub: db then cache.get
136-
assert payloads[1]["attributes"]["sentry.op"] == "db.redis"
136+
assert payloads[1]["attributes"]["sentry.op"] == OP.DB_QUERY
137137
assert payloads[1]["name"] == "GET 'blub'"
138138
assert payloads[2]["attributes"]["sentry.op"] == "cache.get"
139139
assert payloads[2]["name"] == "blub"
140140
assert payloads[2]["attributes"][SPANDATA.DB_QUERY_TEXT] == "GET 'blub'"
141141

142142
# blubkeything: db then cache.get
143-
assert payloads[3]["attributes"]["sentry.op"] == "db.redis"
143+
assert payloads[3]["attributes"]["sentry.op"] == OP.DB_QUERY
144144
assert payloads[3]["name"] == "GET 'blubkeything'"
145145
assert payloads[4]["attributes"]["sentry.op"] == "cache.get"
146146
assert payloads[4]["name"] == "blubkeything"
147147
assert payloads[4]["attributes"][SPANDATA.DB_QUERY_TEXT] == "GET 'blubkeything'"
148148

149149
# bl: db only (no prefix match)
150-
assert payloads[5]["attributes"]["sentry.op"] == "db.redis"
150+
assert payloads[5]["attributes"]["sentry.op"] == OP.DB_QUERY
151151
assert payloads[5]["name"] == "GET 'bl'"
152152

153153
assert payloads[6]["name"] == "custom parent"
@@ -182,7 +182,7 @@ def test_cache_data(sentry_init, capture_items):
182182
payloads = [item.payload for item in items]
183183

184184
# First get (miss)
185-
assert payloads[0]["attributes"]["sentry.op"] == "db.redis"
185+
assert payloads[0]["attributes"]["sentry.op"] == OP.DB_QUERY
186186
cache_get_miss = payloads[1]
187187
assert cache_get_miss["attributes"]["sentry.op"] == "cache.get"
188188
assert cache_get_miss["name"] == "mycachekey"
@@ -199,7 +199,7 @@ def test_cache_data(sentry_init, capture_items):
199199
assert cache_get_miss["attributes"]["network.peer.address"] == host
200200

201201
# Set
202-
assert payloads[2]["attributes"]["sentry.op"] == "db.redis"
202+
assert payloads[2]["attributes"]["sentry.op"] == OP.DB_QUERY
203203
cache_put = payloads[3]
204204
assert cache_put["attributes"]["sentry.op"] == "cache.put"
205205
assert cache_put["name"] == "mycachekey"
@@ -216,7 +216,7 @@ def test_cache_data(sentry_init, capture_items):
216216
assert cache_put["attributes"]["network.peer.address"] == host
217217

218218
# Second get (hit)
219-
assert payloads[4]["attributes"]["sentry.op"] == "db.redis"
219+
assert payloads[4]["attributes"]["sentry.op"] == OP.DB_QUERY
220220
cache_get_hit = payloads[5]
221221
assert cache_get_hit["attributes"]["sentry.op"] == "cache.get"
222222
assert cache_get_hit["attributes"]["cache.key"] == ["mycachekey"]

0 commit comments

Comments
 (0)