/
metrics.go
126 lines (120 loc) · 4.27 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// 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 pushsync
import (
m "github.com/ethersphere/bee/v2/pkg/metrics"
"github.com/prometheus/client_golang/prometheus"
)
type metrics struct {
TotalSent prometheus.Counter
TotalReceived prometheus.Counter
TotalHandlerErrors prometheus.Counter
TotalRequests prometheus.Counter
TotalSendAttempts prometheus.Counter
TotalFailedSendAttempts prometheus.Counter
TotalOutgoing prometheus.Counter
TotalOutgoingErrors prometheus.Counter
InvalidStampErrors prometheus.Counter
StampValidationTime prometheus.HistogramVec
Forwarder prometheus.Counter
Storer prometheus.Counter
TotalHandlerTime prometheus.HistogramVec
PushToPeerTime prometheus.HistogramVec
}
func newMetrics() metrics {
subsystem := "pushsync"
return metrics{
TotalSent: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "total_sent",
Help: "Total chunks sent.",
}),
TotalReceived: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "total_received",
Help: "Total chunks received.",
}),
TotalHandlerErrors: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "total_handler_errors",
Help: "Total no of error occurred while handling an incoming delivery (either while storing or forwarding).",
}),
TotalRequests: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "total_requests",
Help: "Total no of requests to push a chunk into the network (from origin nodes or not).",
}),
TotalSendAttempts: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "total_send_attempts",
Help: "Total no of attempts to push chunk.",
}),
TotalFailedSendAttempts: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "total_failed_send_attempts",
Help: "Total no of failed attempts to push chunk.",
}),
TotalOutgoing: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "total_outgoing",
Help: "Total no of chunks requested to be synced (calls on exported PushChunkToClosest)",
}),
TotalOutgoingErrors: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "total_outgoing_errors",
Help: "Total no of errors of entire operation to sync a chunk (multiple attempts included)",
}),
InvalidStampErrors: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "invalid_stamps",
Help: "No of invalid stamp errors.",
}),
StampValidationTime: *prometheus.NewHistogramVec(prometheus.HistogramOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "stamp_validation_time",
Help: "Time taken to validate stamps.",
}, []string{"status"}),
Forwarder: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "forwarder",
Help: "No of times the peer is a forwarder node.",
}),
Storer: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "storer",
Help: "No of times the peer is a storer node.",
}),
TotalHandlerTime: *prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "total_handler_time",
Help: "Histogram for time taken for the handler.",
}, []string{"status"},
),
PushToPeerTime: *prometheus.NewHistogramVec(
prometheus.HistogramOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "push_peer_time",
Help: "Histogram for time taken to push a chunk to a peer.",
}, []string{"status"},
),
}
}
func (s *PushSync) Metrics() []prometheus.Collector {
return m.PrometheusCollectorsFromFields(s.metrics)
}