Monitor Gorilla Mux with OpenTelemetry
gorilla/mux implements a request router and dispatcher for matching incoming requests to their respective handler. It one of the oldest and most popular routers for Go.
This article explains how you can monitor and optimize Gorilla Mux performance using OpenTelemetry observability framework.
What is OpenTelemetry?
Otel allows developers to collect and export telemetry data in a vendor agnostic way. With OpenTelemetry, you can instrument your application once and then add or change vendors without changing the instrumentation, for example, here is a list popular DataDog alternatives that support OpenTelemetry.
OpenTelemetry is available for most programming languages and provides interoperability across different languages and environments.
To install Gorilla Mux OpenTelemetry instrumentation:
go get go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux
You can instrument Gorilla Mux router by installing OpenTelemetry middleware:
import ( "github.com/gorilla/mux" "go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux" ) router := mux.NewRouter() router.Use(otelmux.Middleware("service-name"))
What is Uptrace?
Need a backend to store telemetry data collected by OpenTelemetry instrumentations?
Uptrace is an open source APM for OpenTelemetry with an intuitive query builder, rich dashboards, automatic alerts, and integrations for most languages and frameworks.
You can get started with Uptrace by downloading a DEB/RPM package or a pre-compiled Go binary.