-
Notifications
You must be signed in to change notification settings - Fork 387
Expand file tree
/
Copy pathmetrics.go
More file actions
102 lines (96 loc) · 3.15 KB
/
Copy pathmetrics.go
File metadata and controls
102 lines (96 loc) · 3.15 KB
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
// Copyright 2023 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 salud
import (
m "github.com/ethersphere/bee/v2/pkg/metrics"
"github.com/prometheus/client_golang/prometheus"
)
type metrics struct {
AvgDur prometheus.Gauge
PDur prometheus.Gauge
PConns prometheus.Gauge
NetworkRadius prometheus.Gauge
NeighborhoodRadius prometheus.Gauge
Commitment prometheus.Gauge
ReserveSizePercentErr prometheus.Gauge
Healthy prometheus.Counter
Unhealthy prometheus.Counter
NeighborhoodAvgDur prometheus.Gauge
NeighborCount prometheus.Gauge
}
func newMetrics() metrics {
subsystem := "salud"
return metrics{
AvgDur: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "dur",
Help: "Average duration for snapshot response.",
}),
PDur: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "pdur",
Help: "Percentile of durations for snapshot response.",
}),
PConns: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "pconns",
Help: "Percentile of connections counts.",
}),
NetworkRadius: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "network_radius",
Help: "Most common radius across the connected peers.",
}),
NeighborhoodRadius: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "neighborhood_radius",
Help: "Most common radius across the connected peers.",
}),
Healthy: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "healthy",
Help: "Count of healthy peers.",
}),
Unhealthy: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "unhealthy",
Help: "Count of unhealthy peers.",
}),
Commitment: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "batch_commitment",
Help: "Most common batch commitment.",
}),
ReserveSizePercentErr: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "reserve_size_percentage_err",
Help: "Percentage error of the reservesize relative to the network average.",
}),
// Neighborhood-specific metrics
NeighborhoodAvgDur: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "neighborhood_dur",
Help: "Average duration for snapshot response from neighborhood peers.",
}),
NeighborCount: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "neighbors",
Help: "Number of neighborhood peers.",
}),
}
}
func (s *service) Metrics() []prometheus.Collector {
return m.PrometheusCollectorsFromFields(s.metrics)
}