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

Fixes Open Telemetry propagation for NonRecordingSpan #1995

Closed
wants to merge 4 commits into from

Conversation

nathanielobrown
Copy link

I was getting an error AttributeError: 'NonRecordingSpan' object has no attribute 'context' which I think might be due to my use of TracerProvider(sampler=TraceIdRatioBased(0.1)), but I'm not sure exactly (I'm an otel noob).

I haven't exhaustively researched the situation here, but it seems like the way the context was fetched from a span was wrong, as there is a clear getter get_span_context that would seems like the more "public" interface than the .context attribute. As supporting evidence, the abstract base class Span has get_span_context but no context defined.

A small piece of feedback: looking at the tests for opentelemetry, in general it seems like they test mock objects rather than than actual objects from the opentelemetry library. Is there a reason for this? Using the underlying objects (span implementations and the like) feels like it would help prevent bugs like this one. At least using the ABC/API interfaces to generate some stubs so we know what we are testing conforms to the interface. Just a thought - I want to help make sure the opentelemetry integration is a success!

Looking forward to hearing your thoughts.

@github-actions
Copy link

github-actions bot commented May 4, 2023

This pull request has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you label it Status: Backlog or Status: In Progress, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@@ -18,6 +19,7 @@
from sentry_sdk.tracing_utils import Baggage



Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This extra blank line is making the linter fail.

@hartungstenio
Copy link
Contributor

I have activated TraceIdRatioBased and started getting this error as well.

@emperorcezar
Copy link

We're experiencing this issue also. The JaegerPropagator had a very similar issue that they fixed. We had to sub-class theirs to get it working and I'm thinking of going the same direction to fix this.

@sentrivana sentrivana self-assigned this Jun 22, 2023
@sentrivana
Copy link
Contributor

Thanks a lot @nathanielobrown for investigating and for the PR! This definitely needs fixing, and based on #2187 it seems there are more places where we're still accessing .context directly. The linked PR also addresses those, so I'll close this in favor of the other one.

As for the tests, it'd make sense to use the actual otel objects/interfaces -- happy for any PRs to improve this!

@sentrivana sentrivana closed this Jun 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants