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

AttributeError: 'NonRecordingSpan' object has no attribute 'parent' #2348

Closed
Zhouhao12345 opened this issue Dec 31, 2021 · 4 comments · Fixed by #2762
Closed

AttributeError: 'NonRecordingSpan' object has no attribute 'parent' #2348

Zhouhao12345 opened this issue Dec 31, 2021 · 4 comments · Fixed by #2762
Labels
bug Something isn't working

Comments

@Zhouhao12345
Copy link

Zhouhao12345 commented Dec 31, 2021

[Environment]

python==3.7.1
opentelemetry-api==1.7.1
opentelemetry-exporter-jaeger==1.7.1
opentelemetry-propagator-jaeger==1.7.1
opentelemetry-sdk==1.7.1

OTEL_TRACES_SAMPLER=traceidratio
OTEL_TRACES_SAMPLER_ARG=0

My Code :
image

[Issue]

0 rate for TraceIdRatioBased sampler to create the NonRecordingSpan, which with no parent attribute.
Then I try to inject carrier with Jaeger Propagator. Following exception happened:
'NonRecordingSpan' object has no attribute 'parent' File "/usr/local/lib/python3.7/dist-packages/opentelemetry/propagators/jaeger/__init__.py", line 84, in inject span_parent_id = span.parent.span_id if span.parent else 0

[expected behavior]

It should return with empty carrier without any exception.

@Zhouhao12345 Zhouhao12345 added the bug Something isn't working label Dec 31, 2021
@Zhouhao12345 Zhouhao12345 changed the title Propagators Jaeger Can't Inject NotRecordingSpan with Valid Span Context Propagators Jaeger Can't Inject carrier with NotRecordingSpan with Valid Span Context Dec 31, 2021
@Zhouhao12345 Zhouhao12345 changed the title Propagators Jaeger Can't Inject carrier with NotRecordingSpan with Valid Span Context AttributeError: 'NonRecordingSpan' object has no attribute 'parent' Dec 31, 2021
@bluesliverx
Copy link
Contributor

We've been running into this as well. Seems like it should be a simple fix, just checking if the parent attribute is present. For now I think I'll work around it by setting a real span if it's a non-recording span.

bluesliverx pushed a commit to bluesliverx/opentelemetry-python that referenced this issue Jun 14, 2022
bluesliverx pushed a commit to bluesliverx/opentelemetry-python that referenced this issue Jun 14, 2022
@ocelotl
Copy link
Contributor

ocelotl commented Jun 14, 2022

@bluesliverx this issue is a bit old, do you have a reproducible example that uses the latest version of our components?

@ocelotl
Copy link
Contributor

ocelotl commented Jun 14, 2022

@bluesliverx this issue is a bit old, do you have a reproducible example that uses the latest version of our components?

Nevermind, I see you submitted #2762, thanks!

bluesliverx added a commit to bluesliverx/opentelemetry-python that referenced this issue Jun 14, 2022
ocelotl pushed a commit that referenced this issue Jun 15, 2022
…2762)

* Fix #2348, add handling for non recording span in jaeger exporter

* Fix pylint errors

* Changes for black
@bluesliverx
Copy link
Contributor

@ocelotl, is there info on the release schedule or is it just "whenever we feel like it"? ;) Just curious, I'm good with either way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants