Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #2348, add handling for non recording span in jaeger propagator #2762

Merged
merged 3 commits into from
Jun 15, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"""
ocelotl marked this conversation as resolved.
Show resolved Hide resolved
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}')