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

Does setting span status to Error automatically create span event? #4823

Closed
cheempz opened this issue Jul 10, 2024 · 8 comments
Closed

Does setting span status to Error automatically create span event? #4823

cheempz opened this issue Jul 10, 2024 · 8 comments
Labels
bug Something isn't working

Comments

@cheempz
Copy link

cheempz commented Jul 10, 2024

Original slack post, links changed to relative repo paths:

Just read the excellent article about errors and there's something puzzling me, really appreciate if someone can help clarify. the blog mentioned here and restated similar behaviour here:

When a span status is set to Error, a span event is created automatically, capturing the span’s resulting error message and stack trace as an event on that span.

is this something specified in the tracing API or SDK specs, or implicitly for autoinstrumentation libraries to do if it collects a span and sets Error status on it? from quick scan of specs and Python SDK implementation i'm not seeing anything.
thanks!

What needs to be changed? Per @svrnm please verify if there is something in the blog post that needs to be fixed or if a reference to the spec is missing.

@cheempz cheempz added the bug Something isn't working label Jul 10, 2024
@svrnm
Copy link
Member

svrnm commented Jul 11, 2024

Thanks for raising this @cheempz!

@reese-lee @avillela can you verify if this is somewhere defined in the spec and just not available in Python, or if this is not in the spec?

If it is in the spec, we can raise an issue with python or check if one exists already and close this issue
If it is not in the spec, let's remove that sentence from the blog post. Although we try to avoid changing blog posts after publication, I think it would be justified in this case to avoid future confusion.

@svrnm
Copy link
Member

svrnm commented Jul 11, 2024

@open-telemetry/python-approvers if someone can take a look and help with answering this question, this would be great/can help to expedite the investigation

@xrmx
Copy link
Contributor

xrmx commented Jul 11, 2024

I don't think we have that kind of magic in Python other than sdk's Span constructor will add to the span every event it get passed to it. Span.record_exception will add the exception as event automatically, maybe they meant that?

@cartermp
Copy link
Contributor

It's a convention in instrumentations to create a span event with a stack trace (or other error details), so that may be what was referred to? There's nothing inherent in OTel SDKs that create a span event automatically, though.

@avillela
Copy link
Contributor

Apologies - I think the wording we used might have been a bit confusing.

From my understanding in Python, if you have:

with tracer.start_as_current_span("do_roll", set_status_on_exception=True)

and your span throws an exception, then that span will be marked as an error span.

I believe that tracks with the above comments? If so, I'm happy to modify that sentence in the blog post to clarify the confusion.

@cheempz
Copy link
Author

cheempz commented Jul 16, 2024

Thanks everyone. From the response so far it seems safe to say that various SDKs and instrumentations may automatically collect span exception events when setting the span status to ERROR, but we (specifically our vendor platform) should not make this assumption, correct?

@svrnm
Copy link
Member

svrnm commented Jul 17, 2024

@avillela can you take a look at your blog post and figure out if the sentence can be rephrased to match what is discussed here. As a quick fix, I am also OK with removing the sentence entirely.

Thanks everyone. From the response so far it seems safe to say that various SDKs and instrumentations may automatically collect span exception events when setting the span status to ERROR, but we (specifically our vendor platform) should not make this assumption, correct?

That's my understanding as well, yes.

avillela added a commit to avillela/opentelemetry.io that referenced this issue Jul 17, 2024
svrnm pushed a commit that referenced this issue Jul 17, 2024
@tiffany76
Copy link
Contributor

Closing as completed by #4844.

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

No branches or pull requests

6 participants