33import pytest
44from fakeredis import FakeStrictRedis
55
6- from sentry_sdk import capture_message , start_transaction
6+ import sentry_sdk
77from sentry_sdk .consts import SPANDATA
88from sentry_sdk .integrations .redis import RedisIntegration
99
@@ -23,7 +23,7 @@ def test_basic(sentry_init, capture_events):
2323 connection = FakeStrictRedis ()
2424
2525 connection .get ("foobar" )
26- capture_message ("hi" )
26+ sentry_sdk . capture_message ("hi" )
2727
2828 (event ,) = events
2929 (crumb ,) = event ["breadcrumbs" ]["values" ]
@@ -60,7 +60,7 @@ def test_redis_pipeline(
6060 events = capture_events ()
6161
6262 connection = FakeStrictRedis ()
63- with start_transaction ():
63+ with sentry_sdk . start_span ():
6464 pipeline = connection .pipeline (transaction = is_transaction )
6565 pipeline .get ("foo" )
6666 pipeline .set ("bar" , 1 )
@@ -94,7 +94,7 @@ def test_sensitive_data(sentry_init, capture_events, render_span_tree):
9494 events = capture_events ()
9595
9696 connection = FakeStrictRedis ()
97- with start_transaction ():
97+ with sentry_sdk . start_span ():
9898 connection .get (
9999 "this is super secret"
100100 ) # because fakeredis does not support AUTH we use GET instead
@@ -103,7 +103,7 @@ def test_sensitive_data(sentry_init, capture_events, render_span_tree):
103103 assert (
104104 render_span_tree (event )
105105 == """\
106- - op="": description=null
106+ - op="<unlabeled span> ": description=null
107107 - op="db.redis": description="GET [Filtered]"\
108108 """
109109 )
@@ -117,7 +117,7 @@ def test_pii_data_redacted(sentry_init, capture_events, render_span_tree):
117117 events = capture_events ()
118118
119119 connection = FakeStrictRedis ()
120- with start_transaction ():
120+ with sentry_sdk . start_span ():
121121 connection .set ("somekey1" , "my secret string1" )
122122 connection .set ("somekey2" , "my secret string2" )
123123 connection .get ("somekey2" )
@@ -127,7 +127,7 @@ def test_pii_data_redacted(sentry_init, capture_events, render_span_tree):
127127 assert (
128128 render_span_tree (event )
129129 == """\
130- - op="": description=null
130+ - op="<unlabeled span> ": description=null
131131 - op="db.redis": description="SET 'somekey1' [Filtered]"
132132 - op="db.redis": description="SET 'somekey2' [Filtered]"
133133 - op="db.redis": description="GET 'somekey2'"
@@ -145,7 +145,7 @@ def test_pii_data_sent(sentry_init, capture_events, render_span_tree):
145145 events = capture_events ()
146146
147147 connection = FakeStrictRedis ()
148- with start_transaction ():
148+ with sentry_sdk . start_span ():
149149 connection .set ("somekey1" , "my secret string1" )
150150 connection .set ("somekey2" , "my secret string2" )
151151 connection .get ("somekey2" )
@@ -155,7 +155,7 @@ def test_pii_data_sent(sentry_init, capture_events, render_span_tree):
155155 assert (
156156 render_span_tree (event )
157157 == """\
158- - op="": description=null
158+ - op="<unlabeled span> ": description=null
159159 - op="db.redis": description="SET 'somekey1' 'my secret string1'"
160160 - op="db.redis": description="SET 'somekey2' 'my secret string2'"
161161 - op="db.redis": description="GET 'somekey2'"
@@ -173,7 +173,7 @@ def test_data_truncation(sentry_init, capture_events, render_span_tree):
173173 events = capture_events ()
174174
175175 connection = FakeStrictRedis ()
176- with start_transaction ():
176+ with sentry_sdk . start_span ():
177177 long_string = "a" * 100000
178178 connection .set ("somekey1" , long_string )
179179 short_string = "b" * 10
@@ -183,7 +183,7 @@ def test_data_truncation(sentry_init, capture_events, render_span_tree):
183183 assert (
184184 render_span_tree (event )
185185 == f"""\
186- - op="": description=null
186+ - op="<unlabeled span> ": description=null
187187 - op="db.redis": description="SET 'somekey1' '{ long_string [: 1024 - len ("..." ) - len ("SET 'somekey1' '" )]} ..."
188188 - op="db.redis": description="SET 'somekey2' 'bbbbbbbbbb'"\
189189 """ # noqa: E221
@@ -199,7 +199,7 @@ def test_data_truncation_custom(sentry_init, capture_events, render_span_tree):
199199 events = capture_events ()
200200
201201 connection = FakeStrictRedis ()
202- with start_transaction ():
202+ with sentry_sdk . start_span ():
203203 long_string = "a" * 100000
204204 connection .set ("somekey1" , long_string )
205205 short_string = "b" * 10
@@ -209,7 +209,7 @@ def test_data_truncation_custom(sentry_init, capture_events, render_span_tree):
209209 assert (
210210 render_span_tree (event )
211211 == f"""\
212- - op="": description=null
212+ - op="<unlabeled span> ": description=null
213213 - op="db.redis": description="SET 'somekey1' '{ long_string [: 30 - len ("..." ) - len ("SET 'somekey1' '" )]} ..."
214214 - op="db.redis": description="SET 'somekey2' '{ short_string } '"\
215215 """ # noqa: E221
@@ -230,7 +230,7 @@ def test_breadcrumbs(sentry_init, capture_events):
230230 short_string = "b" * 10
231231 connection .set ("somekey2" , short_string )
232232
233- capture_message ("hi" )
233+ sentry_sdk . capture_message ("hi" )
234234
235235 (event ,) = events
236236 crumbs = event ["breadcrumbs" ]["values" ]
@@ -268,7 +268,7 @@ def test_db_connection_attributes_client(sentry_init, capture_events):
268268 )
269269 events = capture_events ()
270270
271- with start_transaction ():
271+ with sentry_sdk . start_span ():
272272 connection = FakeStrictRedis (connection_pool = MOCK_CONNECTION_POOL )
273273 connection .get ("foobar" )
274274
@@ -290,7 +290,7 @@ def test_db_connection_attributes_pipeline(sentry_init, capture_events):
290290 )
291291 events = capture_events ()
292292
293- with start_transaction ():
293+ with sentry_sdk . start_span ():
294294 connection = FakeStrictRedis (connection_pool = MOCK_CONNECTION_POOL )
295295 pipeline = connection .pipeline (transaction = False )
296296 pipeline .get ("foo" )
@@ -317,7 +317,7 @@ def test_span_origin(sentry_init, capture_events):
317317 events = capture_events ()
318318
319319 connection = FakeStrictRedis ()
320- with start_transaction (name = "custom_transaction" ):
320+ with sentry_sdk . start_span (name = "custom_transaction" ):
321321 # default case
322322 connection .set ("somekey" , "somevalue" )
323323
0 commit comments