forked from ava-labs/avalanchego
-
Notifications
You must be signed in to change notification settings - Fork 3
/
metrics.go
42 lines (36 loc) · 1.14 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
// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package bootstrap
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/MetalBlockchain/metalgo/utils"
)
type metrics struct {
numFetched, numAccepted prometheus.Counter
fetchETA prometheus.Gauge
}
func newMetrics(namespace string, registerer prometheus.Registerer) (*metrics, error) {
m := &metrics{
numFetched: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "fetched",
Help: "Number of blocks fetched during bootstrapping",
}),
numAccepted: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "accepted",
Help: "Number of blocks accepted during bootstrapping",
}),
fetchETA: prometheus.NewGauge(prometheus.GaugeOpts{
Namespace: namespace,
Name: "eta_fetching_complete",
Help: "ETA in nanoseconds until fetching phase of bootstrapping finishes",
}),
}
err := utils.Err(
registerer.Register(m.numFetched),
registerer.Register(m.numAccepted),
registerer.Register(m.fetchETA),
)
return m, err
}