fix AttributePropagatingSpanProcessor with NonRecordingSpan as parent#744
fix AttributePropagatingSpanProcessor with NonRecordingSpan as parent#744zhongkechen wants to merge 3 commits into
Conversation
| if not _is_server_kind(span): | ||
| propagation_data = self._propagation_data_extractor(span) | ||
| elif parent_span and _is_server_kind(parent_span): | ||
| elif parent_span and isinstance(parent_span, ReadableSpan) and _is_server_kind(parent_span): |
There was a problem hiding this comment.
Suggestion: This fix correctly guards against NonRecordingSpan parents here, but consider also adding a unit test that exercises on_start with a NonRecordingSpan parent to prevent regressions. The existing test suite likely only tests with ReadableSpan parents.
…bute_propagating_span_processor.py Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
|
I partially am okay with these changes, though I don't agree with this span processor working with NonRecording Spans since there's no SpanKind. |
There was a problem hiding this comment.
instead of isinstance(parent_span, ReadableSpan), could we use parent_span.is_recording() instead?
The OTel spec defines that NonRecordingSpan.is_recording() must return False, so it's a cleaner check that doesn't require importing ReadableSpan and aligns directly with the spec's contract:
elif parent_span and parent_span.is_recording() and _is_server_kind(parent_span):
propagation_data = self._propagation_data_extractor(parent_span)
elif parent_span and parent_span.is_recording():
propagation_data = parent_span.attributes.get(self._propagation_data_key)
|
@zhongkechen Please add unit tests for this change as well and a |
I'm using I thought I should keep the check logic consistent at least in the same method |
I see though I'd still suggest using what is OTel spec aligned instead of using |
|
I don't think Since this is an SDK plugin it should be fine for it to introspect API spans to get at the underlying SDK spans, which is where |
I'm okay with the changes then, @zhongkechen please add unit tests and a changelog entry and we can help merge this |
Issue #, if available:
Fixes: #743
Description of changes:
aws-otel-python-instrumentation/aws-opentelemetry-distro/src/amazon/opentelemetry/distro/attribute_propagating_span_processor.py
Lines 80 to 81 in 28fc34e
When the
parent_spanisn't aReadableSpan(e.g. aNonRecordingSpan),_is_server_kindwould throw an attribute exception because the other types of span may not have thekindattribute.By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.