envio 3.3.0 → 3.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/package.json +6 -7
  2. package/src/ChainFetching.res +4 -32
  3. package/src/ChainFetching.res.mjs +2 -12
  4. package/src/ChainState.res +73 -53
  5. package/src/ChainState.res.mjs +61 -30
  6. package/src/ChainState.resi +13 -17
  7. package/src/Config.res +5 -0
  8. package/src/Config.res.mjs +1 -0
  9. package/src/CrossChainState.res +2 -8
  10. package/src/CrossChainState.res.mjs +6 -8
  11. package/src/CrossChainState.resi +1 -0
  12. package/src/EffectState.res +183 -44
  13. package/src/EffectState.res.mjs +134 -26
  14. package/src/EffectState.resi +26 -3
  15. package/src/EventProcessing.res +14 -9
  16. package/src/EventProcessing.res.mjs +7 -7
  17. package/src/FetchState.res +18 -29
  18. package/src/FetchState.res.mjs +20 -37
  19. package/src/IndexerState.res +280 -31
  20. package/src/IndexerState.res.mjs +234 -25
  21. package/src/IndexerState.resi +22 -0
  22. package/src/LoadLayer.res +19 -65
  23. package/src/LoadLayer.res.mjs +13 -55
  24. package/src/Main.res +42 -23
  25. package/src/Main.res.mjs +32 -35
  26. package/src/Metrics.res +943 -66
  27. package/src/Metrics.res.mjs +367 -50
  28. package/src/Persistence.res +3 -0
  29. package/src/PgStorage.res +3 -8
  30. package/src/PgStorage.res.mjs +3 -4
  31. package/src/PruneStaleHistory.res +1 -1
  32. package/src/PruneStaleHistory.res.mjs +1 -2
  33. package/src/Rollback.res +4 -5
  34. package/src/Rollback.res.mjs +2 -3
  35. package/src/SimulateItems.res.mjs +3 -21
  36. package/src/TestIndexer.res.mjs +4 -23
  37. package/src/TestIndexerProxyStorage.res +1 -0
  38. package/src/TestIndexerProxyStorage.res.mjs +1 -1
  39. package/src/Writing.res +3 -5
  40. package/src/Writing.res.mjs +3 -6
  41. package/src/bindings/ClickHouse.res +101 -17
  42. package/src/bindings/ClickHouse.res.mjs +58 -19
  43. package/src/bindings/NodeJs.res +64 -0
  44. package/src/bindings/NodeJs.res.mjs +6 -0
  45. package/src/sources/HyperSyncClient.res +5 -11
  46. package/src/sources/SourceManager.res +72 -27
  47. package/src/sources/SourceManager.res.mjs +81 -11
  48. package/src/sources/SourceManager.resi +14 -0
  49. package/src/tui/Tui.res +1 -1
  50. package/src/tui/Tui.res.mjs +2 -2
  51. package/src/Prometheus.res +0 -789
  52. package/src/Prometheus.res.mjs +0 -847
  53. package/src/bindings/PromClient.res +0 -72
  54. package/src/bindings/PromClient.res.mjs +0 -38
@@ -1,847 +0,0 @@
1
- // Generated by ReScript, PLEASE EDIT WITH CARE
2
-
3
- import * as Utils from "./Utils.res.mjs";
4
- import * as PromClient from "./bindings/PromClient.res.mjs";
5
- import * as Performance from "./bindings/Performance.res.mjs";
6
- import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
7
- import * as Stdlib_JsError from "@rescript/runtime/lib/es6/Stdlib_JsError.js";
8
- import * as S$RescriptSchema from "rescript-schema/src/S.res.mjs";
9
-
10
- function schemaIsString(_schema) {
11
- while (true) {
12
- let schema = _schema;
13
- let match = schema.t;
14
- if (typeof match !== "object") {
15
- return match === "string";
16
- }
17
- switch (match.TAG) {
18
- case "option" :
19
- case "null" :
20
- _schema = match._0;
21
- continue;
22
- default:
23
- return false;
24
- }
25
- };
26
- }
27
-
28
- function getLabelNames(schema) {
29
- let match = schema.t;
30
- if (typeof match !== "object") {
31
- return {
32
- TAG: "Error",
33
- _0: "Label schema must be an object"
34
- };
35
- }
36
- if (match.TAG !== "object") {
37
- return {
38
- TAG: "Error",
39
- _0: "Label schema must be an object"
40
- };
41
- }
42
- let items = match.items;
43
- let nonStringFields = Stdlib_Array.reduce(items, [], (nonStringFields, item) => {
44
- if (schemaIsString(item.schema)) {
45
- return nonStringFields;
46
- } else {
47
- return nonStringFields.concat([item.location]);
48
- }
49
- });
50
- if (nonStringFields.length === 0) {
51
- return {
52
- TAG: "Ok",
53
- _0: items.map(item => item.location)
54
- };
55
- }
56
- let nonStringItems = nonStringFields.join(", ");
57
- return {
58
- TAG: "Error",
59
- _0: `Label schema must be an object with string (or optional string) values. Non string values: ` + nonStringItems
60
- };
61
- }
62
-
63
- let Labels = {
64
- schemaIsString: schemaIsString,
65
- getLabelNames: getLabelNames
66
- };
67
-
68
- let metricNames = new Set();
69
-
70
- function MakeSafePromMetric(M) {
71
- let makeOrThrow = (name, help, labelSchema) => {
72
- let labelNames = getLabelNames(labelSchema);
73
- if (labelNames.TAG !== "Ok") {
74
- return Stdlib_JsError.throwWithMessage(labelNames._0);
75
- }
76
- if (metricNames.has(name)) {
77
- return Stdlib_JsError.throwWithMessage("Duplicate prometheus metric name: " + name);
78
- }
79
- metricNames.add(name);
80
- let metric = M.make({
81
- name: name,
82
- help: help,
83
- labelNames: labelNames._0
84
- });
85
- return {
86
- metric: metric,
87
- labelSchema: labelSchema
88
- };
89
- };
90
- let handleFloat = (param, labels, value) => M.handleFloat(M.labels(param.metric, S$RescriptSchema.reverseConvertToJsonOrThrow(labels, param.labelSchema)), value);
91
- let handleInt = (param, labels, value) => M.handleInt(M.labels(param.metric, S$RescriptSchema.reverseConvertToJsonOrThrow(labels, param.labelSchema)), value);
92
- let increment = (param, labels) => M.labels(param.metric, S$RescriptSchema.reverseConvertToJsonOrThrow(labels, param.labelSchema)).inc();
93
- let incrementMany = (param, labels, value) => M.labels(param.metric, S$RescriptSchema.reverseConvertToJsonOrThrow(labels, param.labelSchema)).inc(value);
94
- return {
95
- makeOrThrow: makeOrThrow,
96
- handleInt: handleInt,
97
- handleFloat: handleFloat,
98
- increment: increment,
99
- incrementMany: incrementMany
100
- };
101
- }
102
-
103
- let make = PromClient.Counter.makeCounter;
104
-
105
- function makeOrThrow(name, help, labelSchema) {
106
- let labelNames = getLabelNames(labelSchema);
107
- if (labelNames.TAG !== "Ok") {
108
- return Stdlib_JsError.throwWithMessage(labelNames._0);
109
- }
110
- if (metricNames.has(name)) {
111
- return Stdlib_JsError.throwWithMessage("Duplicate prometheus metric name: " + name);
112
- }
113
- metricNames.add(name);
114
- let metric = make({
115
- name: name,
116
- help: help,
117
- labelNames: labelNames._0
118
- });
119
- return {
120
- metric: metric,
121
- labelSchema: labelSchema
122
- };
123
- }
124
-
125
- function handleFloat(param, labels, value) {
126
- let prim0 = param.metric.labels(S$RescriptSchema.reverseConvertToJsonOrThrow(labels, param.labelSchema));
127
- prim0.inc(value);
128
- }
129
-
130
- function handleInt(param, labels, value) {
131
- let prim0 = param.metric.labels(S$RescriptSchema.reverseConvertToJsonOrThrow(labels, param.labelSchema));
132
- prim0.inc(value);
133
- }
134
-
135
- function increment(param, labels) {
136
- return param.metric.labels(S$RescriptSchema.reverseConvertToJsonOrThrow(labels, param.labelSchema)).inc();
137
- }
138
-
139
- function incrementMany(param, labels, value) {
140
- return param.metric.labels(S$RescriptSchema.reverseConvertToJsonOrThrow(labels, param.labelSchema)).inc(value);
141
- }
142
-
143
- let SafeCounter = {
144
- makeOrThrow: makeOrThrow,
145
- handleInt: handleInt,
146
- handleFloat: handleFloat,
147
- increment: increment,
148
- incrementMany: incrementMany
149
- };
150
-
151
- let make$1 = PromClient.Gauge.makeGauge;
152
-
153
- function makeOrThrow$1(name, help, labelSchema) {
154
- let labelNames = getLabelNames(labelSchema);
155
- if (labelNames.TAG !== "Ok") {
156
- return Stdlib_JsError.throwWithMessage(labelNames._0);
157
- }
158
- if (metricNames.has(name)) {
159
- return Stdlib_JsError.throwWithMessage("Duplicate prometheus metric name: " + name);
160
- }
161
- metricNames.add(name);
162
- let metric = make$1({
163
- name: name,
164
- help: help,
165
- labelNames: labelNames._0
166
- });
167
- return {
168
- metric: metric,
169
- labelSchema: labelSchema
170
- };
171
- }
172
-
173
- function handleFloat$1(param, labels, value) {
174
- let prim0 = param.metric.labels(S$RescriptSchema.reverseConvertToJsonOrThrow(labels, param.labelSchema));
175
- prim0.set(value);
176
- }
177
-
178
- function handleInt$1(param, labels, value) {
179
- let prim0 = param.metric.labels(S$RescriptSchema.reverseConvertToJsonOrThrow(labels, param.labelSchema));
180
- prim0.set(value);
181
- }
182
-
183
- function increment$1(param, labels) {
184
- return param.metric.labels(S$RescriptSchema.reverseConvertToJsonOrThrow(labels, param.labelSchema)).inc();
185
- }
186
-
187
- function incrementMany$1(param, labels, value) {
188
- return param.metric.labels(S$RescriptSchema.reverseConvertToJsonOrThrow(labels, param.labelSchema)).inc(value);
189
- }
190
-
191
- let SafeGauge = {
192
- makeOrThrow: makeOrThrow$1,
193
- handleInt: handleInt$1,
194
- handleFloat: handleFloat$1,
195
- increment: increment$1,
196
- incrementMany: incrementMany$1
197
- };
198
-
199
- let loadTimeCounter = PromClient.Counter.makeCounter({
200
- name: "envio_preload_seconds",
201
- help: "Cumulative time spent on preloading entities during batch processing."
202
- });
203
-
204
- let handlerTimeCounter = PromClient.Counter.makeCounter({
205
- name: "envio_processing_seconds",
206
- help: "Cumulative time spent executing event handlers during batch processing."
207
- });
208
-
209
- function registerMetrics(loadDuration, handlerDuration) {
210
- loadTimeCounter.inc(loadDuration);
211
- handlerTimeCounter.inc(handlerDuration);
212
- }
213
-
214
- let ProcessingBatch = {
215
- loadTimeCounter: loadTimeCounter,
216
- handlerTimeCounter: handlerTimeCounter,
217
- registerMetrics: registerMetrics
218
- };
219
-
220
- let chainIdLabelsSchema = S$RescriptSchema.object(s => s.f("chainId", S$RescriptSchema.coerce(S$RescriptSchema.string, S$RescriptSchema.int)));
221
-
222
- let gauge = makeOrThrow$1("envio_progress_ready", "Whether the chain is fully synced to the head.", chainIdLabelsSchema);
223
-
224
- let legacyGauge = PromClient.Gauge.makeGauge({
225
- name: "hyperindex_synced_to_head",
226
- help: "All chains fully synced"
227
- });
228
-
229
- function init(chainId) {
230
- handleInt$1(gauge, chainId, 0);
231
- }
232
-
233
- function set(chainId) {
234
- handleInt$1(gauge, chainId, 1);
235
- }
236
-
237
- function setAllReady() {
238
- legacyGauge.set(1);
239
- }
240
-
241
- let ProgressReady = {
242
- gauge: gauge,
243
- legacyGauge: legacyGauge,
244
- init: init,
245
- set: set,
246
- setAllReady: setAllReady
247
- };
248
-
249
- let handlerLabelsSchema = S$RescriptSchema.schema(s => ({
250
- contract: s.m(S$RescriptSchema.string),
251
- event: s.m(S$RescriptSchema.string)
252
- }));
253
-
254
- let timeCounter = makeOrThrow("envio_processing_handler_seconds", "Cumulative time spent inside individual event handler executions.", handlerLabelsSchema);
255
-
256
- let count = makeOrThrow("envio_processing_handler_total", "Total number of individual event handler executions.", handlerLabelsSchema);
257
-
258
- function increment$2(contract, event, duration) {
259
- let labels = {
260
- contract: contract,
261
- event: event
262
- };
263
- handleFloat(timeCounter, labels, duration);
264
- increment(count, labels);
265
- }
266
-
267
- let ProcessingHandler = {
268
- timeCounter: timeCounter,
269
- count: count,
270
- increment: increment$2
271
- };
272
-
273
- let timeCounter$1 = makeOrThrow("envio_preload_handler_seconds", "Wall-clock time spent inside individual preload handler executions.", handlerLabelsSchema);
274
-
275
- let count$1 = makeOrThrow("envio_preload_handler_total", "Total number of individual preload handler executions.", handlerLabelsSchema);
276
-
277
- let sumTimeCounter = makeOrThrow("envio_preload_handler_seconds_total", "Cumulative time spent inside individual preload handler executions. Can exceed wall-clock time due to parallel execution.", handlerLabelsSchema);
278
-
279
- let operations = {};
280
-
281
- function makeKey(contract, event) {
282
- return contract + ":" + event;
283
- }
284
-
285
- function startOperation(contract, event) {
286
- let key = makeKey(contract, event);
287
- let operationRef = operations[key];
288
- if (operationRef !== undefined) {
289
- operationRef.pendingCount = operationRef.pendingCount + 1 | 0;
290
- } else {
291
- operations[key] = {
292
- pendingCount: 1,
293
- timerRef: Performance.now()
294
- };
295
- }
296
- return Performance.now();
297
- }
298
-
299
- function endOperation(timerRef, contract, event) {
300
- let key = makeKey(contract, event);
301
- let labels = {
302
- contract: contract,
303
- event: event
304
- };
305
- let operationRef = operations[key];
306
- operationRef.pendingCount = operationRef.pendingCount - 1 | 0;
307
- if (operationRef.pendingCount === 0) {
308
- handleFloat(timeCounter$1, labels, Performance.secondsSince(operationRef.timerRef));
309
- Utils.Dict.deleteInPlace(operations, key);
310
- }
311
- handleFloat(sumTimeCounter, labels, Performance.secondsSince(timerRef));
312
- increment(count$1, labels);
313
- }
314
-
315
- let PreloadHandler = {
316
- timeCounter: timeCounter$1,
317
- count: count$1,
318
- sumTimeCounter: sumTimeCounter,
319
- operations: operations,
320
- makeKey: makeKey,
321
- startOperation: startOperation,
322
- endOperation: endOperation
323
- };
324
-
325
- let timeCounter$2 = makeOrThrow("envio_fetching_block_range_seconds", "Cumulative time spent fetching block ranges.", chainIdLabelsSchema);
326
-
327
- let parseTimeCounter = makeOrThrow("envio_fetching_block_range_parse_seconds", "Cumulative time spent parsing block range fetch responses.", chainIdLabelsSchema);
328
-
329
- let count$2 = makeOrThrow("envio_fetching_block_range_total", "Total number of block range fetch operations.", chainIdLabelsSchema);
330
-
331
- let eventsCount = makeOrThrow("envio_fetching_block_range_events_total", "Cumulative number of events fetched across all block range operations.", chainIdLabelsSchema);
332
-
333
- let sizeCounter = makeOrThrow("envio_fetching_block_range_size", "Cumulative number of blocks covered across all block range fetch operations.", chainIdLabelsSchema);
334
-
335
- function increment$3(chainId, totalTimeElapsed, parsingTimeElapsed, numEvents, blockRangeSize) {
336
- handleFloat(timeCounter$2, chainId, totalTimeElapsed);
337
- handleFloat(parseTimeCounter, chainId, parsingTimeElapsed);
338
- increment(count$2, chainId);
339
- handleInt(eventsCount, chainId, numEvents);
340
- handleInt(sizeCounter, chainId, blockRangeSize);
341
- }
342
-
343
- let FetchingBlockRange = {
344
- timeCounter: timeCounter$2,
345
- parseTimeCounter: parseTimeCounter,
346
- count: count$2,
347
- eventsCount: eventsCount,
348
- sizeCounter: sizeCounter,
349
- increment: increment$3
350
- };
351
-
352
- let gauge$1 = makeOrThrow$1("envio_indexing_known_height", "The latest known block number reported by the active indexing source. This value may lag behind the actual chain height, as it is updated only when needed.", chainIdLabelsSchema);
353
-
354
- function set$1(blockNumber, chainId) {
355
- handleInt$1(gauge$1, chainId, blockNumber);
356
- }
357
-
358
- let IndexingKnownHeight = {
359
- gauge: gauge$1,
360
- set: set$1
361
- };
362
-
363
- let gauge$2 = makeOrThrow$1("envio_info", "Information about the indexer", S$RescriptSchema.schema(s => ({
364
- version: s.m(S$RescriptSchema.string)
365
- })));
366
-
367
- function set$2(version) {
368
- handleInt$1(gauge$2, {
369
- version: version
370
- }, 1);
371
- }
372
-
373
- let Info = {
374
- gauge: gauge$2,
375
- set: set$2
376
- };
377
-
378
- let gauge$3 = PromClient.Gauge.makeGauge({
379
- name: "envio_process_start_time_seconds",
380
- help: "Start time of the process since unix epoch in seconds."
381
- });
382
-
383
- function set$3() {
384
- gauge$3.set(Date.now() / 1000.0);
385
- }
386
-
387
- let ProcessStartTimeSeconds = {
388
- gauge: gauge$3,
389
- set: set$3
390
- };
391
-
392
- let gauge$4 = makeOrThrow$1("envio_indexing_concurrency", "The number of executing concurrent queries to the chain data-source.", chainIdLabelsSchema);
393
-
394
- function set$4(concurrency, chainId) {
395
- handleInt$1(gauge$4, chainId, concurrency);
396
- }
397
-
398
- let IndexingConcurrency = {
399
- gauge: gauge$4,
400
- set: set$4
401
- };
402
-
403
- let gauge$5 = makeOrThrow$1("envio_indexing_partitions", "The number of partitions used to split fetching logic by addresses and block ranges.", chainIdLabelsSchema);
404
-
405
- function set$5(partitionsCount, chainId) {
406
- handleInt$1(gauge$5, chainId, partitionsCount);
407
- }
408
-
409
- let IndexingPartitions = {
410
- gauge: gauge$5,
411
- set: set$5
412
- };
413
-
414
- let counter = makeOrThrow("envio_indexing_idle_seconds", "The time the indexer source syncing has been idle. A high value may indicate the source sync is a bottleneck.", chainIdLabelsSchema);
415
-
416
- let IndexingIdleTime = {
417
- counter: counter
418
- };
419
-
420
- let counter$1 = makeOrThrow("envio_indexing_source_waiting_seconds", "The time the indexer has been waiting for new blocks.", chainIdLabelsSchema);
421
-
422
- let IndexingSourceWaitingTime = {
423
- counter: counter$1
424
- };
425
-
426
- let counter$2 = makeOrThrow("envio_indexing_source_querying_seconds", "The time spent performing queries to the chain data-source.", chainIdLabelsSchema);
427
-
428
- let IndexingQueryTime = {
429
- counter: counter$2
430
- };
431
-
432
- let gauge$6 = makeOrThrow$1("envio_indexing_buffer_size", "The current number of items in the indexing buffer.", chainIdLabelsSchema);
433
-
434
- function set$6(bufferSize, chainId) {
435
- handleInt$1(gauge$6, chainId, bufferSize);
436
- }
437
-
438
- let IndexingBufferSize = {
439
- gauge: gauge$6,
440
- set: set$6
441
- };
442
-
443
- let gauge$7 = PromClient.Gauge.makeGauge({
444
- name: "envio_indexing_target_buffer_size",
445
- help: "The indexer-wide target buffer size shared across all chains. The actual number of items in the queue may exceed this value, but the indexer always tries to keep the buffer filled up to this target."
446
- });
447
-
448
- function set$7(targetBufferSize) {
449
- gauge$7.set(targetBufferSize);
450
- }
451
-
452
- let IndexingTargetBufferSize = {
453
- gauge: gauge$7,
454
- set: set$7
455
- };
456
-
457
- let gauge$8 = makeOrThrow$1("envio_indexing_buffer_block", "The highest block number that has been fully fetched by the indexer.", chainIdLabelsSchema);
458
-
459
- function set$8(blockNumber, chainId) {
460
- handleInt$1(gauge$8, chainId, blockNumber);
461
- }
462
-
463
- let IndexingBufferBlockNumber = {
464
- gauge: gauge$8,
465
- set: set$8
466
- };
467
-
468
- let gauge$9 = makeOrThrow$1("envio_indexing_end_block", "The block number to stop indexing at. (inclusive)", chainIdLabelsSchema);
469
-
470
- function set$9(endBlock, chainId) {
471
- handleInt$1(gauge$9, chainId, endBlock);
472
- }
473
-
474
- let IndexingEndBlock = {
475
- gauge: gauge$9,
476
- set: set$9
477
- };
478
-
479
- let sourceLabelsSchema = S$RescriptSchema.schema(s => ({
480
- source: s.m(S$RescriptSchema.string),
481
- chainId: s.m(S$RescriptSchema.coerce(S$RescriptSchema.string, S$RescriptSchema.int))
482
- }));
483
-
484
- let gauge$10 = makeOrThrow$1("envio_source_known_height", "The latest known block number reported by the source. This value may lag behind the actual chain height, as it is updated only when queried.", sourceLabelsSchema);
485
-
486
- function set$10(sourceName, chainId, blockNumber) {
487
- handleInt$1(gauge$10, {
488
- source: sourceName,
489
- chainId: chainId
490
- }, blockNumber);
491
- }
492
-
493
- let SourceHeight = {
494
- gauge: gauge$10,
495
- set: set$10
496
- };
497
-
498
- let counter$3 = makeOrThrow("envio_reorg_detected_total", "Total number of reorgs detected", chainIdLabelsSchema);
499
-
500
- function increment$4(chain) {
501
- increment(counter$3, chain);
502
- }
503
-
504
- let ReorgCount = {
505
- counter: counter$3,
506
- increment: increment$4
507
- };
508
-
509
- let gauge$11 = makeOrThrow$1("envio_reorg_detected_block", "The block number where reorg was detected the last time. This doesn't mean that the block was reorged, this is simply where we found block hash to be different.", chainIdLabelsSchema);
510
-
511
- function set$11(blockNumber, chain) {
512
- handleInt$1(gauge$11, chain, blockNumber);
513
- }
514
-
515
- let ReorgDetectionBlockNumber = {
516
- gauge: gauge$11,
517
- set: set$11
518
- };
519
-
520
- let gauge$12 = PromClient.Gauge.makeGauge({
521
- name: "envio_reorg_threshold",
522
- help: "Whether indexing is currently within the reorg threshold"
523
- });
524
-
525
- function set$12(isInReorgThreshold) {
526
- gauge$12.set(isInReorgThreshold ? 1 : 0);
527
- }
528
-
529
- let ReorgThreshold = {
530
- gauge: gauge$12,
531
- set: set$12
532
- };
533
-
534
- let gauge$13 = PromClient.Gauge.makeGauge({
535
- name: "envio_rollback_enabled",
536
- help: "Whether rollback on reorg is enabled"
537
- });
538
-
539
- function set$13(enabled) {
540
- gauge$13.set(enabled ? 1 : 0);
541
- }
542
-
543
- let RollbackEnabled = {
544
- gauge: gauge$13,
545
- set: set$13
546
- };
547
-
548
- let timeCounter$3 = PromClient.Counter.makeCounter({
549
- name: "envio_rollback_seconds",
550
- help: "Rollback on reorg total time."
551
- });
552
-
553
- let counter$4 = PromClient.Counter.makeCounter({
554
- name: "envio_rollback_total",
555
- help: "Number of successful rollbacks on reorg"
556
- });
557
-
558
- let eventsCounter = PromClient.Counter.makeCounter({
559
- name: "envio_rollback_events",
560
- help: "Number of events rollbacked on reorg"
561
- });
562
-
563
- function increment$5(timeSeconds, rollbackedProcessedEvents) {
564
- timeCounter$3.inc(timeSeconds);
565
- counter$4.inc();
566
- eventsCounter.inc(Math.trunc(rollbackedProcessedEvents));
567
- }
568
-
569
- let RollbackSuccess = {
570
- timeCounter: timeCounter$3,
571
- counter: counter$4,
572
- eventsCounter: eventsCounter,
573
- increment: increment$5
574
- };
575
-
576
- let entityNameLabelsSchema = S$RescriptSchema.object(s => s.f("entity", S$RescriptSchema.string));
577
-
578
- let timeCounter$4 = makeOrThrow("envio_rollback_history_prune_seconds", "The total time spent pruning entity history which is not in the reorg threshold.", entityNameLabelsSchema);
579
-
580
- let counter$5 = makeOrThrow("envio_rollback_history_prune_total", "Number of successful entity history prunes", entityNameLabelsSchema);
581
-
582
- function increment$6(timeSeconds, entityName) {
583
- handleFloat(timeCounter$4, entityName, timeSeconds);
584
- increment(counter$5, entityName);
585
- }
586
-
587
- let RollbackHistoryPrune = {
588
- entityNameLabelsSchema: entityNameLabelsSchema,
589
- timeCounter: timeCounter$4,
590
- counter: counter$5,
591
- increment: increment$6
592
- };
593
-
594
- let gauge$14 = makeOrThrow$1("envio_rollback_target_block", "The block number reorg was rollbacked to the last time.", chainIdLabelsSchema);
595
-
596
- function set$14(blockNumber, chain) {
597
- handleInt$1(gauge$14, chain, blockNumber);
598
- }
599
-
600
- let RollbackTargetBlockNumber = {
601
- gauge: gauge$14,
602
- set: set$14
603
- };
604
-
605
- let gauge$15 = PromClient.Gauge.makeGauge({
606
- name: "envio_processing_max_batch_size",
607
- help: "The maximum number of items to process in a single batch."
608
- });
609
-
610
- function set$15(maxBatchSize) {
611
- gauge$15.set(maxBatchSize);
612
- }
613
-
614
- let ProcessingMaxBatchSize = {
615
- gauge: gauge$15,
616
- set: set$15
617
- };
618
-
619
- let gauge$16 = makeOrThrow$1("envio_progress_block", "The block number of the latest block processed and stored in the database.", chainIdLabelsSchema);
620
-
621
- function set$16(blockNumber, chainId) {
622
- handleInt$1(gauge$16, chainId, blockNumber);
623
- }
624
-
625
- let ProgressBlockNumber = {
626
- gauge: gauge$16,
627
- set: set$16
628
- };
629
-
630
- let gauge$17 = makeOrThrow$1("envio_progress_events", "The number of events processed and reflected in the database.", chainIdLabelsSchema);
631
-
632
- function set$17(processedCount, chainId) {
633
- handleFloat$1(gauge$17, chainId, processedCount);
634
- }
635
-
636
- let ProgressEventsCount = {
637
- gauge: gauge$17,
638
- set: set$17
639
- };
640
-
641
- let gauge$18 = makeOrThrow$1("envio_progress_latency", "The latency in milliseconds between the latest processed event creation and the time it was written to storage.", chainIdLabelsSchema);
642
-
643
- function set$18(latencyMs, chainId) {
644
- handleInt$1(gauge$18, chainId, latencyMs);
645
- }
646
-
647
- let ProgressLatency = {
648
- gauge: gauge$18,
649
- set: set$18
650
- };
651
-
652
- let effectLabelsSchema = S$RescriptSchema.object(s => s.f("effect", S$RescriptSchema.string));
653
-
654
- let effectScopeLabelsSchema = S$RescriptSchema.schema(s => ({
655
- effect: s.m(S$RescriptSchema.string),
656
- scope: s.m(S$RescriptSchema.string)
657
- }));
658
-
659
- let timeCounter$5 = makeOrThrow("envio_effect_call_seconds", "Processing time taken to call the Effect function.", effectScopeLabelsSchema);
660
-
661
- let sumTimeCounter$1 = makeOrThrow("envio_effect_call_seconds_total", "Cumulative time spent calling the Effect function during the indexing process.", effectScopeLabelsSchema);
662
-
663
- let totalCallsCount = makeOrThrow("envio_effect_call_total", "Cumulative number of resolved Effect function calls during the indexing process.", effectScopeLabelsSchema);
664
-
665
- let activeCallsCount = makeOrThrow$1("envio_effect_active_calls", "The number of Effect function calls that are currently running.", effectScopeLabelsSchema);
666
-
667
- let EffectCalls = {
668
- timeCounter: timeCounter$5,
669
- sumTimeCounter: sumTimeCounter$1,
670
- totalCallsCount: totalCallsCount,
671
- activeCallsCount: activeCallsCount
672
- };
673
-
674
- let gauge$19 = makeOrThrow$1("envio_effect_cache", "The number of items in the effect cache.", effectScopeLabelsSchema);
675
-
676
- function set$19(count, effectName, scope) {
677
- handleInt$1(gauge$19, {
678
- effect: effectName,
679
- scope: scope
680
- }, count);
681
- }
682
-
683
- let EffectCacheCount = {
684
- gauge: gauge$19,
685
- set: set$19
686
- };
687
-
688
- let counter$6 = makeOrThrow("envio_effect_cache_invalidations", "The number of effect cache invalidations.", effectLabelsSchema);
689
-
690
- function increment$7(effectName) {
691
- increment(counter$6, effectName);
692
- }
693
-
694
- let EffectCacheInvalidationsCount = {
695
- counter: counter$6,
696
- increment: increment$7
697
- };
698
-
699
- let gauge$20 = makeOrThrow$1("envio_effect_queue", "The number of effect calls waiting in the rate limit queue.", effectScopeLabelsSchema);
700
-
701
- let timeCounter$6 = makeOrThrow("envio_effect_queue_wait_seconds", "The time spent waiting in the rate limit queue.", effectLabelsSchema);
702
-
703
- function set$20(count, effectName, scope) {
704
- handleInt$1(gauge$20, {
705
- effect: effectName,
706
- scope: scope
707
- }, count);
708
- }
709
-
710
- let EffectQueueCount = {
711
- gauge: gauge$20,
712
- timeCounter: timeCounter$6,
713
- set: set$20
714
- };
715
-
716
- let loadLabelsSchema = S$RescriptSchema.schema(s => ({
717
- operation: s.m(S$RescriptSchema.string),
718
- storage: s.m(S$RescriptSchema.string)
719
- }));
720
-
721
- let timeCounter$7 = makeOrThrow("envio_storage_load_seconds", "Processing time taken to load data from storage.", loadLabelsSchema);
722
-
723
- let sumTimeCounter$2 = makeOrThrow("envio_storage_load_seconds_total", "Cumulative time spent loading data from storage during the indexing process.", loadLabelsSchema);
724
-
725
- let counter$7 = makeOrThrow("envio_storage_load_total", "Cumulative number of successful storage load operations during the indexing process.", loadLabelsSchema);
726
-
727
- let whereSizeCounter = makeOrThrow("envio_storage_load_where_size", "Cumulative number of filter conditions ('where' items) used in storage load operations during the indexing process.", loadLabelsSchema);
728
-
729
- let sizeCounter$1 = makeOrThrow("envio_storage_load_size", "Cumulative number of records loaded from storage during the indexing process.", loadLabelsSchema);
730
-
731
- let operations$1 = {};
732
-
733
- function makeKey$1(storage, operation) {
734
- return storage + ":" + operation;
735
- }
736
-
737
- function startOperation$1(storage, operation) {
738
- let key = makeKey$1(storage, operation);
739
- let operationRef = operations$1[key];
740
- if (operationRef !== undefined) {
741
- operationRef.pendingCount = operationRef.pendingCount + 1 | 0;
742
- } else {
743
- operations$1[key] = {
744
- pendingCount: 1,
745
- timerRef: Performance.now()
746
- };
747
- }
748
- return Performance.now();
749
- }
750
-
751
- function endOperation$1(timerRef, storage, operation, whereSize, size) {
752
- let key = makeKey$1(storage, operation);
753
- let labels = {
754
- operation: operation,
755
- storage: storage
756
- };
757
- let operationRef = operations$1[key];
758
- operationRef.pendingCount = operationRef.pendingCount - 1 | 0;
759
- if (operationRef.pendingCount === 0) {
760
- handleFloat(timeCounter$7, labels, Performance.secondsSince(operationRef.timerRef));
761
- Utils.Dict.deleteInPlace(operations$1, key);
762
- }
763
- handleFloat(sumTimeCounter$2, labels, Performance.secondsSince(timerRef));
764
- increment(counter$7, labels);
765
- handleInt(whereSizeCounter, labels, whereSize);
766
- handleInt(sizeCounter$1, labels, size);
767
- }
768
-
769
- let StorageLoad = {
770
- loadLabelsSchema: loadLabelsSchema,
771
- timeCounter: timeCounter$7,
772
- sumTimeCounter: sumTimeCounter$2,
773
- counter: counter$7,
774
- whereSizeCounter: whereSizeCounter,
775
- sizeCounter: sizeCounter$1,
776
- operations: operations$1,
777
- makeKey: makeKey$1,
778
- startOperation: startOperation$1,
779
- endOperation: endOperation$1
780
- };
781
-
782
- let storageLabelsSchema = S$RescriptSchema.object(s => s.f("storage", S$RescriptSchema.string));
783
-
784
- let timeCounter$8 = makeOrThrow("envio_storage_write_seconds", "Cumulative time spent writing batch data to storage.", storageLabelsSchema);
785
-
786
- let counter$8 = makeOrThrow("envio_storage_write_total", "Cumulative number of successful storage write operations during the indexing process.", storageLabelsSchema);
787
-
788
- function increment$8(storage, timeSeconds) {
789
- handleFloat(timeCounter$8, storage, timeSeconds);
790
- increment(counter$8, storage);
791
- }
792
-
793
- let StorageWrite = {
794
- storageLabelsSchema: storageLabelsSchema,
795
- timeCounter: timeCounter$8,
796
- counter: counter$8,
797
- increment: increment$8
798
- };
799
-
800
- export {
801
- Labels,
802
- metricNames,
803
- MakeSafePromMetric,
804
- SafeCounter,
805
- SafeGauge,
806
- ProcessingBatch,
807
- chainIdLabelsSchema,
808
- ProgressReady,
809
- handlerLabelsSchema,
810
- ProcessingHandler,
811
- PreloadHandler,
812
- FetchingBlockRange,
813
- IndexingKnownHeight,
814
- Info,
815
- ProcessStartTimeSeconds,
816
- IndexingConcurrency,
817
- IndexingPartitions,
818
- IndexingIdleTime,
819
- IndexingSourceWaitingTime,
820
- IndexingQueryTime,
821
- IndexingBufferSize,
822
- IndexingTargetBufferSize,
823
- IndexingBufferBlockNumber,
824
- IndexingEndBlock,
825
- sourceLabelsSchema,
826
- SourceHeight,
827
- ReorgCount,
828
- ReorgDetectionBlockNumber,
829
- ReorgThreshold,
830
- RollbackEnabled,
831
- RollbackSuccess,
832
- RollbackHistoryPrune,
833
- RollbackTargetBlockNumber,
834
- ProcessingMaxBatchSize,
835
- ProgressBlockNumber,
836
- ProgressEventsCount,
837
- ProgressLatency,
838
- effectLabelsSchema,
839
- effectScopeLabelsSchema,
840
- EffectCalls,
841
- EffectCacheCount,
842
- EffectCacheInvalidationsCount,
843
- EffectQueueCount,
844
- StorageLoad,
845
- StorageWrite,
846
- }
847
- /* metricNames Not a pure module */