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

Question: how to RecordError with otelmux

Open alexgo84 opened this issue 1 year ago • 2 comments

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.

alexgo84 avatar Feb 19 '24 16:02 alexgo84

There is no callback and such available for otelmux. So yes, a wrapping middleware is the way to go.

dmathieu avatar Feb 19 '24 18:02 dmathieu

@alexgo84 did this answer your question? Can we close this issue?

dmathieu avatar Feb 27 '24 20:02 dmathieu