@@ -42,52 +42,6 @@ def test_basic(sentry_init, capture_events):
4242 }
4343
4444
45- @pytest .mark .parametrize (
46- "is_transaction, send_default_pii, expected_first_ten" ,
47- [
48- (False , False , ["GET 'foo'" , "SET 'bar' [Filtered]" , "SET 'baz' [Filtered]" ]),
49- (True , True , ["GET 'foo'" , "SET 'bar' 1" , "SET 'baz' 2" ]),
50- ],
51- )
52- def test_redis_pipeline (
53- sentry_init ,
54- capture_events ,
55- capture_items ,
56- is_transaction ,
57- send_default_pii ,
58- expected_first_ten ,
59- ):
60- sentry_init (
61- integrations = [RedisIntegration ()],
62- traces_sample_rate = 1.0 ,
63- send_default_pii = send_default_pii ,
64- )
65-
66- connection = FakeRedis ()
67-
68- items = capture_items ("span" )
69-
70- with sentry_sdk .start_span (name = "custom parent" ):
71- pipeline = connection .pipeline (transaction = is_transaction )
72- pipeline .get ("foo" )
73- pipeline .set ("bar" , 1 )
74- pipeline .set ("baz" , 2 )
75- pipeline .execute ()
76-
77- sentry_sdk .flush ()
78-
79- assert len (items ) == 2
80- pipeline_span , parent_span = items [0 ].payload , items [1 ].payload
81-
82- assert parent_span ["name" ] == "custom parent"
83- assert parent_span ["is_segment" ] is True
84-
85- assert pipeline_span ["name" ] == "redis.pipeline.execute"
86- assert pipeline_span ["attributes" ]["sentry.op" ] == "db.redis"
87- assert pipeline_span ["attributes" ]["sentry.origin" ] == "auto.db.redis"
88- assert pipeline_span ["attributes" ][SPANDATA .DB_SYSTEM_NAME ] == "redis"
89-
90-
9145@pytest .mark .parametrize (
9246 "data_collection, expected_first_ten" ,
9347 [
@@ -135,38 +89,6 @@ def test_redis_pipeline_data_collection(
13589 assert pipeline_span ["attributes" ]["sentry.op" ] == "db.redis"
13690
13791
138- def test_sensitive_data (
139- sentry_init ,
140- capture_events ,
141- capture_items ,
142- ):
143- # fakeredis does not support the AUTH command, so we need to mock it
144- with mock .patch (
145- "sentry_sdk.integrations.redis.utils._COMMANDS_INCLUDING_SENSITIVE_DATA" ,
146- ["get" ],
147- ):
148- sentry_init (
149- integrations = [RedisIntegration ()],
150- traces_sample_rate = 1.0 ,
151- send_default_pii = True ,
152- )
153-
154- connection = FakeRedis ()
155-
156- items = capture_items ("span" )
157- with sentry_sdk .start_span (name = "custom parent" ):
158- connection .get ("this is super secret" )
159- sentry_sdk .flush ()
160-
161- assert len (items ) == 2
162- redis_span , parent_span = items [0 ].payload , items [1 ].payload
163-
164- assert parent_span ["name" ] == "custom parent"
165- assert redis_span ["name" ] == "GET [Filtered]"
166- assert redis_span ["attributes" ][SPANDATA .DB_QUERY_TEXT ] == "GET [Filtered]"
167- assert redis_span ["attributes" ]["sentry.op" ] == "db.redis"
168-
169-
17092def test_pii_data_redacted (
17193 sentry_init ,
17294 capture_events ,
@@ -205,7 +127,7 @@ def test_pii_data_redacted(
205127@pytest .mark .parametrize (
206128 "data_collection, expected_description" ,
207129 [
208- ({"database_query_data" : False }, "SET 'somekey1'" ),
130+ ({"database_query_data" : False }, "SET 'somekey1' [Filtered] " ),
209131 ({"database_query_data" : True }, "SET 'somekey1' 'my secret string1'" ),
210132 ({}, "SET 'somekey1' 'my secret string1'" ),
211133 ],
@@ -246,94 +168,11 @@ def test_data_collection_database_query_data(
246168 assert set_span ["attributes" ]["sentry.op" ] == "db.redis"
247169
248170
249- @pytest .mark .parametrize (
250- "data_collection, send_default_pii, expected_description" ,
251- [
252- ({"database_query_data" : False }, True , "SET 'somekey1'" ),
253- (
254- {"database_query_data" : True },
255- False ,
256- "SET 'somekey1' 'my secret string1'" ,
257- ),
258- ],
259- )
260- @pytest .mark .filterwarnings ("ignore::DeprecationWarning" )
261- def test_database_query_data_takes_precedence_over_send_default_pii (
262- sentry_init ,
263- capture_events ,
264- capture_items ,
265- data_collection ,
266- send_default_pii ,
267- expected_description ,
268- ):
269- sentry_init (
270- integrations = [RedisIntegration ()],
271- traces_sample_rate = 1.0 ,
272- send_default_pii = send_default_pii ,
273- data_collection = data_collection ,
274- )
275-
276- connection = FakeRedis ()
277-
278- items = capture_items ("span" )
279-
280- with sentry_sdk .start_span (name = "custom parent" ):
281- connection .set ("somekey1" , "my secret string1" )
282-
283- sentry_sdk .flush ()
284-
285- assert len (items ) == 2
286- set_span , parent = [item .payload for item in items ]
287-
288- assert parent ["name" ] == "custom parent"
289- assert set_span ["name" ] == expected_description
290- assert set_span ["attributes" ][SPANDATA .DB_QUERY_TEXT ] == expected_description
291- assert set_span ["attributes" ]["sentry.op" ] == "db.redis"
292-
293-
294- def test_pii_data_sent (sentry_init , capture_items ):
295- sentry_init (
296- integrations = [RedisIntegration ()],
297- traces_sample_rate = 1.0 ,
298- send_default_pii = True ,
299- )
300-
301- connection = FakeRedis ()
302-
303- items = capture_items ("span" )
304-
305- with sentry_sdk .start_span (name = "custom parent" ):
306- connection .set ("somekey1" , "my secret string1" )
307- connection .set ("somekey2" , "my secret string2" )
308- connection .get ("somekey2" )
309- connection .delete ("somekey1" , "somekey2" )
310-
311- sentry_sdk .flush ()
312-
313- assert len (items ) == 5
314- set1 , set2 , get , delete , parent = [item .payload for item in items ]
315-
316- assert parent ["name" ] == "custom parent"
317- assert set1 ["name" ] == "SET 'somekey1' 'my secret string1'"
318- assert (
319- set1 ["attributes" ][SPANDATA .DB_QUERY_TEXT ]
320- == "SET 'somekey1' 'my secret string1'"
321- )
322- assert set1 ["attributes" ]["sentry.op" ] == "db.redis"
323- assert set2 ["name" ] == "SET 'somekey2' 'my secret string2'"
324- assert (
325- set2 ["attributes" ][SPANDATA .DB_QUERY_TEXT ]
326- == "SET 'somekey2' 'my secret string2'"
327- )
328- assert get ["name" ] == "GET 'somekey2'"
329- assert delete ["name" ] == "DEL 'somekey1' 'somekey2'"
330-
331-
332171def test_no_data_truncation_by_default (sentry_init , capture_items ):
333172 sentry_init (
334173 integrations = [RedisIntegration ()],
335174 traces_sample_rate = 1.0 ,
336- send_default_pii = True ,
175+ data_collection = { "database_query_data" : True } ,
337176 )
338177
339178 connection = FakeRedis ()
@@ -366,7 +205,7 @@ def test_no_data_truncation_by_default(sentry_init, capture_items):
366205def test_breadcrumbs (sentry_init , capture_events ):
367206 sentry_init (
368207 integrations = [RedisIntegration ()],
369- send_default_pii = True ,
208+ data_collection = { "database_query_data" : True } ,
370209 )
371210 events = capture_events ()
372211
0 commit comments