Why
document that End should handle recording exceptions for panics.
I think that documenting that span.End should handle recording exceptions for panics is a good idea.
In my opinion, this is how we implement recording an exception in the most possible user-friendly way.
Originally posted by @pellared in #7254
What
Document that
|
// End completes the Span. The Span is considered complete and ready to be |
|
// delivered through the rest of the telemetry pipeline after this method |
|
// is called. Therefore, updates to the Span are not allowed after this |
|
// method has been called. |
|
End(options ...SpanEndOption) |
should also record an unhandled panic and set status to Error.
In order to follow https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/exceptions.md#recording-an-exception, then here
|
if recovered := recover(); recovered != nil { |
|
// Record but don't stop the panic. |
|
defer panic(recovered) |
|
opts := []trace.EventOption{ |
|
trace.WithAttributes( |
|
semconv.ExceptionType(typeStr(recovered)), |
|
semconv.ExceptionMessage(fmt.Sprint(recovered)), |
|
), |
|
} |
|
|
|
if config.StackTrace() { |
|
opts = append(opts, trace.WithAttributes( |
|
semconv.ExceptionStacktrace(recordStackTrace()), |
|
)) |
|
} |
|
|
|
s.addEvent(semconv.ExceptionEventName, opts...) |
|
} |
we also should
Why
Originally posted by @pellared in #7254
What
Document that
opentelemetry-go/trace/span.go
Lines 28 to 32 in cba6502
should also record an unhandled panic and set status to Error.
In order to follow https://github.com/open-telemetry/opentelemetry-specification/blob/main/specification/trace/exceptions.md#recording-an-exception, then here
opentelemetry-go/sdk/trace/span.go
Lines 465 to 482 in bc531cb
we also should
Errorwith a description