55from fakeredis import FakeStrictRedis
66
77import sentry_sdk
8- from sentry_sdk import start_transaction
98from sentry_sdk .integrations .rq import RqIntegration
109from sentry_sdk .utils import parse_version
1110
@@ -46,6 +45,7 @@ def do_trick(dog, trick):
4645 return "{}, can you {}? Good dog!" .format (dog , trick )
4746
4847
48+ @pytest .mark .forked
4949def test_basic (sentry_init , capture_events ):
5050 sentry_init (integrations = [RqIntegration ()])
5151 events = capture_events ()
@@ -78,6 +78,7 @@ def test_basic(sentry_init, capture_events):
7878 assert "started_at" in extra
7979
8080
81+ @pytest .mark .forked
8182def test_transport_shutdown (sentry_init , capture_events_forksafe ):
8283 sentry_init (integrations = [RqIntegration ()])
8384
@@ -96,6 +97,7 @@ def test_transport_shutdown(sentry_init, capture_events_forksafe):
9697 assert exception ["type" ] == "ZeroDivisionError"
9798
9899
100+ @pytest .mark .forked
99101def test_transaction_with_error (
100102 sentry_init , capture_events , DictionaryContaining # noqa:N803
101103):
@@ -131,6 +133,7 @@ def test_transaction_with_error(
131133 )
132134
133135
136+ @pytest .mark .forked
134137def test_error_has_trace_context_if_tracing_disabled (
135138 sentry_init ,
136139 capture_events ,
@@ -149,6 +152,7 @@ def test_error_has_trace_context_if_tracing_disabled(
149152 assert error_event ["contexts" ]["trace" ]
150153
151154
155+ @pytest .mark .forked
152156def test_tracing_enabled (
153157 sentry_init ,
154158 capture_events ,
@@ -159,18 +163,17 @@ def test_tracing_enabled(
159163 queue = rq .Queue (connection = FakeStrictRedis ())
160164 worker = rq .SimpleWorker ([queue ], connection = queue .connection )
161165
162- with start_transaction (op = "rq transaction" ) as transaction :
163- queue .enqueue (crashing_job , foo = None )
164- worker .work (burst = True )
166+ queue .enqueue (crashing_job , foo = None )
167+ worker .work (burst = True )
165168
166- error_event , envelope , _ = events
169+ error_event , transaction = events
167170
168171 assert error_event ["transaction" ] == "tests.integrations.rq.test_rq.crashing_job"
169- assert error_event ["contexts" ]["trace" ]["trace_id" ] == transaction .trace_id
170-
171- assert envelope ["contexts" ]["trace" ] == error_event ["contexts" ]["trace" ]
172+ assert transaction ["transaction" ] == "tests.integrations.rq.test_rq.crashing_job"
173+ assert transaction ["contexts" ]["trace" ] == error_event ["contexts" ]["trace" ]
172174
173175
176+ @pytest .mark .forked
174177def test_tracing_disabled (
175178 sentry_init ,
176179 capture_events ,
@@ -251,6 +254,7 @@ def test_traces_sampler_gets_correct_values_in_sampling_context(
251254 )
252255
253256
257+ @pytest .mark .forked
254258@pytest .mark .skipif (
255259 parse_version (rq .__version__ ) < (1 , 5 ), reason = "At least rq-1.5 required"
256260)
0 commit comments