Skip to content

tliefheid/prometheus-chi-metric-middleware

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

prometheus-chi-metric-middleware

Easy prometheus http server metrics for the chi router.

Based on chi-prometheus

Install

go get github.com/TomL-dev/prometheus-chi-metric-middleware

Usage

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

Result

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}

TODO

  • custom bucket sizes
  • now by default, it's matched on vars, instead of the actual values. (like /user/{id}). maybe make optional?
  • exclusion patterns?

About

Provide easy prometheus server metrics for the chi router

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages