/
metrics.go
133 lines (127 loc) · 4.34 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
127
128
129
130
131
132
133
package wrapped
import (
"github.com/prometheus/client_golang/prometheus"
m "github.com/redesblock/mop/core/metrics"
)
type metrics struct {
TotalRPCCalls prometheus.Counter
TotalRPCErrors prometheus.Counter
TransactionReceiptCalls prometheus.Counter
TransactionCalls prometheus.Counter
BlockNumberCalls prometheus.Counter
BlockHeaderCalls prometheus.Counter
BalanceCalls prometheus.Counter
CodeAtCalls prometheus.Counter
NonceAtCalls prometheus.Counter
PendingNonceCalls prometheus.Counter
CallContractCalls prometheus.Counter
SuggestGasPriceCalls prometheus.Counter
EstimateGasCalls prometheus.Counter
SendTransactionCalls prometheus.Counter
FilterLogsCalls prometheus.Counter
ChainIDCalls prometheus.Counter
}
func newMetrics() metrics {
subsystem := "eth_backend"
return metrics{
TotalRPCCalls: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "total_rpc_calls",
Help: "Count of rpc calls",
}),
TotalRPCErrors: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "total_rpc_errors",
Help: "Count of rpc errors",
}),
TransactionCalls: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "calls_transaction",
Help: "Count of eth_getTransaction rpc calls",
}),
TransactionReceiptCalls: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "calls_transaction_receipt",
Help: "Count of eth_getTransactionReceipt rpc errors",
}),
BlockNumberCalls: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "calls_block_number",
Help: "Count of eth_blockNumber rpc calls",
}),
BlockHeaderCalls: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "calls_block_header",
Help: "Count of eth_getBlockByNumber (header only) calls",
}),
BalanceCalls: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "calls_balance",
Help: "Count of eth_getBalance rpc calls",
}),
CodeAtCalls: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "calls_code_at",
Help: "Count of eth_getCode rpc calls",
}),
NonceAtCalls: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "calls_nonce_at",
Help: "Count of eth_getTransactionCount (pending false) rpc calls",
}),
PendingNonceCalls: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "calls_pending_nonce_at",
Help: "Count of eth_getTransactionCount (pending true) rpc calls",
}),
CallContractCalls: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "calls_eth_call",
Help: "Count of eth_call rpc calls",
}),
SuggestGasPriceCalls: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "calls_suggest_gasprice",
Help: "Count of eth_suggestGasPrice rpc calls",
}),
EstimateGasCalls: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "calls_estimate_gasprice",
Help: "Count of eth_estimateGas rpc calls",
}),
SendTransactionCalls: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "calls_send_transaction",
Help: "Count of eth_sendRawTransaction rpc calls",
}),
FilterLogsCalls: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "calls_filter_logs",
Help: "Count of eth_getLogs rpc calls",
}),
ChainIDCalls: prometheus.NewCounter(prometheus.CounterOpts{
Namespace: m.Namespace,
Subsystem: subsystem,
Name: "calls_chain_id",
Help: "Count of eth_chainId rpc calls",
}),
}
}
func (b *wrappedBackend) Metrics() []prometheus.Collector {
return m.PrometheusCollectorsFromFields(b.metrics)
}