go-chi / chi

lightweight, idiomatic and composable router for building Go HTTP services
https://go-chi.io
MIT License
18.04k stars 973 forks source link

OpenTelemetry Middleware Proposal #937

Open jwafle opened 1 month ago

jwafle commented 1 month ago

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

VojtechVitek commented 1 month ago

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.

jwafle commented 1 month ago

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).