envio
Version:
A latency and sync speed optimized, developer friendly blockchain data indexer.
895 lines (724 loc) • 27.1 kB
JavaScript
// Generated by ReScript, PLEASE EDIT WITH CARE
import * as Utils from "./Utils.res.mjs";
import * as Hrtime from "./bindings/Hrtime.res.mjs";
import * as PromClient from "./bindings/PromClient.res.mjs";
import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
import * as Stdlib_JsError from "@rescript/runtime/lib/es6/Stdlib_JsError.js";
import * as S$RescriptSchema from "rescript-schema/src/S.res.mjs";
function schemaIsString(_schema) {
while (true) {
let schema = _schema;
let match = schema.t;
if (typeof match !== "object") {
return match === "string";
}
switch (match.TAG) {
case "option" :
case "null" :
_schema = match._0;
continue;
default:
return false;
}
};
}
function getLabelNames(schema) {
let match = schema.t;
if (typeof match !== "object") {
return {
TAG: "Error",
_0: "Label schema must be an object"
};
}
if (match.TAG !== "object") {
return {
TAG: "Error",
_0: "Label schema must be an object"
};
}
let items = match.items;
let nonStringFields = Stdlib_Array.reduce(items, [], (nonStringFields, item) => {
if (schemaIsString(item.schema)) {
return nonStringFields;
} else {
return nonStringFields.concat([item.location]);
}
});
if (nonStringFields.length === 0) {
return {
TAG: "Ok",
_0: items.map(item => item.location)
};
}
let nonStringItems = nonStringFields.join(", ");
return {
TAG: "Error",
_0: `Label schema must be an object with string (or optional string) values. Non string values: ` + nonStringItems
};
}
let Labels = {
schemaIsString: schemaIsString,
getLabelNames: getLabelNames
};
let metricNames = new Set();
function MakeSafePromMetric(M) {
let makeOrThrow = (name, help, labelSchema) => {
let labelNames = getLabelNames(labelSchema);
if (labelNames.TAG !== "Ok") {
return Stdlib_JsError.throwWithMessage(labelNames._0);
}
if (metricNames.has(name)) {
return Stdlib_JsError.throwWithMessage("Duplicate prometheus metric name: " + name);
}
metricNames.add(name);
let metric = M.make({
name: name,
help: help,
labelNames: labelNames._0
});
return {
metric: metric,
labelSchema: labelSchema
};
};
let handleFloat = (param, labels, value) => M.handleFloat(M.labels(param.metric, S$RescriptSchema.reverseConvertToJsonOrThrow(labels, param.labelSchema)), value);
let handleInt = (param, labels, value) => M.handleInt(M.labels(param.metric, S$RescriptSchema.reverseConvertToJsonOrThrow(labels, param.labelSchema)), value);
let increment = (param, labels) => M.labels(param.metric, S$RescriptSchema.reverseConvertToJsonOrThrow(labels, param.labelSchema)).inc();
let incrementMany = (param, labels, value) => M.labels(param.metric, S$RescriptSchema.reverseConvertToJsonOrThrow(labels, param.labelSchema)).inc(value);
return {
makeOrThrow: makeOrThrow,
handleInt: handleInt,
handleFloat: handleFloat,
increment: increment,
incrementMany: incrementMany
};
}
let make = PromClient.Counter.makeCounter;
function makeOrThrow(name, help, labelSchema) {
let labelNames = getLabelNames(labelSchema);
if (labelNames.TAG !== "Ok") {
return Stdlib_JsError.throwWithMessage(labelNames._0);
}
if (metricNames.has(name)) {
return Stdlib_JsError.throwWithMessage("Duplicate prometheus metric name: " + name);
}
metricNames.add(name);
let metric = make({
name: name,
help: help,
labelNames: labelNames._0
});
return {
metric: metric,
labelSchema: labelSchema
};
}
function handleFloat(param, labels, value) {
let prim0 = param.metric.labels(S$RescriptSchema.reverseConvertToJsonOrThrow(labels, param.labelSchema));
prim0.inc(value);
}
function handleInt(param, labels, value) {
let prim0 = param.metric.labels(S$RescriptSchema.reverseConvertToJsonOrThrow(labels, param.labelSchema));
prim0.inc(value);
}
function increment(param, labels) {
return param.metric.labels(S$RescriptSchema.reverseConvertToJsonOrThrow(labels, param.labelSchema)).inc();
}
function incrementMany(param, labels, value) {
return param.metric.labels(S$RescriptSchema.reverseConvertToJsonOrThrow(labels, param.labelSchema)).inc(value);
}
let SafeCounter = {
makeOrThrow: makeOrThrow,
handleInt: handleInt,
handleFloat: handleFloat,
increment: increment,
incrementMany: incrementMany
};
let make$1 = PromClient.Gauge.makeGauge;
function makeOrThrow$1(name, help, labelSchema) {
let labelNames = getLabelNames(labelSchema);
if (labelNames.TAG !== "Ok") {
return Stdlib_JsError.throwWithMessage(labelNames._0);
}
if (metricNames.has(name)) {
return Stdlib_JsError.throwWithMessage("Duplicate prometheus metric name: " + name);
}
metricNames.add(name);
let metric = make$1({
name: name,
help: help,
labelNames: labelNames._0
});
return {
metric: metric,
labelSchema: labelSchema
};
}
function handleFloat$1(param, labels, value) {
let prim0 = param.metric.labels(S$RescriptSchema.reverseConvertToJsonOrThrow(labels, param.labelSchema));
prim0.set(value);
}
function handleInt$1(param, labels, value) {
let prim0 = param.metric.labels(S$RescriptSchema.reverseConvertToJsonOrThrow(labels, param.labelSchema));
prim0.set(value);
}
function increment$1(param, labels) {
return param.metric.labels(S$RescriptSchema.reverseConvertToJsonOrThrow(labels, param.labelSchema)).inc();
}
function incrementMany$1(param, labels, value) {
return param.metric.labels(S$RescriptSchema.reverseConvertToJsonOrThrow(labels, param.labelSchema)).inc(value);
}
let SafeGauge = {
makeOrThrow: makeOrThrow$1,
handleInt: handleInt$1,
handleFloat: handleFloat$1,
increment: increment$1,
incrementMany: incrementMany$1
};
let loadTimeCounter = PromClient.Counter.makeCounter({
name: "envio_preload_seconds",
help: "Cumulative time spent on preloading entities during batch processing."
});
let handlerTimeCounter = PromClient.Counter.makeCounter({
name: "envio_processing_seconds",
help: "Cumulative time spent executing event handlers during batch processing."
});
function registerMetrics(loadDuration, handlerDuration) {
loadTimeCounter.inc(loadDuration);
handlerTimeCounter.inc(handlerDuration);
}
let ProcessingBatch = {
loadTimeCounter: loadTimeCounter,
handlerTimeCounter: handlerTimeCounter,
registerMetrics: registerMetrics
};
let chainIdLabelsSchema = S$RescriptSchema.object(s => s.f("chainId", S$RescriptSchema.coerce(S$RescriptSchema.string, S$RescriptSchema.int)));
let gauge = makeOrThrow$1("envio_progress_ready", "Whether the chain is fully synced to the head.", chainIdLabelsSchema);
let legacyGauge = PromClient.Gauge.makeGauge({
name: "hyperindex_synced_to_head",
help: "All chains fully synced"
});
function init(chainId) {
handleInt$1(gauge, chainId, 0);
}
function set(chainId) {
handleInt$1(gauge, chainId, 1);
}
function setAllReady() {
legacyGauge.set(1);
}
let ProgressReady = {
gauge: gauge,
legacyGauge: legacyGauge,
init: init,
set: set,
setAllReady: setAllReady
};
let handlerLabelsSchema = S$RescriptSchema.schema(s => ({
contract: s.m(S$RescriptSchema.string),
event: s.m(S$RescriptSchema.string)
}));
let timeCounter = makeOrThrow("envio_processing_handler_seconds", "Cumulative time spent inside individual event handler executions.", handlerLabelsSchema);
let count = makeOrThrow("envio_processing_handler_total", "Total number of individual event handler executions.", handlerLabelsSchema);
function increment$2(contract, event, duration) {
let labels = {
contract: contract,
event: event
};
handleFloat(timeCounter, labels, duration);
increment(count, labels);
}
let ProcessingHandler = {
timeCounter: timeCounter,
count: count,
increment: increment$2
};
let timeCounter$1 = makeOrThrow("envio_preload_handler_seconds", "Wall-clock time spent inside individual preload handler executions.", handlerLabelsSchema);
let count$1 = makeOrThrow("envio_preload_handler_total", "Total number of individual preload handler executions.", handlerLabelsSchema);
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);
let operations = {};
function makeKey(contract, event) {
return contract + ":" + event;
}
function startOperation(contract, event) {
let key = makeKey(contract, event);
let operationRef = operations[key];
if (operationRef !== undefined) {
operationRef.pendingCount = operationRef.pendingCount + 1 | 0;
} else {
operations[key] = {
pendingCount: 1,
timerRef: Hrtime.makeTimer()
};
}
return Hrtime.makeTimer();
}
function endOperation(timerRef, contract, event) {
let key = makeKey(contract, event);
let labels = {
contract: contract,
event: event
};
let operationRef = operations[key];
operationRef.pendingCount = operationRef.pendingCount - 1 | 0;
if (operationRef.pendingCount === 0) {
handleFloat(timeCounter$1, labels, Hrtime.toSecondsFloat(Hrtime.timeSince(operationRef.timerRef)));
Utils.Dict.deleteInPlace(operations, key);
}
handleFloat(sumTimeCounter, labels, Hrtime.toSecondsFloat(Hrtime.timeSince(timerRef)));
increment(count$1, labels);
}
let PreloadHandler = {
timeCounter: timeCounter$1,
count: count$1,
sumTimeCounter: sumTimeCounter,
operations: operations,
makeKey: makeKey,
startOperation: startOperation,
endOperation: endOperation
};
let timeCounter$2 = makeOrThrow("envio_fetching_block_range_seconds", "Cumulative time spent fetching block ranges.", chainIdLabelsSchema);
let parseTimeCounter = makeOrThrow("envio_fetching_block_range_parse_seconds", "Cumulative time spent parsing block range fetch responses.", chainIdLabelsSchema);
let count$2 = makeOrThrow("envio_fetching_block_range_total", "Total number of block range fetch operations.", chainIdLabelsSchema);
let eventsCount = makeOrThrow("envio_fetching_block_range_events_total", "Cumulative number of events fetched across all block range operations.", chainIdLabelsSchema);
let sizeCounter = makeOrThrow("envio_fetching_block_range_size", "Cumulative number of blocks covered across all block range fetch operations.", chainIdLabelsSchema);
function increment$3(chainId, totalTimeElapsed, parsingTimeElapsed, numEvents, blockRangeSize) {
handleFloat(timeCounter$2, chainId, totalTimeElapsed);
handleFloat(parseTimeCounter, chainId, parsingTimeElapsed);
increment(count$2, chainId);
handleInt(eventsCount, chainId, numEvents);
handleInt(sizeCounter, chainId, blockRangeSize);
}
let FetchingBlockRange = {
timeCounter: timeCounter$2,
parseTimeCounter: parseTimeCounter,
count: count$2,
eventsCount: eventsCount,
sizeCounter: sizeCounter,
increment: increment$3
};
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);
function set$1(blockNumber, chainId) {
handleInt$1(gauge$1, chainId, blockNumber);
}
let IndexingKnownHeight = {
gauge: gauge$1,
set: set$1
};
let gauge$2 = makeOrThrow$1("envio_info", "Information about the indexer", S$RescriptSchema.schema(s => ({
version: s.m(S$RescriptSchema.string)
})));
function set$2(version) {
handleInt$1(gauge$2, {
version: version
}, 1);
}
let Info = {
gauge: gauge$2,
set: set$2
};
let gauge$3 = PromClient.Gauge.makeGauge({
name: "envio_process_start_time_seconds",
help: "Start time of the process since unix epoch in seconds."
});
function set$3() {
gauge$3.set(Date.now() / 1000.0);
}
let ProcessStartTimeSeconds = {
gauge: gauge$3,
set: set$3
};
let gauge$4 = makeOrThrow$1("envio_indexing_addresses", "The number of addresses indexed on chain. Includes both static and dynamic addresses.", chainIdLabelsSchema);
function set$4(addressesCount, chainId) {
handleInt$1(gauge$4, chainId, addressesCount);
}
let IndexingAddresses = {
gauge: gauge$4,
set: set$4
};
let gauge$5 = makeOrThrow$1("envio_indexing_max_concurrency", "The maximum number of concurrent queries to the chain data-source.", chainIdLabelsSchema);
function set$5(maxConcurrency, chainId) {
handleInt$1(gauge$5, chainId, maxConcurrency);
}
let IndexingMaxConcurrency = {
gauge: gauge$5,
set: set$5
};
let gauge$6 = makeOrThrow$1("envio_indexing_concurrency", "The number of executing concurrent queries to the chain data-source.", chainIdLabelsSchema);
function set$6(concurrency, chainId) {
handleInt$1(gauge$6, chainId, concurrency);
}
let IndexingConcurrency = {
gauge: gauge$6,
set: set$6
};
let gauge$7 = makeOrThrow$1("envio_indexing_partitions", "The number of partitions used to split fetching logic by addresses and block ranges.", chainIdLabelsSchema);
function set$7(partitionsCount, chainId) {
handleInt$1(gauge$7, chainId, partitionsCount);
}
let IndexingPartitions = {
gauge: gauge$7,
set: set$7
};
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);
let IndexingIdleTime = {
counter: counter
};
let counter$1 = makeOrThrow("envio_indexing_source_waiting_seconds", "The time the indexer has been waiting for new blocks.", chainIdLabelsSchema);
let IndexingSourceWaitingTime = {
counter: counter$1
};
let counter$2 = makeOrThrow("envio_indexing_source_querying_seconds", "The time spent performing queries to the chain data-source.", chainIdLabelsSchema);
let IndexingQueryTime = {
counter: counter$2
};
let gauge$8 = makeOrThrow$1("envio_indexing_buffer_size", "The current number of items in the indexing buffer.", chainIdLabelsSchema);
function set$8(bufferSize, chainId) {
handleInt$1(gauge$8, chainId, bufferSize);
}
let IndexingBufferSize = {
gauge: gauge$8,
set: set$8
};
let gauge$9 = PromClient.Gauge.makeGauge({
name: "envio_indexing_target_buffer_size",
help: "The target buffer size per chain for indexing. 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."
});
function set$9(targetBufferSize) {
gauge$9.set(targetBufferSize);
}
let IndexingTargetBufferSize = {
gauge: gauge$9,
set: set$9
};
let gauge$10 = makeOrThrow$1("envio_indexing_buffer_block", "The highest block number that has been fully fetched by the indexer.", chainIdLabelsSchema);
function set$10(blockNumber, chainId) {
handleInt$1(gauge$10, chainId, blockNumber);
}
let IndexingBufferBlockNumber = {
gauge: gauge$10,
set: set$10
};
let gauge$11 = makeOrThrow$1("envio_indexing_end_block", "The block number to stop indexing at. (inclusive)", chainIdLabelsSchema);
function set$11(endBlock, chainId) {
handleInt$1(gauge$11, chainId, endBlock);
}
let IndexingEndBlock = {
gauge: gauge$11,
set: set$11
};
let sourceLabelsSchema = S$RescriptSchema.schema(s => ({
source: s.m(S$RescriptSchema.string),
chainId: s.m(S$RescriptSchema.coerce(S$RescriptSchema.string, S$RescriptSchema.int))
}));
let sourceRequestLabelsSchema = S$RescriptSchema.schema(s => ({
source: s.m(S$RescriptSchema.string),
chainId: s.m(S$RescriptSchema.coerce(S$RescriptSchema.string, S$RescriptSchema.int)),
method: s.m(S$RescriptSchema.string)
}));
let counter$3 = makeOrThrow("envio_source_request_total", "The number of requests made to data sources.", sourceRequestLabelsSchema);
let sumTimeCounter$1 = makeOrThrow("envio_source_request_seconds_total", "Cumulative time spent on data source requests.", sourceRequestLabelsSchema);
function increment$4(sourceName, chainId, method) {
increment(counter$3, {
source: sourceName,
chainId: chainId,
method: method
});
}
function addSeconds(sourceName, chainId, method, seconds) {
handleFloat(sumTimeCounter$1, {
source: sourceName,
chainId: chainId,
method: method
}, seconds);
}
let SourceRequestCount = {
counter: counter$3,
sumTimeCounter: sumTimeCounter$1,
increment: increment$4,
addSeconds: addSeconds
};
let gauge$12 = 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);
function set$12(sourceName, chainId, blockNumber) {
handleInt$1(gauge$12, {
source: sourceName,
chainId: chainId
}, blockNumber);
}
let SourceHeight = {
gauge: gauge$12,
set: set$12
};
let counter$4 = makeOrThrow("envio_reorg_detected_total", "Total number of reorgs detected", chainIdLabelsSchema);
function increment$5(chain) {
increment(counter$4, chain);
}
let ReorgCount = {
counter: counter$4,
increment: increment$5
};
let gauge$13 = 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);
function set$13(blockNumber, chain) {
handleInt$1(gauge$13, chain, blockNumber);
}
let ReorgDetectionBlockNumber = {
gauge: gauge$13,
set: set$13
};
let gauge$14 = PromClient.Gauge.makeGauge({
name: "envio_reorg_threshold",
help: "Whether indexing is currently within the reorg threshold"
});
function set$14(isInReorgThreshold) {
gauge$14.set(isInReorgThreshold ? 1 : 0);
}
let ReorgThreshold = {
gauge: gauge$14,
set: set$14
};
let gauge$15 = PromClient.Gauge.makeGauge({
name: "envio_rollback_enabled",
help: "Whether rollback on reorg is enabled"
});
function set$15(enabled) {
gauge$15.set(enabled ? 1 : 0);
}
let RollbackEnabled = {
gauge: gauge$15,
set: set$15
};
let timeCounter$3 = PromClient.Counter.makeCounter({
name: "envio_rollback_seconds",
help: "Rollback on reorg total time."
});
let counter$5 = PromClient.Counter.makeCounter({
name: "envio_rollback_total",
help: "Number of successful rollbacks on reorg"
});
let eventsCounter = PromClient.Counter.makeCounter({
name: "envio_rollback_events",
help: "Number of events rollbacked on reorg"
});
function increment$6(timeSeconds, rollbackedProcessedEvents) {
timeCounter$3.inc(timeSeconds);
counter$5.inc();
eventsCounter.inc(Math.trunc(rollbackedProcessedEvents));
}
let RollbackSuccess = {
timeCounter: timeCounter$3,
counter: counter$5,
eventsCounter: eventsCounter,
increment: increment$6
};
let entityNameLabelsSchema = S$RescriptSchema.object(s => s.f("entity", S$RescriptSchema.string));
let timeCounter$4 = makeOrThrow("envio_rollback_history_prune_seconds", "The total time spent pruning entity history which is not in the reorg threshold.", entityNameLabelsSchema);
let counter$6 = makeOrThrow("envio_rollback_history_prune_total", "Number of successful entity history prunes", entityNameLabelsSchema);
function increment$7(timeSeconds, entityName) {
handleFloat(timeCounter$4, entityName, timeSeconds);
increment(counter$6, entityName);
}
let RollbackHistoryPrune = {
entityNameLabelsSchema: entityNameLabelsSchema,
timeCounter: timeCounter$4,
counter: counter$6,
increment: increment$7
};
let gauge$16 = makeOrThrow$1("envio_rollback_target_block", "The block number reorg was rollbacked to the last time.", chainIdLabelsSchema);
function set$16(blockNumber, chain) {
handleInt$1(gauge$16, chain, blockNumber);
}
let RollbackTargetBlockNumber = {
gauge: gauge$16,
set: set$16
};
let gauge$17 = PromClient.Gauge.makeGauge({
name: "envio_processing_max_batch_size",
help: "The maximum number of items to process in a single batch."
});
function set$17(maxBatchSize) {
gauge$17.set(maxBatchSize);
}
let ProcessingMaxBatchSize = {
gauge: gauge$17,
set: set$17
};
let gauge$18 = makeOrThrow$1("envio_progress_block", "The block number of the latest block processed and stored in the database.", chainIdLabelsSchema);
function set$18(blockNumber, chainId) {
handleInt$1(gauge$18, chainId, blockNumber);
}
let ProgressBlockNumber = {
gauge: gauge$18,
set: set$18
};
let gauge$19 = makeOrThrow$1("envio_progress_events", "The number of events processed and reflected in the database.", chainIdLabelsSchema);
function set$19(processedCount, chainId) {
handleFloat$1(gauge$19, chainId, processedCount);
}
let ProgressEventsCount = {
gauge: gauge$19,
set: set$19
};
let gauge$20 = makeOrThrow$1("envio_progress_latency", "The latency in milliseconds between the latest processed event creation and the time it was written to storage.", chainIdLabelsSchema);
function set$20(latencyMs, chainId) {
handleInt$1(gauge$20, chainId, latencyMs);
}
let ProgressLatency = {
gauge: gauge$20,
set: set$20
};
let effectLabelsSchema = S$RescriptSchema.object(s => s.f("effect", S$RescriptSchema.string));
let timeCounter$5 = makeOrThrow("envio_effect_call_seconds", "Processing time taken to call the Effect function.", effectLabelsSchema);
let sumTimeCounter$2 = makeOrThrow("envio_effect_call_seconds_total", "Cumulative time spent calling the Effect function during the indexing process.", effectLabelsSchema);
let totalCallsCount = makeOrThrow("envio_effect_call_total", "Cumulative number of resolved Effect function calls during the indexing process.", effectLabelsSchema);
let activeCallsCount = makeOrThrow$1("envio_effect_active_calls", "The number of Effect function calls that are currently running.", effectLabelsSchema);
let EffectCalls = {
timeCounter: timeCounter$5,
sumTimeCounter: sumTimeCounter$2,
totalCallsCount: totalCallsCount,
activeCallsCount: activeCallsCount
};
let gauge$21 = makeOrThrow$1("envio_effect_cache", "The number of items in the effect cache.", effectLabelsSchema);
function set$21(count, effectName) {
handleInt$1(gauge$21, effectName, count);
}
let EffectCacheCount = {
gauge: gauge$21,
set: set$21
};
let counter$7 = makeOrThrow("envio_effect_cache_invalidations", "The number of effect cache invalidations.", effectLabelsSchema);
function increment$8(effectName) {
increment(counter$7, effectName);
}
let EffectCacheInvalidationsCount = {
counter: counter$7,
increment: increment$8
};
let gauge$22 = makeOrThrow$1("envio_effect_queue", "The number of effect calls waiting in the rate limit queue.", effectLabelsSchema);
let timeCounter$6 = makeOrThrow("envio_effect_queue_wait_seconds", "The time spent waiting in the rate limit queue.", effectLabelsSchema);
function set$22(count, effectName) {
handleInt$1(gauge$22, effectName, count);
}
let EffectQueueCount = {
gauge: gauge$22,
timeCounter: timeCounter$6,
set: set$22
};
let loadLabelsSchema = S$RescriptSchema.schema(s => ({
operation: s.m(S$RescriptSchema.string),
storage: s.m(S$RescriptSchema.string)
}));
let timeCounter$7 = makeOrThrow("envio_storage_load_seconds", "Processing time taken to load data from storage.", loadLabelsSchema);
let sumTimeCounter$3 = makeOrThrow("envio_storage_load_seconds_total", "Cumulative time spent loading data from storage during the indexing process.", loadLabelsSchema);
let counter$8 = makeOrThrow("envio_storage_load_total", "Cumulative number of successful storage load operations during the indexing process.", loadLabelsSchema);
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);
let sizeCounter$1 = makeOrThrow("envio_storage_load_size", "Cumulative number of records loaded from storage during the indexing process.", loadLabelsSchema);
let operations$1 = {};
function makeKey$1(storage, operation) {
return storage + ":" + operation;
}
function startOperation$1(storage, operation) {
let key = makeKey$1(storage, operation);
let operationRef = operations$1[key];
if (operationRef !== undefined) {
operationRef.pendingCount = operationRef.pendingCount + 1 | 0;
} else {
operations$1[key] = {
pendingCount: 1,
timerRef: Hrtime.makeTimer()
};
}
return Hrtime.makeTimer();
}
function endOperation$1(timerRef, storage, operation, whereSize, size) {
let key = makeKey$1(storage, operation);
let labels = {
operation: operation,
storage: storage
};
let operationRef = operations$1[key];
operationRef.pendingCount = operationRef.pendingCount - 1 | 0;
if (operationRef.pendingCount === 0) {
handleFloat(timeCounter$7, labels, Hrtime.toSecondsFloat(Hrtime.timeSince(operationRef.timerRef)));
Utils.Dict.deleteInPlace(operations$1, key);
}
handleFloat(sumTimeCounter$3, labels, Hrtime.toSecondsFloat(Hrtime.timeSince(timerRef)));
increment(counter$8, labels);
handleInt(whereSizeCounter, labels, whereSize);
handleInt(sizeCounter$1, labels, size);
}
let StorageLoad = {
loadLabelsSchema: loadLabelsSchema,
timeCounter: timeCounter$7,
sumTimeCounter: sumTimeCounter$3,
counter: counter$8,
whereSizeCounter: whereSizeCounter,
sizeCounter: sizeCounter$1,
operations: operations$1,
makeKey: makeKey$1,
startOperation: startOperation$1,
endOperation: endOperation$1
};
let storageLabelsSchema = S$RescriptSchema.object(s => s.f("storage", S$RescriptSchema.string));
let timeCounter$8 = makeOrThrow("envio_storage_write_seconds", "Cumulative time spent writing batch data to storage.", storageLabelsSchema);
let counter$9 = makeOrThrow("envio_storage_write_total", "Cumulative number of successful storage write operations during the indexing process.", storageLabelsSchema);
function increment$9(storage, timeSeconds) {
handleFloat(timeCounter$8, storage, timeSeconds);
increment(counter$9, storage);
}
let StorageWrite = {
storageLabelsSchema: storageLabelsSchema,
timeCounter: timeCounter$8,
counter: counter$9,
increment: increment$9
};
export {
Labels,
metricNames,
MakeSafePromMetric,
SafeCounter,
SafeGauge,
ProcessingBatch,
chainIdLabelsSchema,
ProgressReady,
handlerLabelsSchema,
ProcessingHandler,
PreloadHandler,
FetchingBlockRange,
IndexingKnownHeight,
Info,
ProcessStartTimeSeconds,
IndexingAddresses,
IndexingMaxConcurrency,
IndexingConcurrency,
IndexingPartitions,
IndexingIdleTime,
IndexingSourceWaitingTime,
IndexingQueryTime,
IndexingBufferSize,
IndexingTargetBufferSize,
IndexingBufferBlockNumber,
IndexingEndBlock,
sourceLabelsSchema,
sourceRequestLabelsSchema,
SourceRequestCount,
SourceHeight,
ReorgCount,
ReorgDetectionBlockNumber,
ReorgThreshold,
RollbackEnabled,
RollbackSuccess,
RollbackHistoryPrune,
RollbackTargetBlockNumber,
ProcessingMaxBatchSize,
ProgressBlockNumber,
ProgressEventsCount,
ProgressLatency,
effectLabelsSchema,
EffectCalls,
EffectCacheCount,
EffectCacheInvalidationsCount,
EffectQueueCount,
StorageLoad,
StorageWrite,
}
/* metricNames Not a pure module */