opentelemetry-go-contrib
opentelemetry-go-contrib copied to clipboard
Question: how to RecordError with otelmux
I would like to record an error on the span created by otelmux middleware whenever an error response is sent.
One thing that comes to mind is to wrap the middleware from otelmux with a custom middleware that would extract the span added by otelmux from the request context whenever it's present, and call RecordError on it when the response is >=400.
This however feels a bit forced and I was wondering if there isn't a more native / correct way to go about this.
There is no callback and such available for otelmux. So yes, a wrapping middleware is the way to go.
@alexgo84 did this answer your question? Can we close this issue?