-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmetrics.go
58 lines (49 loc) · 1.67 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
package main
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
"github.com/prometheus/client_golang/prometheus/promhttp"
"net/http"
)
type metrics struct {
transferRun prometheus.Counter
txAmount prometheus.Counter
addressTotalBalance *prometheus.GaugeVec
addressLockedBalance *prometheus.GaugeVec
addressUtxos *prometheus.GaugeVec
}
func initPrometheus(env envConfig, mux *http.ServeMux) *metrics {
m := &metrics{}
m.transferRun = promauto.NewCounter(prometheus.CounterOpts{
Name: "transfer_runs_count",
Help: "Number of transfer runs",
Namespace: env.MetricsNamespace,
Subsystem: env.MetricsSubsystem,
})
m.txAmount = promauto.NewCounter(prometheus.CounterOpts{
Name: "transfer_amount_total",
Help: "Amount transferred",
Namespace: env.MetricsNamespace,
Subsystem: env.MetricsSubsystem,
})
m.addressTotalBalance = promauto.NewGaugeVec(prometheus.GaugeOpts{
Name: "total_balance",
Help: "Total balance of the address",
Namespace: env.MetricsNamespace,
Subsystem: env.MetricsSubsystem,
}, []string{"address"})
m.addressLockedBalance = promauto.NewGaugeVec(prometheus.GaugeOpts{
Name: "locked_balance",
Help: "Locked balance of the address",
Namespace: env.MetricsNamespace,
Subsystem: env.MetricsSubsystem,
}, []string{"address"})
m.addressUtxos = promauto.NewGaugeVec(prometheus.GaugeOpts{
Name: "utxos",
Help: "Number of UTXOs of the address",
Namespace: env.MetricsNamespace,
Subsystem: env.MetricsSubsystem,
}, []string{"address"})
mux.Handle(env.MetricsPath, promhttp.Handler())
return m
}