forked from xmidt-org/themis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
metrics.go
65 lines (61 loc) · 1.71 KB
/
metrics.go
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package main
import (
"github.com/xmidt-org/themis/xmetrics"
"github.com/xmidt-org/themis/xmetrics/xmetricshttp"
"github.com/prometheus/client_golang/prometheus"
"go.uber.org/fx"
)
// ServerLabel is the metric label for which internal server (key, claims, etc) a metric is for
const ServerLabel = "server"
// provideMetrics builds the application metrics and makes them available to the container
func provideMetrics() fx.Option {
return fx.Provide(
xmetrics.ProvideCounterVec(
prometheus.CounterOpts{
Name: "server_request_count",
Help: "total incoming HTTP requests",
},
xmetricshttp.DefaultCodeLabel,
xmetricshttp.DefaultMethodLabel,
ServerLabel,
),
xmetrics.ProvideHistogramVec(
prometheus.HistogramOpts{
Name: "server_request_duration_ms",
Help: "tracks incoming request durations in ms",
},
xmetricshttp.DefaultCodeLabel,
xmetricshttp.DefaultMethodLabel,
ServerLabel,
),
xmetrics.ProvideGaugeVec(
prometheus.GaugeOpts{
Name: "server_requests_in_flight",
Help: "tracks the current number of incoming requests being processed",
},
ServerLabel,
),
xmetrics.ProvideCounterVec(
prometheus.CounterOpts{
Name: "client_request_count",
Help: "total outgoing HTTP requests",
},
xmetricshttp.DefaultCodeLabel,
xmetricshttp.DefaultMethodLabel,
),
xmetrics.ProvideHistogramVec(
prometheus.HistogramOpts{
Name: "client_request_count",
Help: "total outgoing HTTP requests",
},
xmetricshttp.DefaultCodeLabel,
xmetricshttp.DefaultMethodLabel,
),
xmetrics.ProvideGaugeVec(
prometheus.GaugeOpts{
Name: "client_requests_in_flight",
Help: "tracks the current number of incoming requests being processed",
},
),
)
}