Skip to content

Commit

Permalink
Fix open-telemetry#2348, add handling for non recording span in jaege…
Browse files Browse the repository at this point in the history
…r exporter
  • Loading branch information
bluesliverx committed Jun 14, 2022
1 parent ca7a3fa commit 4541883
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
([#2705](https://github.com/open-telemetry/opentelemetry-python/pull/2705))
- Add entrypoint for metrics exporter
([#2748](https://github.com/open-telemetry/opentelemetry-python/pull/2748))
- Fix Jaeger propagator usage with NonRecordingSpan
([#2762](https://github.com/open-telemetry/opentelemetry-python/pull/2762))

## [1.12.0rc1-0.31b0](https://github.com/open-telemetry/opentelemetry-python/releases/tag/v1.12.0rc1-0.31b0) - 2022-05-17

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ def inject(
if span_context == trace.INVALID_SPAN_CONTEXT:
return

span_parent_id = span.parent.span_id if span.parent else 0
# Non-recording spans do not have a parent
span_parent_id = span.parent.span_id if span.is_recording() and span.parent else 0
trace_flags = span_context.trace_flags
if trace_flags.sampled:
trace_flags |= self.DEBUG_FLAG
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,3 +230,15 @@ def test_extract_invalid_uber_trace_id_header_to_implicit_ctx(self):

ctx = FORMAT.extract(carrier)
self.assertDictEqual(Context(), ctx)

def test_non_recording_span_does_not_crash(self):
"""Make sure propagator does not crash when working with NonRecordingSpan"""
tracer = trace.TracerProvider().get_tracer("sdk_tracer_provider")
mock_setter = Mock()
span = trace_api.NonRecordingSpan(trace_api.SpanContext(1, 1, True))
with trace_api.use_span(span, end_on_exit=True):
try:
FORMAT.inject({}, setter=mock_setter)
except Exception as exc:
self.fail(f'Injecting failed for NonRecordingSpan with {exc}')

0 comments on commit 4541883

Please sign in to comment.