func Metrics(next http.Handler) http.Handler {
	labels := []string{
		"id",
		"code",
		"handler",
		"method",
	}

	reqTotal := promauto.NewCounterVec(prometheus.CounterOpts{
		Subsystem: "http",
		Name:      "requests_total",
		Help:      "Total number of HTTP requests made",
	}, labels[1:])

	reqTime := promauto.NewHistogramVec(prometheus.HistogramOpts{
		Subsystem: "http",
		Name:      "request_duration_seconds",
		Help:      "The HTTP response duration time",
		Buckets:   prometheus.DefBuckets,
	}, labels)

	hn := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		writer := middleware.NewWrapResponseWriter(w, r.ProtoMajor)
		next.ServeHTTP(writer, r)
		Status(r, writer.Status())
	})

	fn := func(w http.ResponseWriter, r *http.Request) {
		handler := InstrumentHandlerCounter(reqTotal, InstrumentHandlerDuration(reqTime, hn))
		handler.ServeHTTP(w, r)
	}

	return http.HandlerFunc(fn)
}
// Metrics enables metrics for each request
Metrics enables metrics for each request
// Metrics enables metrics for each request
func Metrics(next http.Handler) http.Handler {
	labels := []string{
		"id",
		"code",
		"handler",
		"method",
	}
	reqTotal := promauto.NewCounterVec(prometheus.CounterOpts{
		Subsystem: "http",
		Name:      "requests_total",
		Help:      "Total number of HTTP requests made",
	}, labels[1:])
	reqTime := promauto.NewHistogramVec(prometheus.HistogramOpts{
		Subsystem: "http",
		Name:      "request_duration_seconds",
		Help:      "The HTTP response duration time",
		Buckets:   prometheus.DefBuckets,
	}, labels)
	hn := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
		writer := middleware.NewWrapResponseWriter(w, r.ProtoMajor)
		next.ServeHTTP(writer, r)
		Status(r, writer.Status())
	})
	fn := func(w http.ResponseWriter, r *http.Request) {
		handler := InstrumentHandlerCounter(reqTotal, InstrumentHandlerDuration(reqTime, hn))
		handler.ServeHTTP(w, r)
	}
	return http.HandlerFunc(fn)
}
func Metrics ( next http . Handler ) http . Handler { labels := [ ] string { " " , " " , " " , " " , } reqTotal := promauto . NewCounterVec ( prometheus . CounterOpts { Subsystem : " " , Name : " " , Help : " " , } , labels [ 1 : ] ) reqTime := promauto . NewHistogramVec ( prometheus . HistogramOpts { Subsystem : " " , Name : " " , Help : " " , Buckets : prometheus . DefBuckets , } , labels ) hn := http . HandlerFunc ( func ( w http . ResponseWriter , r * http . Request ) { writer := middleware . NewWrapResponseWriter ( w , r . ProtoMajor ) next . ServeHTTP ( writer , r ) Status ( r , writer . Status ( ) ) } ) fn := func ( w http . ResponseWriter , r * http . Request ) { handler := InstrumentHandlerCounter ( reqTotal , InstrumentHandlerDuration ( reqTime , hn ) ) handler . ServeHTTP ( w , r ) } return http . HandlerFunc ( fn ) }
Metrics enables metrics for each request
Metrics enables metrics for each request