-
Notifications
You must be signed in to change notification settings - Fork 10
/
metrics.go
67 lines (63 loc) · 1.82 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
66
67
// SPDX-FileCopyrightText: 2017 Comcast Cable Communications Management, LLC
// SPDX-License-Identifier: Apache-2.0
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",
},
),
)
}