Newer
Older
// Code generated by go-swagger/go-orusapi; DO NOT EDIT.
// Copyright Orus.io team
{{ if .Copyright -}}// {{ comment .Copyright -}}{{ end }}
package {{ .Package }}
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
)
var (
{{ camelize .Name }}HandlerDuration = prometheus.NewSummaryVec(
prometheus.SummaryOpts{
Name: "orus_api_handler",
Help: "The handlers duration and count.",
Objectives: map[float64]float64{0.9: 0.01, 0.95: 0.01, 0.99: 0.001},
ConstLabels: map[string]string{
"service": "{{.Name}}",
{{- if .Tags }}
"tag": "{{ .Tags }}",
{{- end }}
},
},
[]string{"code"},
)
{{ camelize .Name }}HandlerInFlight = prometheus.NewGauge(
prometheus.GaugeOpts{
Name: "orus_api_handler_in_flight",
Help: "The number of handlers currently running.",
ConstLabels: map[string]string{
"service": "{{.Name}}",
{{- if .Tags }}
"tag": "{{ .Tags }}",
{{- end }}
},
},
)
)
func {{ pascalize .Name }}InstrumentHandler(handler http.Handler) http.Handler {
return promhttp.InstrumentHandlerInFlight({{ camelize .Name }}HandlerInFlight,
promhttp.InstrumentHandlerDuration({{ camelize .Name }}HandlerDuration,
handler,
),
)
}