opentelemetry-go icon indicating copy to clipboard operation
opentelemetry-go copied to clipboard

Add trace.WithStatus option for span.RecordError and trace.WithStatusOnPanic option for span.End

Open amanakin opened this issue 5 months ago • 1 comments

Closes https://github.com/open-telemetry/opentelemetry-go/issues/1677

In this commit I add WithErrorStatus as SpanEndOption and EventOption. With this option we could:

  • Call span.RecordError(err, trace.WithStatus()) and error span status will be set.
  • Call span.End(trace.WithStatusOnPanic()) and if panic will occur error span status will be set.

For example, otelhttp handler doesn't set span's status if panic is occurred: https://github.com/open-telemetry/opentelemetry-go-contrib/blob/1808301d09ad7f9695cb7ebd01244102f49df0d1/instrumentation/net/http/otelhttp/handler.go#L160 With this commit is will be possible to pass trace.WithErrorStatus(true) here and set status.

amanakin avatar Sep 02 '24 20:09 amanakin