-
Notifications
You must be signed in to change notification settings - Fork 655
/
tx_metrics.go
144 lines (121 loc) · 3.06 KB
/
tx_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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
// Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.
package metrics
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/ava-labs/avalanchego/vms/platformvm/txs"
)
const txLabel = "tx"
var (
_ txs.Visitor = (*txMetrics)(nil)
txLabels = []string{txLabel}
)
type txMetrics struct {
numTxs *prometheus.CounterVec
}
func newTxMetrics(
namespace string,
registerer prometheus.Registerer,
) (*txMetrics, error) {
m := &txMetrics{
numTxs: prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: namespace,
Name: "txs_accepted",
Help: "number of transactions accepted",
},
txLabels,
),
}
return m, registerer.Register(m.numTxs)
}
func (m *txMetrics) AddValidatorTx(*txs.AddValidatorTx) error {
m.numTxs.With(prometheus.Labels{
txLabel: "add_validator",
}).Inc()
return nil
}
func (m *txMetrics) AddSubnetValidatorTx(*txs.AddSubnetValidatorTx) error {
m.numTxs.With(prometheus.Labels{
txLabel: "add_subnet_validator",
}).Inc()
return nil
}
func (m *txMetrics) AddDelegatorTx(*txs.AddDelegatorTx) error {
m.numTxs.With(prometheus.Labels{
txLabel: "add_delegator",
}).Inc()
return nil
}
func (m *txMetrics) CreateChainTx(*txs.CreateChainTx) error {
m.numTxs.With(prometheus.Labels{
txLabel: "create_chain",
}).Inc()
return nil
}
func (m *txMetrics) CreateSubnetTx(*txs.CreateSubnetTx) error {
m.numTxs.With(prometheus.Labels{
txLabel: "create_subnet",
}).Inc()
return nil
}
func (m *txMetrics) ImportTx(*txs.ImportTx) error {
m.numTxs.With(prometheus.Labels{
txLabel: "import",
}).Inc()
return nil
}
func (m *txMetrics) ExportTx(*txs.ExportTx) error {
m.numTxs.With(prometheus.Labels{
txLabel: "export",
}).Inc()
return nil
}
func (m *txMetrics) AdvanceTimeTx(*txs.AdvanceTimeTx) error {
m.numTxs.With(prometheus.Labels{
txLabel: "advance_time",
}).Inc()
return nil
}
func (m *txMetrics) RewardValidatorTx(*txs.RewardValidatorTx) error {
m.numTxs.With(prometheus.Labels{
txLabel: "reward_validator",
}).Inc()
return nil
}
func (m *txMetrics) RemoveSubnetValidatorTx(*txs.RemoveSubnetValidatorTx) error {
m.numTxs.With(prometheus.Labels{
txLabel: "remove_subnet_validator",
}).Inc()
return nil
}
func (m *txMetrics) TransformSubnetTx(*txs.TransformSubnetTx) error {
m.numTxs.With(prometheus.Labels{
txLabel: "transform_subnet",
}).Inc()
return nil
}
func (m *txMetrics) AddPermissionlessValidatorTx(*txs.AddPermissionlessValidatorTx) error {
m.numTxs.With(prometheus.Labels{
txLabel: "add_permissionless_validator",
}).Inc()
return nil
}
func (m *txMetrics) AddPermissionlessDelegatorTx(*txs.AddPermissionlessDelegatorTx) error {
m.numTxs.With(prometheus.Labels{
txLabel: "add_permissionless_delegator",
}).Inc()
return nil
}
func (m *txMetrics) TransferSubnetOwnershipTx(*txs.TransferSubnetOwnershipTx) error {
m.numTxs.With(prometheus.Labels{
txLabel: "transfer_subnet_ownership",
}).Inc()
return nil
}
func (m *txMetrics) BaseTx(*txs.BaseTx) error {
m.numTxs.With(prometheus.Labels{
txLabel: "base",
}).Inc()
return nil
}