forked from ava-labs/avalanchego
-
Notifications
You must be signed in to change notification settings - Fork 4
/
metrics.go
49 lines (42 loc) · 1.41 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
// Copyright (C) 2019-2022, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package avm
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/MetalBlockchain/metalgo/utils/metric"
"github.com/MetalBlockchain/metalgo/utils/wrappers"
)
type metrics struct {
numTxRefreshes, numTxRefreshHits, numTxRefreshMisses prometheus.Counter
apiRequestMetric metric.APIInterceptor
}
func (m *metrics) Initialize(
namespace string,
registerer prometheus.Registerer,
) error {
m.numTxRefreshes = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "tx_refreshes",
Help: "Number of times unique txs have been refreshed",
})
m.numTxRefreshHits = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "tx_refresh_hits",
Help: "Number of times unique txs have not been unique, but were cached",
})
m.numTxRefreshMisses = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: namespace,
Name: "tx_refresh_misses",
Help: "Number of times unique txs have not been unique and weren't cached",
})
apiRequestMetric, err := metric.NewAPIInterceptor(namespace, registerer)
m.apiRequestMetric = apiRequestMetric
errs := wrappers.Errs{}
errs.Add(
err,
registerer.Register(m.numTxRefreshes),
registerer.Register(m.numTxRefreshHits),
registerer.Register(m.numTxRefreshMisses),
)
return errs.Err
}