File tree 3 files changed +16
-1
lines changed
propagator/opentelemetry-propagator-jaeger
src/opentelemetry/propagators/jaeger 3 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
39
39
([ #2705 ] ( https://github.com/open-telemetry/opentelemetry-python/pull/2705 ) )
40
40
- Add entrypoint for metrics exporter
41
41
([ #2748 ] ( https://github.com/open-telemetry/opentelemetry-python/pull/2748 ) )
42
+ - Fix Jaeger propagator usage with NonRecordingSpan
43
+ ([ #2762 ] ( https://github.com/open-telemetry/opentelemetry-python/pull/2762 ) )
42
44
43
45
## [ 1.12.0rc1-0.31b0] ( https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.12.0rc1-0.31b0 ) - 2022-05-17
44
46
Original file line number Diff line number Diff line change @@ -81,7 +81,10 @@ def inject(
81
81
if span_context == trace .INVALID_SPAN_CONTEXT :
82
82
return
83
83
84
- span_parent_id = span .parent .span_id if span .parent else 0
84
+ # Non-recording spans do not have a parent
85
+ span_parent_id = (
86
+ span .parent .span_id if span .is_recording () and span .parent else 0
87
+ )
85
88
trace_flags = span_context .trace_flags
86
89
if trace_flags .sampled :
87
90
trace_flags |= self .DEBUG_FLAG
Original file line number Diff line number Diff line change @@ -230,3 +230,13 @@ def test_extract_invalid_uber_trace_id_header_to_implicit_ctx(self):
230
230
231
231
ctx = FORMAT .extract (carrier )
232
232
self .assertDictEqual (Context (), ctx )
233
+
234
+ def test_non_recording_span_does_not_crash (self ):
235
+ """Make sure propagator does not crash when working with NonRecordingSpan"""
236
+ mock_setter = Mock ()
237
+ span = trace_api .NonRecordingSpan (trace_api .SpanContext (1 , 1 , True ))
238
+ with trace_api .use_span (span , end_on_exit = True ):
239
+ try :
240
+ FORMAT .inject ({}, setter = mock_setter )
241
+ except Exception as exc : # pylint: disable=broad-except
242
+ self .fail (f"Injecting failed for NonRecordingSpan with { exc } " )
You can’t perform that action at this time.
0 commit comments