-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Add Span#RecordError
method to simplify adding error events to spans
#473
Conversation
|
Agree with @lizthegrey. And since this is an implementation of the OpenTelemetry specs, I think we shouldn't be adding new methods to the Span API before changing the specs, I don't know the exactly process for these changes but I'm sure others could help. |
Understandable. I had thought that since #248 wasn't tagged as "blocked on spec" and the new method related specifically to Go error handling it might not require spec changes. I'd be happy to help draft and shepherd changes to the spec through the process if someone can point me in the right direction and maybe show some examples of similar changes that have made it through the process. |
am discussing at spec meeting now (you're welcome to join) |
someone filled me in, what we want is open-telemetry/opentelemetry-specification#427 |
We're clear to use our judgment for 0.3, but we may need to change it between here and 0.4 |
Ok, so based on a brief reading of open-telemetry/opentelemetry-specification#427 it looks like the direction to go would be changing this to |
I think that setting the attribute/status code is actually fine, because otherwise it'll require more complex cross-span/event correlation where just setting an attribute would do. I'll chime in to that effect on the upstream spec discussion |
+1 |
The implementation in the SDK package now relies on existing API methods.
Span#Error
method to simplify setting an error status and message.Span#RecordError
method to simplify adding error events to spans
I try with Jaeger exporter on my forked of gomongowrapper, it's seems like it's needs to called |
That's a good point and something lost when moving from status/attributes to recording an event. I've added a |
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.
Did some nitpicking.
Co-Authored-By: Krzesimir Nowak <qdlacz@gmail.com>
* Ensure complete and unique error type is recorded for defined types * Avoid duplicating logic under test in tests
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.
One last thing (honest!), otherwise looks good.
} | ||
|
||
if cfg.Status != codes.OK { | ||
s.SetStatus(cfg.Status) |
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 line raises questions for me about the SetStatus
API, which is tangential to this PR. The Span.Status field has two fields, the code (passed here) and a message. This should probably set the same err.Error()
as used for the event message, but the SetStatus
API doesn't accept a message string (which is a separate matter).
This has me wondering whether we want to use RecordError(..., WithStatusCode())
as the conventional pattern for recording an error and setting the status. I'm not sure I'd pick this approach -- I'm inclined for there to be two methods, one to record an error event, and one to record an error event plus set the status (i.e., two methods RecordErrorEvent
and RecordErrorStatus
).
Fixes #248.
I wonder whether
Tracer#WithSpan
should invoke this new method with the result of the user-provided function.