chi icon indicating copy to clipboard operation
chi copied to clipboard

OpenTelemetry Middleware Proposal

Open jwafle opened this issue 1 year ago • 2 comments

OpenTelemetry is becoming a popular open-source solution for monitoring application performance. Well-defined semantic conventions are supplied for HTTP metrics and traces. See here: https://opentelemetry.io/docs/specs/semconv/http/

In following with their guidance on instrumentation, they recommend implementing instrumentation code in the library for which it is written: https://github.com/open-telemetry/opentelemetry-go-contrib/tree/main/instrumentation#new-instrumentation

If interested, I would be willing to contribute instrumentation code that implements OpenTelemetry metrics and tracing as a middleware for chi. Please let me know if you would like me to proceed with opening a PR.

Thanks.

p.s. thank you for chi, using it is a great experience

jwafle avatar Jul 22 '24 18:07 jwafle

We don't have official go-chi package for OTEL yet, but we might add it to https://github.com/go-chi/telemetry.

However, check out https://github.com/riandyrn/otelchi, which looks very decent.

VojtechVitek avatar Jul 22 '24 19:07 VojtechVitek

go-chi/telemetry seems like a proper place to put this, but would we want to split out separate packages for prometheus instrumentation and OTEL instrumentation?

otelchi does support tracing. In my personal experience, I've found that metrics can be just as, if not more useful in a production setting. I would also argue that bringing the instrumentation into an official repository would help give the package some validity for use in production (as a developer, I would have a hard time arguing to use a small package from a single maintainer in my day job).

jwafle avatar Jul 22 '24 19:07 jwafle