@@ -62,9 +62,12 @@ def test_get_otel_context():
6262
6363def test_get_trace_data_with_span_and_trace ():
6464 otel_span = MagicMock ()
65- otel_span .context = MagicMock ()
66- otel_span .context .trace_id = int ("1234567890abcdef1234567890abcdef" , 16 )
67- otel_span .context .span_id = int ("1234567890abcdef" , 16 )
65+ span_context = SpanContext (
66+ trace_id = int ("1234567890abcdef1234567890abcdef" , 16 ),
67+ span_id = int ("1234567890abcdef" , 16 ),
68+ is_remote = True ,
69+ )
70+ otel_span .get_span_context .return_value = span_context
6871 otel_span .parent = None
6972
7073 parent_context = {}
@@ -80,9 +83,12 @@ def test_get_trace_data_with_span_and_trace():
8083
8184def test_get_trace_data_with_span_and_trace_and_parent ():
8285 otel_span = MagicMock ()
83- otel_span .context = MagicMock ()
84- otel_span .context .trace_id = int ("1234567890abcdef1234567890abcdef" , 16 )
85- otel_span .context .span_id = int ("1234567890abcdef" , 16 )
86+ span_context = SpanContext (
87+ trace_id = int ("1234567890abcdef1234567890abcdef" , 16 ),
88+ span_id = int ("1234567890abcdef" , 16 ),
89+ is_remote = True ,
90+ )
91+ otel_span .get_span_context .return_value = span_context
8692 otel_span .parent = MagicMock ()
8793 otel_span .parent .span_id = int ("abcdef1234567890" , 16 )
8894
@@ -99,9 +105,12 @@ def test_get_trace_data_with_span_and_trace_and_parent():
99105
100106def test_get_trace_data_with_sentry_trace ():
101107 otel_span = MagicMock ()
102- otel_span .context = MagicMock ()
103- otel_span .context .trace_id = int ("1234567890abcdef1234567890abcdef" , 16 )
104- otel_span .context .span_id = int ("1234567890abcdef" , 16 )
108+ span_context = SpanContext (
109+ trace_id = int ("1234567890abcdef1234567890abcdef" , 16 ),
110+ span_id = int ("1234567890abcdef" , 16 ),
111+ is_remote = True ,
112+ )
113+ otel_span .get_span_context .return_value = span_context
105114 otel_span .parent = MagicMock ()
106115 otel_span .parent .span_id = int ("abcdef1234567890" , 16 )
107116
@@ -144,9 +153,12 @@ def test_get_trace_data_with_sentry_trace():
144153
145154def test_get_trace_data_with_sentry_trace_and_baggage ():
146155 otel_span = MagicMock ()
147- otel_span .context = MagicMock ()
148- otel_span .context .trace_id = int ("1234567890abcdef1234567890abcdef" , 16 )
149- otel_span .context .span_id = int ("1234567890abcdef" , 16 )
156+ span_context = SpanContext (
157+ trace_id = int ("1234567890abcdef1234567890abcdef" , 16 ),
158+ span_id = int ("1234567890abcdef" , 16 ),
159+ is_remote = True ,
160+ )
161+ otel_span .get_span_context .return_value = span_context
150162 otel_span .parent = MagicMock ()
151163 otel_span .parent .span_id = int ("abcdef1234567890" , 16 )
152164
@@ -263,9 +275,12 @@ def test_on_start_transaction():
263275 otel_span = MagicMock ()
264276 otel_span .name = "Sample OTel Span"
265277 otel_span .start_time = time .time_ns ()
266- otel_span .context = MagicMock ()
267- otel_span .context .trace_id = int ("1234567890abcdef1234567890abcdef" , 16 )
268- otel_span .context .span_id = int ("1234567890abcdef" , 16 )
278+ span_context = SpanContext (
279+ trace_id = int ("1234567890abcdef1234567890abcdef" , 16 ),
280+ span_id = int ("1234567890abcdef" , 16 ),
281+ is_remote = True ,
282+ )
283+ otel_span .get_span_context .return_value = span_context
269284 otel_span .parent = MagicMock ()
270285 otel_span .parent .span_id = int ("abcdef1234567890" , 16 )
271286
@@ -305,9 +320,12 @@ def test_on_start_child():
305320 otel_span = MagicMock ()
306321 otel_span .name = "Sample OTel Span"
307322 otel_span .start_time = time .time_ns ()
308- otel_span .context = MagicMock ()
309- otel_span .context .trace_id = int ("1234567890abcdef1234567890abcdef" , 16 )
310- otel_span .context .span_id = int ("1234567890abcdef" , 16 )
323+ span_context = SpanContext (
324+ trace_id = int ("1234567890abcdef1234567890abcdef" , 16 ),
325+ span_id = int ("1234567890abcdef" , 16 ),
326+ is_remote = True ,
327+ )
328+ otel_span .get_span_context .return_value = span_context
311329 otel_span .parent = MagicMock ()
312330 otel_span .parent .span_id = int ("abcdef1234567890" , 16 )
313331
@@ -351,8 +369,12 @@ def test_on_end_no_sentry_span():
351369 otel_span = MagicMock ()
352370 otel_span .name = "Sample OTel Span"
353371 otel_span .end_time = time .time_ns ()
354- otel_span .context = MagicMock ()
355- otel_span .context .span_id = int ("1234567890abcdef" , 16 )
372+ span_context = SpanContext (
373+ trace_id = int ("1234567890abcdef1234567890abcdef" , 16 ),
374+ span_id = int ("1234567890abcdef" , 16 ),
375+ is_remote = True ,
376+ )
377+ otel_span .get_span_context .return_value = span_context
356378
357379 span_processor = SentrySpanProcessor ()
358380 span_processor .otel_span_map = {}
@@ -372,8 +394,12 @@ def test_on_end_sentry_transaction():
372394 otel_span = MagicMock ()
373395 otel_span .name = "Sample OTel Span"
374396 otel_span .end_time = time .time_ns ()
375- otel_span .context = MagicMock ()
376- otel_span .context .span_id = int ("1234567890abcdef" , 16 )
397+ span_context = SpanContext (
398+ trace_id = int ("1234567890abcdef1234567890abcdef" , 16 ),
399+ span_id = int ("1234567890abcdef" , 16 ),
400+ is_remote = True ,
401+ )
402+ otel_span .get_span_context .return_value = span_context
377403
378404 fake_sentry_span = MagicMock (spec = Transaction )
379405 fake_sentry_span .set_context = MagicMock ()
@@ -398,8 +424,12 @@ def test_on_end_sentry_span():
398424 otel_span = MagicMock ()
399425 otel_span .name = "Sample OTel Span"
400426 otel_span .end_time = time .time_ns ()
401- otel_span .context = MagicMock ()
402- otel_span .context .span_id = int ("1234567890abcdef" , 16 )
427+ span_context = SpanContext (
428+ trace_id = int ("1234567890abcdef1234567890abcdef" , 16 ),
429+ span_id = int ("1234567890abcdef" , 16 ),
430+ is_remote = True ,
431+ )
432+ otel_span .get_span_context .return_value = span_context
403433
404434 fake_sentry_span = MagicMock (spec = Span )
405435 fake_sentry_span .set_context = MagicMock ()
@@ -425,7 +455,6 @@ def test_link_trace_context_to_error_event():
425455 """
426456 fake_client = MagicMock ()
427457 fake_client .options = {"instrumenter" : "otel" }
428- fake_client
429458
430459 current_hub = MagicMock ()
431460 current_hub .client = fake_client
0 commit comments