riandyrn/otelchi

panic doesn't mark span as error

Closed this issue · 3 comments

aep commented

the middleware doesn't call recover anywhere, pressumably because otel already does that according to the trace

go.opentelemetry.io/otel/sdk/trace.(*recordingSpan).End.func1()
	/home/aep/.go/pkg/mod/go.opentelemetry.io/otel/sdk@v1.11.0/trace/span.go:396 +0x2a
go.opentelemetry.io/otel/sdk/trace.(*recordingSpan).End(0xc00033e480, {0x0, 0x0, 0xc0000b4780?})
	/home/aep/.go/pkg/mod/go.opentelemetry.io/otel/sdk@v1.11.0/trace/span.go:435 +0x8ee

this records an event, but does not set the span as error.

confusingly, a 404 is set as error, but i don't understand where that's happening either. because otelchi calls span.SetStatus . should it also do that for panic, or is that a problem in otel?

aep commented

it works when using middleware.Recoverer after otelchi, so that otelchi sees a 500.
possibly otel does it correctly but since otelchi always calls span.SetStatus it is overriden?

Closed based on #13 (comment).