Easy prometheus http server metrics for the chi router.
Based on chi-prometheus
go get github.com/TomL-dev/prometheus-chi-metric-middleware
import (
chiprometheus "github.com/TomL-dev/prometheus-chi-metric-middleware"
)
r := chi.NewRouter()
metricMiddleware := chiprometheus.NewMiddleware(chiprometheus.Options{
Namespace: "mock",
})
r.Use(metricMiddleware.Handler)
For other info, see the example dir
On the metric
endpoint of prometheus you'll see the timeseries created by the middleware. The following timeseries will be defined:
- [Counter] http_request_total{code, path}
- [Histogram] http_request_duration_nanoseconds{path}
- [Histogram] http_response_size_bytes{path}
- custom bucket sizes
- now by default, it's matched on vars, instead of the actual values. (like /user/{id}). maybe make optional?
- exclusion patterns?