Skip to content

Commit

Permalink
Merge branch 'main' into issue_2360
Browse files Browse the repository at this point in the history
  • Loading branch information
ocelotl authored Jun 16, 2022
2 parents 4c90726 + b03b5ca commit 2d7a045
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 @@ -39,6 +39,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,10 @@ 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,13 @@ 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"""
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: # pylint: disable=broad-except
self.fail(f"Injecting failed for NonRecordingSpan with {exc}")

0 comments on commit 2d7a045

Please sign in to comment.