aboutsummaryrefslogtreecommitdiff
path: root/server/metrics/metrics.go
blob: 410235347e2fd45235026cb1275ff99d4666792f (plain)
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
package metrics

import (
	"github.com/prometheus/client_golang/prometheus"
)

// Metrics collects the metrics.
type Metrics struct {
	AuthValid,
	AuthExchange,
	Errs *prometheus.CounterVec
}

// M structure to collect all metrics together.
var M Metrics

// Register metrics and metrics page.
func Register() {
	M = Metrics{
		AuthValid: prometheus.NewCounterVec(prometheus.CounterOpts{
			Namespace: "cashier",
			Subsystem: "auth",
			Name:      "valid_total",
			Help:      "Auth Valid calls",
		}, []string{"module"}),
		AuthExchange: prometheus.NewCounterVec(prometheus.CounterOpts{
			Namespace: "cashier",
			Subsystem: "auth",
			Name:      "exchange_total",
			Help:      "Auth Exchange calls",
		}, []string{"module"}),
		Errs: prometheus.NewCounterVec(prometheus.CounterOpts{
			Namespace: "cashier",
			Subsystem: "sys",
			Name:      "error_total",
			Help:      "Error counts by module",
		}, []string{"module"}),
	}
	prometheus.MustRegister(M.Errs)
	prometheus.MustRegister(M.AuthValid)
	prometheus.MustRegister(M.AuthExchange)
}