@@ -62,9 +62,12 @@ def test_get_otel_context():
62
62
63
63
def test_get_trace_data_with_span_and_trace ():
64
64
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
68
71
otel_span .parent = None
69
72
70
73
parent_context = {}
@@ -80,9 +83,12 @@ def test_get_trace_data_with_span_and_trace():
80
83
81
84
def test_get_trace_data_with_span_and_trace_and_parent ():
82
85
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
86
92
otel_span .parent = MagicMock ()
87
93
otel_span .parent .span_id = int ("abcdef1234567890" , 16 )
88
94
@@ -99,9 +105,12 @@ def test_get_trace_data_with_span_and_trace_and_parent():
99
105
100
106
def test_get_trace_data_with_sentry_trace ():
101
107
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
105
114
otel_span .parent = MagicMock ()
106
115
otel_span .parent .span_id = int ("abcdef1234567890" , 16 )
107
116
@@ -144,9 +153,12 @@ def test_get_trace_data_with_sentry_trace():
144
153
145
154
def test_get_trace_data_with_sentry_trace_and_baggage ():
146
155
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
150
162
otel_span .parent = MagicMock ()
151
163
otel_span .parent .span_id = int ("abcdef1234567890" , 16 )
152
164
@@ -263,9 +275,12 @@ def test_on_start_transaction():
263
275
otel_span = MagicMock ()
264
276
otel_span .name = "Sample OTel Span"
265
277
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
269
284
otel_span .parent = MagicMock ()
270
285
otel_span .parent .span_id = int ("abcdef1234567890" , 16 )
271
286
@@ -305,9 +320,12 @@ def test_on_start_child():
305
320
otel_span = MagicMock ()
306
321
otel_span .name = "Sample OTel Span"
307
322
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
311
329
otel_span .parent = MagicMock ()
312
330
otel_span .parent .span_id = int ("abcdef1234567890" , 16 )
313
331
@@ -351,8 +369,12 @@ def test_on_end_no_sentry_span():
351
369
otel_span = MagicMock ()
352
370
otel_span .name = "Sample OTel Span"
353
371
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
356
378
357
379
span_processor = SentrySpanProcessor ()
358
380
span_processor .otel_span_map = {}
@@ -372,8 +394,12 @@ def test_on_end_sentry_transaction():
372
394
otel_span = MagicMock ()
373
395
otel_span .name = "Sample OTel Span"
374
396
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
377
403
378
404
fake_sentry_span = MagicMock (spec = Transaction )
379
405
fake_sentry_span .set_context = MagicMock ()
@@ -398,8 +424,12 @@ def test_on_end_sentry_span():
398
424
otel_span = MagicMock ()
399
425
otel_span .name = "Sample OTel Span"
400
426
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
403
433
404
434
fake_sentry_span = MagicMock (spec = Span )
405
435
fake_sentry_span .set_context = MagicMock ()
@@ -425,7 +455,6 @@ def test_link_trace_context_to_error_event():
425
455
"""
426
456
fake_client = MagicMock ()
427
457
fake_client .options = {"instrumenter" : "otel" }
428
- fake_client
429
458
430
459
current_hub = MagicMock ()
431
460
current_hub .client = fake_client
0 commit comments