-
Notifications
You must be signed in to change notification settings - Fork 413
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
chore(er): capture exception API #9714
Conversation
We add a new programmatic API for Exception Replay to allow users to capture caught exceptions explicitly.
just checked the API method name and looks good to me :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome. I think there are two things missing:
- we need documentation both on change log here and on exception replay docs to expose this feature
- figure out if
capture_exception()
works on non service entry spans with Error Tracking. if that not the case - make sure we document this as known limitation or have a follow up PR to find a solution
|
||
try: | ||
span = tracer.current_span() | ||
if span is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how this works when
- a user call capture_exception() multiple times? will the first one/last one win? do we capture all snapshots multiple times?
- how this works if the exception also propagate to the span it self? is that same as call "capture_exception" twice?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Multiple calls would cause the data to be emitted multiple times. We could probably guard against this by checking if the span has error
already set, and skip.
how this works if the exception also propagate to the span
I'm not quite sure I understand this. With this call we are setting an error on the span. However, we don't expect this to be used when the exceptions are not handled. This will only work in an exception handler, as anywhere else in the code there won't be an exception to attach to a span. If the exception is re-raised within an exception block however, then the tracer will trigger the capturing of debug data a second time.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You got it. Therefore, I think this logic is little broken and should emit debug info only the last/first error that was assigned to the span.
from ddtrace import tracer | ||
|
||
try: | ||
span = tracer.current_span() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if trace._current_span() is not the service entry, will this still work?
I heard there is a tag ET support to index that span error if it not the service entry. maybe this should also set that tag. However, I can't seem to find it on their docs. so maybe this should add tags to service entry span (or both entry and current) or simple abort for non-entry?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if trace._current_span() is not the service entry, will this still work?
This will put debug info on the current span, regardless of what the span is. So any limitations are probably not due to "us" I'd expect
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yup. this is broken as non entry spans are not get indexed and there is no way for the user to query on that and it would not appear in Error tracking. so not sure why we allow the user to do it in the first place.
Closing in favour of #10430. |
Pull request was closed
We add a new programmatic API for Exception Replay to allow users to capture caught exceptions explicitly.
Checklist
Reviewer Checklist