Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Code generated by go-swagger with a alpe-api template; DO NOT EDIT.
// Copyright Orus.io team
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: "alpe_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}}",
},
},
[]string{"code"},
)
{{ camelize .Name }}HandlerInFlight = prometheus.NewGauge(
prometheus.GaugeOpts{
Name: "alpe_api_handler_in_flights",
Help: "The number of handlers currently running.",
ConstLabels: map[string]string{
"service": "{{.Name}}",
},
},
)
)
func {{ pascalize .Name }}InstrumentHandler(handler http.Handler) http.Handler {
return promhttp.InstrumentHandlerInFlight({{ camelize .Name }}HandlerInFlight,
promhttp.InstrumentHandlerDuration({{ camelize .Name }}HandlerDuration,
handler,
),
)
}
func init() {
prometheus.MustRegister(
{{ camelize .Name }}HandlerDuration,
{{ camelize .Name }}HandlerInFlight,
)
}