-
Notifications
You must be signed in to change notification settings - Fork 9
/
metrics.go
66 lines (60 loc) · 1.94 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
// Copyright 2020 The Swarm Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package traffic
import (
m "github.com/gauss-project/aurorafs/pkg/metrics"
"github.com/prometheus/client_golang/prometheus"
)
type metrics struct {
TotalReceived prometheus.Counter
TotalSent prometheus.Counter
ChequesReceived prometheus.Counter
ChequesSent prometheus.Counter
ChequesRejected prometheus.Counter
AvailableBalance prometheus.Gauge
}
func newMetrics() metrics {
subsystem := "traffic"
return metrics{
TotalReceived: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "total_received",
Help: "Amount of tokens received from peers (income of the node)",
}),
TotalSent: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "total_sent",
Help: "Amount of tokens sent to peers (costs paid by the node)",
}),
ChequesReceived: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "cheques_received",
Help: "Number of cheques received from peers",
}),
ChequesSent: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "cheques_sent",
Help: "Number of cheques sent to peers",
}),
ChequesRejected: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "cheques_rejected",
Help: "Number of cheques rejected",
}),
AvailableBalance: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "available_balance",
Help: "Currently availeble chequebook balance.",
}),
}
}
func (s *Service) Metrics() []prometheus.Collector {
return m.PrometheusCollectorsFromFields(s.metrics)
}