@@ -118,7 +118,9 @@ def test_transaction_with_error(
118118 )
119119
120120 assert envelope ["type" ] == "transaction"
121- assert envelope ["contexts" ]["trace" ] == error_event ["contexts" ]["trace" ]
121+ assert envelope ["contexts" ]["trace" ] == DictionaryContaining (
122+ error_event ["contexts" ]["trace" ]
123+ )
122124 assert envelope ["transaction" ] == error_event ["transaction" ]
123125 assert envelope ["extra" ]["rq-job" ] == DictionaryContaining (
124126 {
@@ -148,10 +150,7 @@ def test_error_has_trace_context_if_tracing_disabled(
148150 assert error_event ["contexts" ]["trace" ]
149151
150152
151- def test_tracing_enabled (
152- sentry_init ,
153- capture_events ,
154- ):
153+ def test_tracing_enabled (sentry_init , capture_events , DictionaryContaining ):
155154 sentry_init (integrations = [RqIntegration ()], traces_sample_rate = 1.0 )
156155 events = capture_events ()
157156
@@ -165,12 +164,10 @@ def test_tracing_enabled(
165164
166165 assert error_event ["transaction" ] == "tests.integrations.rq.test_rq.crashing_job"
167166 assert transaction ["transaction" ] == "tests.integrations.rq.test_rq.crashing_job"
168- for trace_key in error_event ["contexts" ]["trace" ]:
169- assert trace_key in transaction ["contexts" ]["trace" ]
170- assert (
171- error_event ["contexts" ]["trace" ][trace_key ]
172- == transaction ["contexts" ]["trace" ][trace_key ]
173- )
167+ assert (
168+ DictionaryContaining (error_event ["contexts" ]["trace" ])
169+ == transaction ["contexts" ]["trace" ]
170+ )
174171
175172
176173def test_tracing_disabled (
@@ -223,9 +220,7 @@ def test_transaction_no_error(
223220 )
224221
225222
226- def test_traces_sampler_gets_correct_values_in_sampling_context (
227- sentry_init , DictionaryContaining , ObjectDescribedBy # noqa:N803
228- ):
223+ def test_traces_sampler_gets_correct_values_in_sampling_context (sentry_init ):
229224 traces_sampler = mock .Mock (return_value = True )
230225 sentry_init (integrations = [RqIntegration ()], traces_sampler = traces_sampler )
231226
@@ -235,22 +230,12 @@ def test_traces_sampler_gets_correct_values_in_sampling_context(
235230 queue .enqueue (do_trick , "Bodhi" , trick = "roll over" )
236231 worker .work (burst = True )
237232
238- traces_sampler .assert_any_call (
239- DictionaryContaining (
240- {
241- "rq_job" : ObjectDescribedBy (
242- type = rq .job .Job ,
243- attrs = {
244- "description" : "tests.integrations.rq.test_rq.do_trick('Bodhi', trick='roll over')" ,
245- "result" : "Bodhi, can you roll over? Good dog!" ,
246- "func_name" : "tests.integrations.rq.test_rq.do_trick" ,
247- "args" : ("Bodhi" ,),
248- "kwargs" : {"trick" : "roll over" },
249- },
250- ),
251- }
252- )
253- )
233+ sampling_context = traces_sampler .call_args_list [0 ][0 ][0 ]
234+ assert sampling_context ["messaging.system" ] == "rq"
235+ assert sampling_context ["rq.job.args" ] == ["Bodhi" ]
236+ assert sampling_context ["rq.job.kwargs" ] == '{"trick": "roll over"}'
237+ assert sampling_context ["messaging.message.id" ]
238+ assert sampling_context ["messaging.destination.name" ] == "default"
254239
255240
256241@pytest .mark .skipif (
0 commit comments