-
Notifications
You must be signed in to change notification settings - Fork 179
/
execution_data_sync.go
248 lines (230 loc) · 8.14 KB
/
execution_data_sync.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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
package metrics
import (
"strconv"
"time"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto"
)
type ExecutionDataRequesterV2Collector struct {
fulfilledHeight prometheus.Gauge
receiptsSkipped prometheus.Counter
requestDurations prometheus.Summary
latestSuccessfulRequestHeight prometheus.Gauge
executionDataSizes prometheus.Summary
requestAttempts prometheus.Histogram
requestsFailed *prometheus.CounterVec
requestsCancelled prometheus.Counter
responsesDropped prometheus.Counter
}
func NewExecutionDataRequesterV2Collector() *ExecutionDataRequesterV2Collector {
return &ExecutionDataRequesterV2Collector{
fulfilledHeight: promauto.NewGauge(prometheus.GaugeOpts{
Name: "fulfilled_height",
Namespace: namespaceExecutionDataSync,
Subsystem: subsystemExeDataRequester,
Help: "the latest sealed height for which all execution data has been retrieved and stored locally",
}),
receiptsSkipped: promauto.NewCounter(prometheus.CounterOpts{
Name: "receipts_skipped",
Namespace: namespaceExecutionDataSync,
Subsystem: subsystemExeDataRequester,
Help: "the number of skipped receipts",
}),
requestDurations: promauto.NewSummary(prometheus.SummaryOpts{
Name: "request_durations_ms",
Namespace: namespaceExecutionDataSync,
Subsystem: subsystemExeDataRequester,
Help: "the durations of requests in milliseconds",
Objectives: map[float64]float64{
0.01: 0.001,
0.1: 0.01,
0.25: 0.025,
0.5: 0.05,
0.75: 0.025,
0.9: 0.01,
0.99: 0.001,
},
}),
latestSuccessfulRequestHeight: promauto.NewGauge(prometheus.GaugeOpts{
Name: "latest_successful_request_height",
Namespace: namespaceExecutionDataSync,
Subsystem: subsystemExeDataRequester,
Help: "the block height of the latest successful request",
}),
executionDataSizes: promauto.NewSummary(prometheus.SummaryOpts{
Name: "execution_data_sizes_bytes",
Namespace: namespaceExecutionDataSync,
Subsystem: subsystemExeDataRequester,
Help: "the sizes of Block Execution Data in bytes",
Objectives: map[float64]float64{
0.01: 0.001,
0.1: 0.01,
0.25: 0.025,
0.5: 0.05,
0.75: 0.025,
0.9: 0.01,
0.99: 0.001,
},
}),
requestAttempts: promauto.NewHistogram(prometheus.HistogramOpts{
Name: "request_attempts",
Namespace: namespaceExecutionDataSync,
Subsystem: subsystemExeDataRequester,
Buckets: []float64{1, 2, 3, 4, 5},
Help: "the number of attempts before a request succeeded",
}),
requestsFailed: promauto.NewCounterVec(prometheus.CounterOpts{
Name: "requests_failed",
Namespace: namespaceExecutionDataSync,
Subsystem: subsystemExeDataRequester,
Help: "the number of failed requests",
}, []string{ExecutionDataRequestRetryable}),
requestsCancelled: promauto.NewCounter(prometheus.CounterOpts{
Name: "requests_cancelled",
Namespace: namespaceExecutionDataSync,
Subsystem: subsystemExeDataRequester,
Help: "the number of cancelled requests",
}),
responsesDropped: promauto.NewCounter(prometheus.CounterOpts{
Name: "responses_dropped",
Namespace: namespaceExecutionDataSync,
Subsystem: subsystemExeDataRequester,
Help: "the number of dropped responses",
}),
}
}
func (c *ExecutionDataRequesterV2Collector) FulfilledHeight(blockHeight uint64) {
c.fulfilledHeight.Set(float64(blockHeight))
}
func (c *ExecutionDataRequesterV2Collector) ReceiptSkipped() {
c.receiptsSkipped.Inc()
}
func (c *ExecutionDataRequesterV2Collector) RequestSucceeded(blockHeight uint64, duration time.Duration, totalSize uint64, numberOfAttempts int) {
c.requestDurations.Observe(float64(duration.Milliseconds()))
c.latestSuccessfulRequestHeight.Set(float64(blockHeight))
c.executionDataSizes.Observe(float64(totalSize))
c.requestAttempts.Observe(float64(numberOfAttempts))
}
func (c *ExecutionDataRequesterV2Collector) RequestFailed(duration time.Duration, retryable bool) {
c.requestDurations.Observe(float64(duration.Milliseconds()))
c.requestsFailed.WithLabelValues(strconv.FormatBool(retryable)).Inc()
}
func (c *ExecutionDataRequesterV2Collector) RequestCanceled() {
c.requestsCancelled.Inc()
}
func (c *ExecutionDataRequesterV2Collector) ResponseDropped() {
c.responsesDropped.Inc()
}
type ExecutionDataProviderCollector struct {
computeRootIDDurations prometheus.Summary
numberOfChunks prometheus.Histogram
addBlobsDurations prometheus.Summary
executionDataSizes prometheus.Summary
addBlobsFailed prometheus.Counter
}
func NewExecutionDataProviderCollector() *ExecutionDataProviderCollector {
return &ExecutionDataProviderCollector{
computeRootIDDurations: promauto.NewSummary(prometheus.SummaryOpts{
Name: "compute_root_id_durations_ms",
Namespace: namespaceExecutionDataSync,
Subsystem: subsystemExeDataProvider,
Help: "the durations of computing root IDs in milliseconds",
Objectives: map[float64]float64{
0.01: 0.001,
0.1: 0.01,
0.25: 0.025,
0.5: 0.05,
0.75: 0.025,
0.9: 0.01,
0.99: 0.001,
},
}),
numberOfChunks: promauto.NewHistogram(prometheus.HistogramOpts{
Name: "number_of_chunks",
Namespace: namespaceExecutionDataSync,
Subsystem: subsystemExeDataProvider,
Buckets: []float64{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},
Help: "the number of chunks in a Block Execution Data",
}),
addBlobsDurations: promauto.NewSummary(prometheus.SummaryOpts{
Name: "add_blobs_durations_ms",
Namespace: namespaceExecutionDataSync,
Subsystem: subsystemExeDataProvider,
Help: "the durations of adding blobs in milliseconds",
Objectives: map[float64]float64{
0.01: 0.001,
0.1: 0.01,
0.25: 0.025,
0.5: 0.05,
0.75: 0.025,
0.9: 0.01,
0.99: 0.001,
},
}),
executionDataSizes: promauto.NewSummary(prometheus.SummaryOpts{
Name: "execution_data_sizes_bytes",
Namespace: namespaceExecutionDataSync,
Subsystem: subsystemExeDataProvider,
Help: "the sizes of Block Execution Data in bytes",
Objectives: map[float64]float64{
0.01: 0.001,
0.1: 0.01,
0.25: 0.025,
0.5: 0.05,
0.75: 0.025,
0.9: 0.01,
0.99: 0.001,
},
}),
addBlobsFailed: promauto.NewCounter(prometheus.CounterOpts{
Name: "add_blobs_failed",
Namespace: namespaceExecutionDataSync,
Subsystem: subsystemExeDataProvider,
Help: "the number of failed attempts to add blobs",
}),
}
}
func (c *ExecutionDataProviderCollector) RootIDComputed(duration time.Duration, numberOfChunks int) {
c.computeRootIDDurations.Observe(float64(duration.Milliseconds()))
c.numberOfChunks.Observe(float64(numberOfChunks))
}
func (c *ExecutionDataProviderCollector) AddBlobsSucceeded(duration time.Duration, totalSize uint64) {
c.addBlobsDurations.Observe(float64(duration.Milliseconds()))
c.executionDataSizes.Observe(float64(totalSize))
}
func (c *ExecutionDataProviderCollector) AddBlobsFailed() {
c.addBlobsFailed.Inc()
}
type ExecutionDataPrunerCollector struct {
pruneDurations prometheus.Summary
latestHeightPruned prometheus.Gauge
}
func NewExecutionDataPrunerCollector() *ExecutionDataPrunerCollector {
return &ExecutionDataPrunerCollector{
pruneDurations: promauto.NewSummary(prometheus.SummaryOpts{
Name: "prune_durations_ms",
Namespace: namespaceExecutionDataSync,
Subsystem: subsystemExeDataPruner,
Help: "the durations of pruning in milliseconds",
Objectives: map[float64]float64{
0.01: 0.001,
0.1: 0.01,
0.25: 0.025,
0.5: 0.05,
0.75: 0.025,
0.9: 0.01,
0.99: 0.001,
},
}),
latestHeightPruned: promauto.NewGauge(prometheus.GaugeOpts{
Name: "latest_height_pruned",
Namespace: namespaceExecutionDataSync,
Subsystem: subsystemExeDataPruner,
Help: "the latest height pruned",
}),
}
}
func (c *ExecutionDataPrunerCollector) Pruned(height uint64, duration time.Duration) {
c.pruneDurations.Observe(float64(duration.Milliseconds()))
c.latestHeightPruned.Set(float64(height))
}