@eclesia/indexer-engine 2.10.0-next.1 → 2.10.0-next.3
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.
- package/dist/index.cjs +12 -12
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/indexer/index.cjs +68 -13
- package/dist/indexer/index.cjs.map +1 -1
- package/dist/indexer/index.d.cts +8 -1
- package/dist/indexer/index.d.cts.map +1 -1
- package/dist/indexer/index.d.ts +8 -1
- package/dist/indexer/index.d.ts.map +1 -1
- package/dist/indexer/index.js +58 -3
- package/dist/indexer/index.js.map +1 -1
- package/dist/metrics/index.cjs +72 -0
- package/dist/metrics/index.cjs.map +1 -1
- package/dist/metrics/index.d.cts +52 -0
- package/dist/metrics/index.d.cts.map +1 -1
- package/dist/metrics/index.d.ts +52 -0
- package/dist/metrics/index.d.ts.map +1 -1
- package/dist/metrics/index.js +72 -0
- package/dist/metrics/index.js.map +1 -1
- package/dist/types/index.cjs.map +1 -1
- package/dist/types/index.d.cts +2 -0
- package/dist/types/index.d.cts.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["Registry","Counter","Gauge","Histogram"],"sources":["../../src/metrics/index.ts"],"sourcesContent":["/**\n * Prometheus metrics for monitoring indexer performance and health\n * Exposes metrics for blocks indexed, queue depth, errors, and processing times\n */\n\nimport {\n collectDefaultMetrics, Counter, Gauge, Histogram, Registry,\n} from \"prom-client\";\n\n/** Prometheus metrics registry */\nexport class IndexerMetrics {\n /** Prometheus registry instance */\n public readonly registry: Registry;\n\n /** Counter for total blocks indexed */\n public readonly blocksIndexed: Counter;\n\n /** Gauge for current block height */\n public readonly currentHeight: Gauge;\n\n /** Gauge for latest chain block height */\n public readonly latestHeight: Gauge;\n\n /** Gauge for blocks behind chain tip */\n public readonly blocksBehind: Gauge;\n\n /** Gauge for block queue depth */\n public readonly queueDepth: Gauge;\n\n /** Counter for total errors */\n public readonly errors: Counter;\n\n /** Counter for RPC errors */\n public readonly rpcErrors: Counter;\n\n /** Counter for database errors */\n public readonly databaseErrors: Counter;\n\n /** Histogram for block processing duration */\n public readonly blockProcessingDuration: Histogram;\n\n /** Histogram for RPC call duration */\n public readonly rpcCallDuration: Histogram;\n\n /** Histogram for database query duration */\n public readonly databaseQueryDuration: Histogram;\n\n /** Gauge for retry count */\n public readonly retryCount: Gauge;\n\n /** Counter for total transactions processed */\n public readonly transactionsProcessed: Counter;\n\n constructor() {\n this.registry = new Registry();\n\n // Collect default Node.js metrics (memory, CPU, etc.)\n collectDefaultMetrics({\n register: this.registry,\n });\n\n // Block indexing metrics\n this.blocksIndexed = new Counter({\n name: \"indexer_blocks_indexed_total\",\n help: \"Total number of blocks indexed\",\n registers: [this.registry],\n });\n\n this.currentHeight = new Gauge({\n name: \"indexer_current_height\",\n help: \"Current block height being processed\",\n registers: [this.registry],\n });\n\n this.latestHeight = new Gauge({\n name: \"indexer_latest_chain_height\",\n help: \"Latest block height on the chain\",\n registers: [this.registry],\n });\n\n this.blocksBehind = new Gauge({\n name: \"indexer_blocks_behind\",\n help: \"Number of blocks behind chain tip\",\n registers: [this.registry],\n });\n\n this.queueDepth = new Gauge({\n name: \"indexer_queue_depth\",\n help: \"Current depth of block processing queue\",\n registers: [this.registry],\n });\n\n // Error metrics\n this.errors = new Counter({\n name: \"indexer_errors_total\",\n help: \"Total number of indexer errors\",\n labelNames: [\"type\"],\n registers: [this.registry],\n });\n\n this.rpcErrors = new Counter({\n name: \"indexer_rpc_errors_total\",\n help: \"Total number of RPC errors\",\n registers: [this.registry],\n });\n\n this.databaseErrors = new Counter({\n name: \"indexer_database_errors_total\",\n help: \"Total number of database errors\",\n registers: [this.registry],\n });\n\n // Performance metrics\n this.blockProcessingDuration = new Histogram({\n name: \"indexer_block_processing_duration_seconds\",\n help: \"Time spent processing a single block\",\n buckets: [0.001, 0.005, 0.01, 0.05, 0.1, 0.5, 1, 2, 5],\n registers: [this.registry],\n });\n\n this.rpcCallDuration = new Histogram({\n name: \"indexer_rpc_call_duration_seconds\",\n help: \"Duration of RPC calls\",\n buckets: [0.01, 0.05, 0.1, 0.5, 1, 2, 5, 10],\n labelNames: [\"method\"],\n registers: [this.registry],\n });\n\n this.databaseQueryDuration = new Histogram({\n name: \"indexer_database_query_duration_seconds\",\n help: \"Duration of database queries\",\n buckets: [0.001, 0.005, 0.01, 0.05, 0.1, 0.5, 1],\n labelNames: [\"query_type\"],\n registers: [this.registry],\n });\n\n // Operational metrics\n this.retryCount = new Gauge({\n name: \"indexer_retry_count\",\n help: \"Current number of retry attempts\",\n registers: [this.registry],\n });\n\n this.transactionsProcessed = new Counter({\n name: \"indexer_transactions_processed_total\",\n help: \"Total number of transactions processed\",\n registers: [this.registry],\n });\n }\n\n /**\n * Updates block indexing metrics\n * @param currentHeight - Current height being processed\n * @param latestHeight - Latest height on chain\n * @param queueSize - Current queue depth\n */\n updateBlockMetrics(currentHeight: number, latestHeight: number, queueSize: number) {\n this.blocksIndexed.inc();\n this.currentHeight.set(currentHeight);\n this.latestHeight.set(latestHeight);\n this.blocksBehind.set(latestHeight - currentHeight);\n this.queueDepth.set(queueSize);\n }\n\n /**\n * Records an error occurrence\n * @param type - Error type (rpc, database, processing, etc.)\n */\n recordError(type: string) {\n this.errors.inc({\n type,\n });\n\n if (type === \"rpc\") {\n this.rpcErrors.inc();\n }\n else if (type === \"database\") {\n this.databaseErrors.inc();\n }\n }\n\n /**\n * Gets metrics in Prometheus format\n * @returns Prometheus metrics string\n */\n async getMetrics(): Promise<string> {\n return this.registry.metrics();\n }\n}\n"],"mappings":";;;;;;;;;AAUA,IAAa,iBAAb,MAA4B;CA2C1B,cAAc;AACZ,OAAK,WAAW,IAAIA,sBAAU;AAG9B,yCAAsB,EACpB,UAAU,KAAK,UAChB,CA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AAM;GACN,MAAM;GACN,SAAS;IAAC;IAAO;IAAO;IAAM;IAAM;IAAK;IAAK;IAAE;GAChD,YAAY,CAAC,aAAa;GAC1B,WAAW,CAAC,KAAK,SAAS;GAC3B,CAAC;AAGF,OAAK,aAAa,IAAID,kBAAM;GAC1B,MAAM;GACN,MAAM;GACN,WAAW,CAAC,KAAK,SAAS;GAC3B,CAAC;AAEF,OAAK,wBAAwB,IAAID,oBAAQ;GACvC,MAAM;GACN,MAAM;GACN,WAAW,CAAC,KAAK,SAAS;GAC3B,CAAC;;;;;;;;CASJ,mBAAmB,eAAuB,cAAsB,WAAmB;AACjF,OAAK,cAAc,KAAK;AACxB,OAAK,cAAc,IAAI,cAAc;AACrC,OAAK,aAAa,IAAI,aAAa;AACnC,OAAK,aAAa,IAAI,eAAe,cAAc;AACnD,OAAK,WAAW,IAAI,UAAU;;;;;;CAOhC,YAAY,MAAc;AACxB,OAAK,OAAO,IAAI,EACd,MACD,CAAC;AAEF,MAAI,SAAS,MACX,MAAK,UAAU,KAAK;WAEb,SAAS,WAChB,MAAK,eAAe,KAAK;;;;;;CAQ7B,MAAM,aAA8B;AAClC,SAAO,KAAK,SAAS,SAAS"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["Registry","Counter","Gauge","Histogram"],"sources":["../../src/metrics/index.ts"],"sourcesContent":["/**\n * Prometheus metrics for monitoring indexer performance and health\n * Exposes metrics for blocks indexed, queue depth, errors, and processing times\n */\n\nimport {\n collectDefaultMetrics, Counter, Gauge, Histogram, Registry,\n} from \"prom-client\";\n\n/** Prometheus metrics registry */\nexport class IndexerMetrics {\n /** Prometheus registry instance */\n public readonly registry: Registry;\n\n /** Counter for total blocks indexed */\n public readonly blocksIndexed: Counter;\n\n /** Gauge for current block height */\n public readonly currentHeight: Gauge;\n\n /** Gauge for latest chain block height */\n public readonly latestHeight: Gauge;\n\n /** Gauge for blocks behind chain tip */\n public readonly blocksBehind: Gauge;\n\n /** Gauge for block queue depth */\n public readonly queueDepth: Gauge;\n\n /** Counter for total errors */\n public readonly errors: Counter;\n\n /** Counter for RPC errors */\n public readonly rpcErrors: Counter;\n\n /** Counter for database errors */\n public readonly databaseErrors: Counter;\n\n /** Histogram for block processing duration */\n public readonly blockProcessingDuration: Histogram;\n\n /** Histogram for RPC call duration */\n public readonly rpcCallDuration: Histogram;\n\n /** Histogram for database query duration */\n public readonly databaseQueryDuration: Histogram;\n\n /** Gauge for retry count */\n public readonly retryCount: Gauge;\n\n /** Counter for total transactions processed */\n public readonly transactionsProcessed: Counter;\n\n constructor() {\n this.registry = new Registry();\n\n // Collect default Node.js metrics (memory, CPU, etc.)\n collectDefaultMetrics({\n register: this.registry,\n });\n\n // Block indexing metrics\n this.blocksIndexed = new Counter({\n name: \"indexer_blocks_indexed_total\",\n help: \"Total number of blocks indexed\",\n registers: [this.registry],\n });\n\n this.currentHeight = new Gauge({\n name: \"indexer_current_height\",\n help: \"Current block height being processed\",\n registers: [this.registry],\n });\n\n this.latestHeight = new Gauge({\n name: \"indexer_latest_chain_height\",\n help: \"Latest block height on the chain\",\n registers: [this.registry],\n });\n\n this.blocksBehind = new Gauge({\n name: \"indexer_blocks_behind\",\n help: \"Number of blocks behind chain tip\",\n registers: [this.registry],\n });\n\n this.queueDepth = new Gauge({\n name: \"indexer_queue_depth\",\n help: \"Current depth of block processing queue\",\n registers: [this.registry],\n });\n\n // Error metrics\n this.errors = new Counter({\n name: \"indexer_errors_total\",\n help: \"Total number of indexer errors\",\n labelNames: [\"type\"],\n registers: [this.registry],\n });\n\n this.rpcErrors = new Counter({\n name: \"indexer_rpc_errors_total\",\n help: \"Total number of RPC errors\",\n registers: [this.registry],\n });\n\n this.databaseErrors = new Counter({\n name: \"indexer_database_errors_total\",\n help: \"Total number of database errors\",\n registers: [this.registry],\n });\n\n // Performance metrics\n this.blockProcessingDuration = new Histogram({\n name: \"indexer_block_processing_duration_seconds\",\n help: \"Time spent processing a single block\",\n buckets: [0.001, 0.005, 0.01, 0.05, 0.1, 0.5, 1, 2, 5],\n registers: [this.registry],\n });\n\n this.rpcCallDuration = new Histogram({\n name: \"indexer_rpc_call_duration_seconds\",\n help: \"Duration of RPC calls\",\n buckets: [0.01, 0.05, 0.1, 0.5, 1, 2, 5, 10],\n labelNames: [\"method\"],\n registers: [this.registry],\n });\n\n this.databaseQueryDuration = new Histogram({\n name: \"indexer_database_query_duration_seconds\",\n help: \"Duration of database queries\",\n buckets: [0.001, 0.005, 0.01, 0.05, 0.1, 0.5, 1],\n labelNames: [\"query_type\"],\n registers: [this.registry],\n });\n\n // Operational metrics\n this.retryCount = new Gauge({\n name: \"indexer_retry_count\",\n help: \"Current number of retry attempts\",\n registers: [this.registry],\n });\n\n this.transactionsProcessed = new Counter({\n name: \"indexer_transactions_processed_total\",\n help: \"Total number of transactions processed\",\n registers: [this.registry],\n });\n }\n\n /**\n * Updates block indexing metrics\n * @param currentHeight - Current height being processed\n * @param latestHeight - Latest height on chain\n * @param queueSize - Current queue depth\n */\n updateBlockMetrics(currentHeight: number, latestHeight: number, queueSize: number) {\n this.blocksIndexed.inc();\n this.currentHeight.set(currentHeight);\n this.latestHeight.set(latestHeight);\n this.blocksBehind.set(latestHeight - currentHeight);\n this.queueDepth.set(queueSize);\n }\n\n /**\n * Records an error occurrence\n * @param type - Error type (rpc, database, processing, etc.)\n */\n recordError(type: string) {\n this.errors.inc({\n type,\n });\n\n if (type === \"rpc\") {\n this.rpcErrors.inc();\n }\n else if (type === \"database\") {\n this.databaseErrors.inc();\n }\n }\n\n /**\n * Records block processing duration\n * @param durationSeconds - Duration in seconds\n */\n recordBlockProcessing(durationSeconds: number) {\n this.blockProcessingDuration.observe(durationSeconds);\n }\n\n /**\n * Times a block processing operation\n * @returns End timer function to call when operation completes\n */\n timeBlockProcessing() {\n return this.blockProcessingDuration.startTimer();\n }\n\n /**\n * Records RPC call duration\n * @param method - RPC method name\n * @param durationSeconds - Duration in seconds\n */\n recordRpcCall(method: string, durationSeconds: number) {\n this.rpcCallDuration.observe({\n method,\n }, durationSeconds);\n }\n\n /**\n * Times an RPC call operation\n * @param method - RPC method name\n * @returns End timer function to call when operation completes\n */\n timeRpcCall(method: string) {\n return this.rpcCallDuration.startTimer({\n method,\n });\n }\n\n /**\n * Records database query duration\n * @param queryType - Type of query (select, insert, update, delete, etc.)\n * @param durationSeconds - Duration in seconds\n */\n recordDatabaseQuery(queryType: string, durationSeconds: number) {\n this.databaseQueryDuration.observe({\n query_type: queryType,\n }, durationSeconds);\n }\n\n /**\n * Times a database query operation\n * @param queryType - Type of query (select, insert, update, delete, etc.)\n * @returns End timer function to call when operation completes\n */\n timeDatabaseQuery(queryType: string) {\n return this.databaseQueryDuration.startTimer({\n query_type: queryType,\n });\n }\n\n /**\n * Updates the retry count gauge\n * @param count - Current retry count\n */\n updateRetryCount(count: number) {\n this.retryCount.set(count);\n }\n\n /**\n * Increments the retry count gauge by 1\n */\n incrementRetryCount() {\n this.retryCount.inc();\n }\n\n /**\n * Resets the retry count gauge to 0\n */\n resetRetryCount() {\n this.retryCount.set(0);\n }\n\n /**\n * Records transactions processed\n * @param count - Number of transactions to record (defaults to 1)\n */\n recordTransactions(count: number = 1) {\n this.transactionsProcessed.inc(count);\n }\n\n /**\n * Gets metrics in Prometheus format\n * @returns Prometheus metrics string\n */\n async getMetrics(): Promise<string> {\n return this.registry.metrics();\n }\n}\n"],"mappings":";;;;;;;;;AAUA,IAAa,iBAAb,MAA4B;CA2C1B,cAAc;AACZ,OAAK,WAAW,IAAIA,sBAAU;AAG9B,yCAAsB,EACpB,UAAU,KAAK,UAChB,CAAC;AAGF,OAAK,gBAAgB,IAAIC,oBAAQ;GAC/B,MAAM;GACN,MAAM;GACN,WAAW,CAAC,KAAK,SAAS;GAC3B,CAAC;AAEF,OAAK,gBAAgB,IAAIC,kBAAM;GAC7B,MAAM;GACN,MAAM;GACN,WAAW,CAAC,KAAK,SAAS;GAC3B,CAAC;AAEF,OAAK,eAAe,IAAIA,kBAAM;GAC5B,MAAM;GACN,MAAM;G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ics {
|
|
|
45
45
|
* @param type - Error type (rpc, database, processing, etc.)
|
|
46
46
|
*/
|
|
47
47
|
recordError(type: string): void;
|
|
48
|
+
/**
|
|
49
|
+
* Records block processing duration
|
|
50
|
+
* @param durationSeconds - Duration in seconds
|
|
51
|
+
*/
|
|
52
|
+
recordBlockProcessing(durationSeconds: number): void;
|
|
53
|
+
/**
|
|
54
|
+
* Times a block processing operation
|
|
55
|
+
* @returns End timer function to call when operation completes
|
|
56
|
+
*/
|
|
57
|
+
timeBlockProcessing(): (labels?: Partial<Record<string, string | number>> | undefined) => number;
|
|
58
|
+
/**
|
|
59
|
+
* Records RPC call duration
|
|
60
|
+
* @param method - RPC method name
|
|
61
|
+
* @param durationSeconds - Duration in seconds
|
|
62
|
+
*/
|
|
63
|
+
recordRpcCall(method: string, durationSeconds: number): void;
|
|
64
|
+
/**
|
|
65
|
+
* Times an RPC call operation
|
|
66
|
+
* @param method - RPC method name
|
|
67
|
+
* @returns End timer function to call when operation completes
|
|
68
|
+
*/
|
|
69
|
+
timeRpcCall(method: string): (labels?: Partial<Record<string, string | number>> | undefined) => number;
|
|
70
|
+
/**
|
|
71
|
+
* Records database query duration
|
|
72
|
+
* @param queryType - Type of query (select, insert, update, delete, etc.)
|
|
73
|
+
* @param durationSeconds - Duration in seconds
|
|
74
|
+
*/
|
|
75
|
+
recordDatabaseQuery(queryType: string, durationSeconds: number): void;
|
|
76
|
+
/**
|
|
77
|
+
* Times a database query operation
|
|
78
|
+
* @param queryType - Type of query (select, insert, update, delete, etc.)
|
|
79
|
+
* @returns End timer function to call when operation completes
|
|
80
|
+
*/
|
|
81
|
+
timeDatabaseQuery(queryType: string): (labels?: Partial<Record<string, string | number>> | undefined) => number;
|
|
82
|
+
/**
|
|
83
|
+
* Updates the retry count gauge
|
|
84
|
+
* @param count - Current retry count
|
|
85
|
+
*/
|
|
86
|
+
updateRetryCount(count: number): void;
|
|
87
|
+
/**
|
|
88
|
+
* Increments the retry count gauge by 1
|
|
89
|
+
*/
|
|
90
|
+
incrementRetryCount(): void;
|
|
91
|
+
/**
|
|
92
|
+
* Resets the retry count gauge to 0
|
|
93
|
+
*/
|
|
94
|
+
resetRetryCount(): void;
|
|
95
|
+
/**
|
|
96
|
+
* Records transactions processed
|
|
97
|
+
* @param count - Number of transactions to record (defaults to 1)
|
|
98
|
+
*/
|
|
99
|
+
recordTransactions(count?: number): void;
|
|
48
100
|
/**
|
|
49
101
|
* Gets metrics in Prometheus format
|
|
50
102
|
* @returns Prometheus metrics string
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/metrics/index.ts"],"sourcesContent":[],"mappings":";;;;;AAeiC,cALpB,cAAA,CAKoB;;WAMD,QAAA,EATJ,QASI;;WAMF,aAAA,EAZG,OAYH;;WAMD,aAAA,EAfI,KAeJ;;WAMc,YAAA,EAlBX,KAkBW;;WAMF,YAAA,EArBT,KAqBS;;WAMA,UAAA,EAxBX,KAwBW;;
|
|
1
|
+
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/metrics/index.ts"],"sourcesContent":[],"mappings":";;;;;AAeiC,cALpB,cAAA,CAKoB;;WAMD,QAAA,EATJ,QASI;;WAMF,aAAA,EAZG,OAYH;;WAMD,aAAA,EAfI,KAeJ;;WAMc,YAAA,EAlBX,KAkBW;;WAMF,YAAA,EArBT,KAqBS;;WAMA,UAAA,EAxBX,KAwBW;;WA8IpB,MAAA,EAnKK,OAmKL;;WAoBO,SAAA,EApLC,OAoLD;;WAsBS,cAAA,EAvMH,OAuMG;;EAwCR,SAAA,uBAAA,EA5Oc,SA4Od;;4BAzOM;;kCAGM;;uBAGX;;kCAGW;;;;;;;;;;;;;;;;;;;;;;;mCA8IpB,QAAA;;;;;;;;;;;;yCAoBO,QAAA;;;;;;;;;;;;kDAsBS,QAAA;;;;;;;;;;;;;;;;;;;;;;;gBAwCf"}
|
package/dist/metrics/index.d.ts
CHANGED
|
@@ -45,6 +45,58 @@ declare class IndexerMetrics {
|
|
|
45
45
|
* @param type - Error type (rpc, database, processing, etc.)
|
|
46
46
|
*/
|
|
47
47
|
recordError(type: string): void;
|
|
48
|
+
/**
|
|
49
|
+
* Records block processing duration
|
|
50
|
+
* @param durationSeconds - Duration in seconds
|
|
51
|
+
*/
|
|
52
|
+
recordBlockProcessing(durationSeconds: number): void;
|
|
53
|
+
/**
|
|
54
|
+
* Times a block processing operation
|
|
55
|
+
* @returns End timer function to call when operation completes
|
|
56
|
+
*/
|
|
57
|
+
timeBlockProcessing(): (labels?: Partial<Record<string, string | number>> | undefined) => number;
|
|
58
|
+
/**
|
|
59
|
+
* Records RPC call duration
|
|
60
|
+
* @param method - RPC method name
|
|
61
|
+
* @param durationSeconds - Duration in seconds
|
|
62
|
+
*/
|
|
63
|
+
recordRpcCall(method: string, durationSeconds: number): void;
|
|
64
|
+
/**
|
|
65
|
+
* Times an RPC call operation
|
|
66
|
+
* @param method - RPC method name
|
|
67
|
+
* @returns End timer function to call when operation completes
|
|
68
|
+
*/
|
|
69
|
+
timeRpcCall(method: string): (labels?: Partial<Record<string, string | number>> | undefined) => number;
|
|
70
|
+
/**
|
|
71
|
+
* Records database query duration
|
|
72
|
+
* @param queryType - Type of query (select, insert, update, delete, etc.)
|
|
73
|
+
* @param durationSeconds - Duration in seconds
|
|
74
|
+
*/
|
|
75
|
+
recordDatabaseQuery(queryType: string, durationSeconds: number): void;
|
|
76
|
+
/**
|
|
77
|
+
* Times a database query operation
|
|
78
|
+
* @param queryType - Type of query (select, insert, update, delete, etc.)
|
|
79
|
+
* @returns End timer function to call when operation completes
|
|
80
|
+
*/
|
|
81
|
+
timeDatabaseQuery(queryType: string): (labels?: Partial<Record<string, string | number>> | undefined) => number;
|
|
82
|
+
/**
|
|
83
|
+
* Updates the retry count gauge
|
|
84
|
+
* @param count - Current retry count
|
|
85
|
+
*/
|
|
86
|
+
updateRetryCount(count: number): void;
|
|
87
|
+
/**
|
|
88
|
+
* Increments the retry count gauge by 1
|
|
89
|
+
*/
|
|
90
|
+
incrementRetryCount(): void;
|
|
91
|
+
/**
|
|
92
|
+
* Resets the retry count gauge to 0
|
|
93
|
+
*/
|
|
94
|
+
resetRetryCount(): void;
|
|
95
|
+
/**
|
|
96
|
+
* Records transactions processed
|
|
97
|
+
* @param count - Number of transactions to record (defaults to 1)
|
|
98
|
+
*/
|
|
99
|
+
recordTransactions(count?: number): void;
|
|
48
100
|
/**
|
|
49
101
|
* Gets metrics in Prometheus format
|
|
50
102
|
* @returns Prometheus metrics string
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/metrics/index.ts"],"sourcesContent":[],"mappings":";;;;;AAeiC,cALpB,cAAA,CAKoB;;WAMD,QAAA,EATJ,QASI;;WAMF,aAAA,EAZG,OAYH;;WAMD,aAAA,EAfI,KAeJ;;WAMc,YAAA,EAlBX,KAkBW;;WAMF,YAAA,EArBT,KAqBS;;WAMA,UAAA,EAxBX,KAwBW;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/metrics/index.ts"],"sourcesContent":[],"mappings":";;;;;AAeiC,cALpB,cAAA,CAKoB;;WAMD,QAAA,EATJ,QASI;;WAMF,aAAA,EAZG,OAYH;;WAMD,aAAA,EAfI,KAeJ;;WAMc,YAAA,EAlBX,KAkBW;;WAMF,YAAA,EArBT,KAqBS;;WAMA,UAAA,EAxBX,KAwBW;;WA8IpB,MAAA,EAnKK,OAmKL;;WAoBO,SAAA,EApLC,OAoLD;;WAsBS,cAAA,EAvMH,OAuMG;;EAwCR,SAAA,uBAAA,EA5Oc,SA4Od;;4BAzOM;;kCAGM;;uBAGX;;kCAGW;;;;;;;;;;;;;;;;;;;;;;;mCA8IpB,QAAA;;;;;;;;;;;;yCAoBO,QAAA;;;;;;;;;;;;kDAsBS,QAAA;;;;;;;;;;;;;;;;;;;;;;;gBAwCf"}
|
package/dist/metrics/index.js
CHANGED
|
@@ -132,6 +132,78 @@ var IndexerMetrics = class {
|
|
|
132
132
|
else if (type === "database") this.databaseErrors.inc();
|
|
133
133
|
}
|
|
134
134
|
/**
|
|
135
|
+
* Records block processing duration
|
|
136
|
+
* @param durationSeconds - Duration in seconds
|
|
137
|
+
*/
|
|
138
|
+
recordBlockProcessing(durationSeconds) {
|
|
139
|
+
this.blockProcessingDuration.observe(durationSeconds);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Times a block processing operation
|
|
143
|
+
* @returns End timer function to call when operation completes
|
|
144
|
+
*/
|
|
145
|
+
timeBlockProcessing() {
|
|
146
|
+
return this.blockProcessingDuration.startTimer();
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Records RPC call duration
|
|
150
|
+
* @param method - RPC method name
|
|
151
|
+
* @param durationSeconds - Duration in seconds
|
|
152
|
+
*/
|
|
153
|
+
recordRpcCall(method, durationSeconds) {
|
|
154
|
+
this.rpcCallDuration.observe({ method }, durationSeconds);
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Times an RPC call operation
|
|
158
|
+
* @param method - RPC method name
|
|
159
|
+
* @returns End timer function to call when operation completes
|
|
160
|
+
*/
|
|
161
|
+
timeRpcCall(method) {
|
|
162
|
+
return this.rpcCallDuration.startTimer({ method });
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Records database query duration
|
|
166
|
+
* @param queryType - Type of query (select, insert, update, delete, etc.)
|
|
167
|
+
* @param durationSeconds - Duration in seconds
|
|
168
|
+
*/
|
|
169
|
+
recordDatabaseQuery(queryType, durationSeconds) {
|
|
170
|
+
this.databaseQueryDuration.observe({ query_type: queryType }, durationSeconds);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Times a database query operation
|
|
174
|
+
* @param queryType - Type of query (select, insert, update, delete, etc.)
|
|
175
|
+
* @returns End timer function to call when operation completes
|
|
176
|
+
*/
|
|
177
|
+
timeDatabaseQuery(queryType) {
|
|
178
|
+
return this.databaseQueryDuration.startTimer({ query_type: queryType });
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Updates the retry count gauge
|
|
182
|
+
* @param count - Current retry count
|
|
183
|
+
*/
|
|
184
|
+
updateRetryCount(count) {
|
|
185
|
+
this.retryCount.set(count);
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Increments the retry count gauge by 1
|
|
189
|
+
*/
|
|
190
|
+
incrementRetryCount() {
|
|
191
|
+
this.retryCount.inc();
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Resets the retry count gauge to 0
|
|
195
|
+
*/
|
|
196
|
+
resetRetryCount() {
|
|
197
|
+
this.retryCount.set(0);
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* Records transactions processed
|
|
201
|
+
* @param count - Number of transactions to record (defaults to 1)
|
|
202
|
+
*/
|
|
203
|
+
recordTransactions(count = 1) {
|
|
204
|
+
this.transactionsProcessed.inc(count);
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
135
207
|
* Gets metrics in Prometheus format
|
|
136
208
|
* @returns Prometheus metrics string
|
|
137
209
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/metrics/index.ts"],"sourcesContent":["/**\n * Prometheus metrics for monitoring indexer performance and health\n * Exposes metrics for blocks indexed, queue depth, errors, and processing times\n */\n\nimport {\n collectDefaultMetrics, Counter, Gauge, Histogram, Registry,\n} from \"prom-client\";\n\n/** Prometheus metrics registry */\nexport class IndexerMetrics {\n /** Prometheus registry instance */\n public readonly registry: Registry;\n\n /** Counter for total blocks indexed */\n public readonly blocksIndexed: Counter;\n\n /** Gauge for current block height */\n public readonly currentHeight: Gauge;\n\n /** Gauge for latest chain block height */\n public readonly latestHeight: Gauge;\n\n /** Gauge for blocks behind chain tip */\n public readonly blocksBehind: Gauge;\n\n /** Gauge for block queue depth */\n public readonly queueDepth: Gauge;\n\n /** Counter for total errors */\n public readonly errors: Counter;\n\n /** Counter for RPC errors */\n public readonly rpcErrors: Counter;\n\n /** Counter for database errors */\n public readonly databaseErrors: Counter;\n\n /** Histogram for block processing duration */\n public readonly blockProcessingDuration: Histogram;\n\n /** Histogram for RPC call duration */\n public readonly rpcCallDuration: Histogram;\n\n /** Histogram for database query duration */\n public readonly databaseQueryDuration: Histogram;\n\n /** Gauge for retry count */\n public readonly retryCount: Gauge;\n\n /** Counter for total transactions processed */\n public readonly transactionsProcessed: Counter;\n\n constructor() {\n this.registry = new Registry();\n\n // Collect default Node.js metrics (memory, CPU, etc.)\n collectDefaultMetrics({\n register: this.registry,\n });\n\n // Block indexing metrics\n this.blocksIndexed = new Counter({\n name: \"indexer_blocks_indexed_total\",\n help: \"Total number of blocks indexed\",\n registers: [this.registry],\n });\n\n this.currentHeight = new Gauge({\n name: \"indexer_current_height\",\n help: \"Current block height being processed\",\n registers: [this.registry],\n });\n\n this.latestHeight = new Gauge({\n name: \"indexer_latest_chain_height\",\n help: \"Latest block height on the chain\",\n registers: [this.registry],\n });\n\n this.blocksBehind = new Gauge({\n name: \"indexer_blocks_behind\",\n help: \"Number of blocks behind chain tip\",\n registers: [this.registry],\n });\n\n this.queueDepth = new Gauge({\n name: \"indexer_queue_depth\",\n help: \"Current depth of block processing queue\",\n registers: [this.registry],\n });\n\n // Error metrics\n this.errors = new Counter({\n name: \"indexer_errors_total\",\n help: \"Total number of indexer errors\",\n labelNames: [\"type\"],\n registers: [this.registry],\n });\n\n this.rpcErrors = new Counter({\n name: \"indexer_rpc_errors_total\",\n help: \"Total number of RPC errors\",\n registers: [this.registry],\n });\n\n this.databaseErrors = new Counter({\n name: \"indexer_database_errors_total\",\n help: \"Total number of database errors\",\n registers: [this.registry],\n });\n\n // Performance metrics\n this.blockProcessingDuration = new Histogram({\n name: \"indexer_block_processing_duration_seconds\",\n help: \"Time spent processing a single block\",\n buckets: [0.001, 0.005, 0.01, 0.05, 0.1, 0.5, 1, 2, 5],\n registers: [this.registry],\n });\n\n this.rpcCallDuration = new Histogram({\n name: \"indexer_rpc_call_duration_seconds\",\n help: \"Duration of RPC calls\",\n buckets: [0.01, 0.05, 0.1, 0.5, 1, 2, 5, 10],\n labelNames: [\"method\"],\n registers: [this.registry],\n });\n\n this.databaseQueryDuration = new Histogram({\n name: \"indexer_database_query_duration_seconds\",\n help: \"Duration of database queries\",\n buckets: [0.001, 0.005, 0.01, 0.05, 0.1, 0.5, 1],\n labelNames: [\"query_type\"],\n registers: [this.registry],\n });\n\n // Operational metrics\n this.retryCount = new Gauge({\n name: \"indexer_retry_count\",\n help: \"Current number of retry attempts\",\n registers: [this.registry],\n });\n\n this.transactionsProcessed = new Counter({\n name: \"indexer_transactions_processed_total\",\n help: \"Total number of transactions processed\",\n registers: [this.registry],\n });\n }\n\n /**\n * Updates block indexing metrics\n * @param currentHeight - Current height being processed\n * @param latestHeight - Latest height on chain\n * @param queueSize - Current queue depth\n */\n updateBlockMetrics(currentHeight: number, latestHeight: number, queueSize: number) {\n this.blocksIndexed.inc();\n this.currentHeight.set(currentHeight);\n this.latestHeight.set(latestHeight);\n this.blocksBehind.set(latestHeight - currentHeight);\n this.queueDepth.set(queueSize);\n }\n\n /**\n * Records an error occurrence\n * @param type - Error type (rpc, database, processing, etc.)\n */\n recordError(type: string) {\n this.errors.inc({\n type,\n });\n\n if (type === \"rpc\") {\n this.rpcErrors.inc();\n }\n else if (type === \"database\") {\n this.databaseErrors.inc();\n }\n }\n\n /**\n * Gets metrics in Prometheus format\n * @returns Prometheus metrics string\n */\n async getMetrics(): Promise<string> {\n return this.registry.metrics();\n }\n}\n"],"mappings":";;;;;;;;AAUA,IAAa,iBAAb,MAA4B;CA2C1B,cAAc;AACZ,OAAK,WAAW,IAAI,UAAU;AAG9B,wBAAsB,EACpB,UAAU,KAAK,UAChB,CAAC;AAGF,OAAK,gBAAgB,IAAI,QAAQ;GAC/B,MAAM;GACN,MAAM;GACN,WAAW,CAAC,KAAK,SAAS;GAC3B,CAAC;AAEF,OAAK,gBAAgB,IAAI,MAAM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,IAAI,MAAM;GAC1B,MAAM;GACN,MAAM;GACN,WAAW,CAAC,KAAK,SAAS;GAC3B,CAAC;AAEF,OAAK,wBAAwB,IAAI,QAAQ;GACvC,MAAM;GACN,MAAM;GACN,WAAW,CAAC,KAAK,SAAS;GAC3B,CAAC;;;;;;;;CASJ,mBAAmB,eAAuB,cAAsB,WAAmB;AACjF,OAAK,cAAc,KAAK;AACxB,OAAK,cAAc,IAAI,cAAc;AACrC,OAAK,aAAa,IAAI,aAAa;AACnC,OAAK,aAAa,IAAI,eAAe,cAAc;AACnD,OAAK,WAAW,IAAI,UAAU;;;;;;CAOhC,YAAY,MAAc;AACxB,OAAK,OAAO,IAAI,EACd,MACD,CAAC;AAEF,MAAI,SAAS,MACX,MAAK,UAAU,KAAK;WAEb,SAAS,WAChB,MAAK,eAAe,KAAK;;;;;;CAQ7B,MAAM,aAA8B;AAClC,SAAO,KAAK,SAAS,SAAS"}
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/metrics/index.ts"],"sourcesContent":["/**\n * Prometheus metrics for monitoring indexer performance and health\n * Exposes metrics for blocks indexed, queue depth, errors, and processing times\n */\n\nimport {\n collectDefaultMetrics, Counter, Gauge, Histogram, Registry,\n} from \"prom-client\";\n\n/** Prometheus metrics registry */\nexport class IndexerMetrics {\n /** Prometheus registry instance */\n public readonly registry: Registry;\n\n /** Counter for total blocks indexed */\n public readonly blocksIndexed: Counter;\n\n /** Gauge for current block height */\n public readonly currentHeight: Gauge;\n\n /** Gauge for latest chain block height */\n public readonly latestHeight: Gauge;\n\n /** Gauge for blocks behind chain tip */\n public readonly blocksBehind: Gauge;\n\n /** Gauge for block queue depth */\n public readonly queueDepth: Gauge;\n\n /** Counter for total errors */\n public readonly errors: Counter;\n\n /** Counter for RPC errors */\n public readonly rpcErrors: Counter;\n\n /** Counter for database errors */\n public readonly databaseErrors: Counter;\n\n /** Histogram for block processing duration */\n public readonly blockProcessingDuration: Histogram;\n\n /** Histogram for RPC call duration */\n public readonly rpcCallDuration: Histogram;\n\n /** Histogram for database query duration */\n public readonly databaseQueryDuration: Histogram;\n\n /** Gauge for retry count */\n public readonly retryCount: Gauge;\n\n /** Counter for total transactions processed */\n public readonly transactionsProcessed: Counter;\n\n constructor() {\n this.registry = new Registry();\n\n // Collect default Node.js metrics (memory, CPU, etc.)\n collectDefaultMetrics({\n register: this.registry,\n });\n\n // Block indexing metrics\n this.blocksIndexed = new Counter({\n name: \"indexer_blocks_indexed_total\",\n help: \"Total number of blocks indexed\",\n registers: [this.registry],\n });\n\n this.currentHeight = new Gauge({\n name: \"indexer_current_height\",\n help: \"Current block height being processed\",\n registers: [this.registry],\n });\n\n this.latestHeight = new Gauge({\n name: \"indexer_latest_chain_height\",\n help: \"Latest block height on the chain\",\n registers: [this.registry],\n });\n\n this.blocksBehind = new Gauge({\n name: \"indexer_blocks_behind\",\n help: \"Number of blocks behind chain tip\",\n registers: [this.registry],\n });\n\n this.queueDepth = new Gauge({\n name: \"indexer_queue_depth\",\n help: \"Current depth of block processing queue\",\n registers: [this.registry],\n });\n\n // Error metrics\n this.errors = new Counter({\n name: \"indexer_errors_total\",\n help: \"Total number of indexer errors\",\n labelNames: [\"type\"],\n registers: [this.registry],\n });\n\n this.rpcErrors = new Counter({\n name: \"indexer_rpc_errors_total\",\n help: \"Total number of RPC errors\",\n registers: [this.registry],\n });\n\n this.databaseErrors = new Counter({\n name: \"indexer_database_errors_total\",\n help: \"Total number of database errors\",\n registers: [this.registry],\n });\n\n // Performance metrics\n this.blockProcessingDuration = new Histogram({\n name: \"indexer_block_processing_duration_seconds\",\n help: \"Time spent processing a single block\",\n buckets: [0.001, 0.005, 0.01, 0.05, 0.1, 0.5, 1, 2, 5],\n registers: [this.registry],\n });\n\n this.rpcCallDuration = new Histogram({\n name: \"indexer_rpc_call_duration_seconds\",\n help: \"Duration of RPC calls\",\n buckets: [0.01, 0.05, 0.1, 0.5, 1, 2, 5, 10],\n labelNames: [\"method\"],\n registers: [this.registry],\n });\n\n this.databaseQueryDuration = new Histogram({\n name: \"indexer_database_query_duration_seconds\",\n help: \"Duration of database queries\",\n buckets: [0.001, 0.005, 0.01, 0.05, 0.1, 0.5, 1],\n labelNames: [\"query_type\"],\n registers: [this.registry],\n });\n\n // Operational metrics\n this.retryCount = new Gauge({\n name: \"indexer_retry_count\",\n help: \"Current number of retry attempts\",\n registers: [this.registry],\n });\n\n this.transactionsProcessed = new Counter({\n name: \"indexer_transactions_processed_total\",\n help: \"Total number of transactions processed\",\n registers: [this.registry],\n });\n }\n\n /**\n * Updates block indexing metrics\n * @param currentHeight - Current height being processed\n * @param latestHeight - Latest height on chain\n * @param queueSize - Current queue depth\n */\n updateBlockMetrics(currentHeight: number, latestHeight: number, queueSize: number) {\n this.blocksIndexed.inc();\n this.currentHeight.set(currentHeight);\n this.latestHeight.set(latestHeight);\n this.blocksBehind.set(latestHeight - currentHeight);\n this.queueDepth.set(queueSize);\n }\n\n /**\n * Records an error occurrence\n * @param type - Error type (rpc, database, processing, etc.)\n */\n recordError(type: string) {\n this.errors.inc({\n type,\n });\n\n if (type === \"rpc\") {\n this.rpcErrors.inc();\n }\n else if (type === \"database\") {\n this.databaseErrors.inc();\n }\n }\n\n /**\n * Records block processing duration\n * @param durationSeconds - Duration in seconds\n */\n recordBlockProcessing(durationSeconds: number) {\n this.blockProcessingDuration.observe(durationSeconds);\n }\n\n /**\n * Times a block processing operation\n * @returns End timer function to call when operation completes\n */\n timeBlockProcessing() {\n return this.blockProcessingDuration.startTimer();\n }\n\n /**\n * Records RPC call duration\n * @param method - RPC method name\n * @param durationSeconds - Duration in seconds\n */\n recordRpcCall(method: string, durationSeconds: number) {\n this.rpcCallDuration.observe({\n method,\n }, durationSeconds);\n }\n\n /**\n * Times an RPC call operation\n * @param method - RPC method name\n * @returns End timer function to call when operation completes\n */\n timeRpcCall(method: string) {\n return this.rpcCallDuration.startTimer({\n method,\n });\n }\n\n /**\n * Records database query duration\n * @param queryType - Type of query (select, insert, update, delete, etc.)\n * @param durationSeconds - Duration in seconds\n */\n recordDatabaseQuery(queryType: string, durationSeconds: number) {\n this.databaseQueryDuration.observe({\n query_type: queryType,\n }, durationSeconds);\n }\n\n /**\n * Times a database query operation\n * @param queryType - Type of query (select, insert, update, delete, etc.)\n * @returns End timer function to call when operation completes\n */\n timeDatabaseQuery(queryType: string) {\n return this.databaseQueryDuration.startTimer({\n query_type: queryType,\n });\n }\n\n /**\n * Updates the retry count gauge\n * @param count - Current retry count\n */\n updateRetryCount(count: number) {\n this.retryCount.set(count);\n }\n\n /**\n * Increments the retry count gauge by 1\n */\n incrementRetryCount() {\n this.retryCount.inc();\n }\n\n /**\n * Resets the retry count gauge to 0\n */\n resetRetryCount() {\n this.retryCount.set(0);\n }\n\n /**\n * Records transactions processed\n * @param count - Number of transactions to record (defaults to 1)\n */\n recordTransactions(count: number = 1) {\n this.transactionsProcessed.inc(count);\n }\n\n /**\n * Gets metrics in Prometheus format\n * @returns Prometheus metrics string\n */\n async getMetrics(): Promise<string> {\n return this.registry.metrics();\n }\n}\n"],"mappings":";;;;;;;;AAUA,IAAa,iBAAb,MAA4B;CA2C1B,cAAc;AACZ,OAAK,WAAW,IAAI,UAAU;AAG9B,wBAAsB,EACpB,UAAU,KAAK,UAChB,CAAC;AAGF,OAAK,gBAAgB,IAAI,QAAQ;GAC/B,MAAM;GACN,MAAM;GACN,WAAW,CAAC,KAAK,SAAS;GAC3B,CAAC;AAEF,OAAK,gBAAgB,IAAI,MAAM;GAC7B,MAAM;GACN,MAAM;GACN,WAAW,CAAC,KAAK,SAAS;GAC3B,CAAC;AAEF,OAAK,eAAe,IAAI,MAAM;GAC5B,MAAM;GACN,MAAM;GACN,WAAW,CAAC,KAAK,SAAS;GAC3B,CAAC;AAEF,OAAK,eAAe,IAAI,MAAM;GAC5B,MAAM;GACN,MAAM;GACN,WAAW,CAAC,KAAK,SAAS;GAC3B,CAAC;AAEF,OAAK,aAAa,IAAI,MAAM;GAC1B,MAAM;GACN,MAAM;GACN,W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AAa,IAAI,eAAe,cAAc;AACnD,OAAK,WAAW,IAAI,UAAU;;;;;;CAOhC,YAAY,MAAc;AACxB,OAAK,OAAO,IAAI,EACd,MACD,CAAC;AAEF,MAAI,SAAS,MACX,MAAK,UAAU,KAAK;WAEb,SAAS,WAChB,MAAK,eAAe,KAAK;;;;;;CAQ7B,sBAAsB,iBAAyB;AAC7C,OAAK,wBAAwB,QAAQ,gBAAgB;;;;;;CAOvD,sBAAsB;AACpB,SAAO,KAAK,wBAAwB,YAAY;;;;;;;CAQlD,cAAc,QAAgB,iBAAyB;AACrD,OAAK,gBAAgB,QAAQ,EAC3B,QACD,EAAE,gBAAgB;;;;;;;CAQrB,YAAY,QAAgB;AAC1B,SAAO,KAAK,gBAAgB,WAAW,EACrC,QACD,CAAC;;;;;;;CAQJ,oBAAoB,WAAmB,iBAAyB;AAC9D,OAAK,sBAAsB,QAAQ,EACjC,YAAY,WACb,EAAE,gBAAgB;;;;;;;CAQrB,kBAAkB,WAAmB;AACnC,SAAO,KAAK,sBAAsB,WAAW,EAC3C,YAAY,WACb,CAAC;;;;;;CAOJ,iBAAiB,OAAe;AAC9B,OAAK,WAAW,IAAI,MAAM;;;;;CAM5B,sBAAsB;AACpB,OAAK,WAAW,KAAK;;;;;CAMvB,kBAAkB;AAChB,OAAK,WAAW,IAAI,EAAE;;;;;;CAOxB,mBAAmB,QAAgB,GAAG;AACpC,OAAK,sBAAsB,IAAI,MAAM;;;;;;CAOvC,MAAM,aAA8B;AAClC,SAAO,KAAK,SAAS,SAAS"}
|
package/dist/types/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":[],"sources":["../../src/types/index.ts"],"sourcesContent":["/* eslint-disable @stylistic/no-multi-spaces */\nimport {\n BlockResponse, BlockResultsResponse,\n} from \"@cosmjs/tendermint-rpc\";\nimport {\n BlockResultsResponse as BlockResultsResponse38, Event,\n} from \"@cosmjs/tendermint-rpc/build/comet38/responses\";\nimport {\n Validator,\n} from \"cosmjs-types/cosmos/staking/v1beta1/staking\";\nimport {\n TxBody,\n} from \"cosmjs-types/cosmos/tx/v1beta1/tx\";\n\nimport {\n EcleciaIndexer,\n} from \"../indexer\";\nimport {\n CircularBuffer,\n} from \"../promise-queue\";\n\n/** Configuration interface for the Eclesia indexer */\nexport type EcleciaIndexerConfig = {\n startHeight?: number // Block height to start indexing from\n endHeight?: number // Block height to stop indexing at (optional)\n batchSize: number // Number of blocks to process in parallel\n modules: string[] // List of module names to enable\n getNextHeight: () => number | PromiseLike<number> // Function to determine next block to process\n logLevel: \"error\" | \"warn\" | \"info\" | \"http\" | \"verbose\" | \"debug\" | \"silly\" // Logging verbosity level\n rpcUrl: string // Tendermint RPC endpoint URL\n shouldProcessGenesis: () => Promise<boolean> // Whether to process genesis state\n genesisPath?: string // Path to genesis file\n usePolling?: boolean // Use polling instead of WebSocket subscription\n pollingInterval?: number // Interval between polls in milliseconds\n minimal?: boolean // Use minimal indexing mode (blocks only)\n healthCheckPort?: number // Port for health check HTTP server (default: 8080)\n init?: () => Promise<void> // Custom initialization function\n beginTransaction: () => Promise<void> // Function to begin database transaction\n endTransaction: (status: boolean) => Promise<void>
|
|
1
|
+
{"version":3,"file":"index.cjs","names":[],"sources":["../../src/types/index.ts"],"sourcesContent":["/* eslint-disable @stylistic/no-multi-spaces */\nimport {\n BlockResponse, BlockResultsResponse,\n} from \"@cosmjs/tendermint-rpc\";\nimport {\n BlockResultsResponse as BlockResultsResponse38, Event,\n} from \"@cosmjs/tendermint-rpc/build/comet38/responses\";\nimport {\n Validator,\n} from \"cosmjs-types/cosmos/staking/v1beta1/staking\";\nimport {\n TxBody,\n} from \"cosmjs-types/cosmos/tx/v1beta1/tx\";\n\nimport {\n EcleciaIndexer,\n} from \"../indexer\";\nimport {\n CircularBuffer,\n} from \"../promise-queue\";\n\n/** Configuration interface for the Eclesia indexer */\nexport type EcleciaIndexerConfig = {\n startHeight?: number // Block height to start indexing from\n endHeight?: number // Block height to stop indexing at (optional)\n batchSize: number // Number of blocks to process in parallel\n modules: string[] // List of module names to enable\n getNextHeight: () => number | PromiseLike<number> // Function to determine next block to process\n logLevel: \"error\" | \"warn\" | \"info\" | \"http\" | \"verbose\" | \"debug\" | \"silly\" // Logging verbosity level\n rpcUrl: string // Tendermint RPC endpoint URL\n shouldProcessGenesis: () => Promise<boolean> // Whether to process genesis state\n genesisPath?: string // Path to genesis file\n usePolling?: boolean // Use polling instead of WebSocket subscription\n pollingInterval?: number // Interval between polls in milliseconds\n minimal?: boolean // Use minimal indexing mode (blocks only)\n healthCheckPort?: number // Port for health check HTTP server (default: 8080)\n enablePrometheus?: boolean // Enable Prometheus metrics server\n prometheusPort?: number // Port for Prometheus metrics server (default: 9090)\n init?: () => Promise<void> // Custom initialization function\n beginTransaction: () => Promise<void> // Function to begin database transaction\n endTransaction: (status: boolean) => Promise<void> // Function to end database transaction\n};\n\n/** Queue for full indexing mode with validator data */\nexport type FullBlockQueue = CircularBuffer<[BlockResponse, BlockResultsResponse, Uint8Array]>;\n\n/** Queue for minimal indexing mode without validator data */\nexport type MinimalBlockQueue = CircularBuffer<[BlockResponse, BlockResultsResponse]>;\n\n/** Union type for block queues */\nexport type BlockQueue = FullBlockQueue | MinimalBlockQueue;\n\n/** Utility type to add height, timestamp, and UUID to event types */\nexport type WithHeightAndUUID<T> = {\n [K in keyof T]: T[K] & {\n uuid?: string // Unique identifier for event tracking\n height?: number // Block height when event occurred\n timestamp?: string // Block timestamp when event occurred\n };\n};\n\n/** Function signature for emitting events asynchronously */\nexport type EmitFunc<K extends keyof WithHeightAndUUID<EventMap>> = (\n t: K,\n e: WithHeightAndUUID<EventMap>[K]\n) => Promise<void | void[]>;\n\nexport type LogEvent = {\n type: \"log\" | \"info\" | \"warning\" | \"error\" | \"verbose\" | \"transient\"\n message: string\n};\nexport type UUIDEvent = {\n uuid: string\n error?: string\n status: boolean\n};\nexport type Events = {\n log: LogEvent\n uuid: UUIDEvent\n \"fatal-error\": {\n error: Error\n message: string\n retryCount?: number\n }\n begin_block: {\n value: {\n events: BlockResultsResponse[\"beginBlockEvents\"] | BlockResultsResponse38[\"finalizeBlockEvents\"]\n validators: Validator[] | undefined\n }\n }\n\n block: {\n value: {\n block: BlockResponse\n block_results: BlockResultsResponse | BlockResultsResponse38\n }\n }\n end_block: {\n value: BlockResultsResponse[\"endBlockEvents\"] | BlockResultsResponse38[\"finalizeBlockEvents\"]\n }\n tx_events: {\n value: BlockResultsResponse[\"results\"] | BlockResultsResponse38[\"results\"]\n }\n tx_memo: {\n value: {\n txHash: string\n txBody: TxBody\n }\n }\n _unhandled: {\n type: string\n event: unknown\n }\n \"periodic/50\": {\n value: null\n }\n \"periodic/100\": {\n value: null\n }\n \"periodic/1000\": {\n value: null\n }\n};\nexport type TxResult<T> = {\n tx: T\n events: Event[]\n};\n\n/** Interface that all indexing modules must implement */\nexport interface IndexingModule {\n indexer: EcleciaIndexer // Reference to the main indexer instance\n name: string // Unique module name\n depends: string[] // Array of module names this module depends on\n provides: string[] // Array of capabilities this module provides\n setup: () => Promise<void> // Async setup function for database schema initialization\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n init: (...args: any[]) => void // Initialization function called by the indexer\n}\n"],"mappings":""}
|
package/dist/types/index.d.cts
CHANGED
|
@@ -24,6 +24,8 @@ type EcleciaIndexerConfig = {
|
|
|
24
24
|
pollingInterval?: number;
|
|
25
25
|
minimal?: boolean;
|
|
26
26
|
healthCheckPort?: number;
|
|
27
|
+
enablePrometheus?: boolean;
|
|
28
|
+
prometheusPort?: number;
|
|
27
29
|
init?: () => Promise<void>;
|
|
28
30
|
beginTransaction: () => Promise<void>;
|
|
29
31
|
endTransaction: (status: boolean) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","names":[],"sources":["../../src/types/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;KAsBY,oBAAA;;;;;gCAKoB;;;8BAGF
|
|
1
|
+
{"version":3,"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R,MAAA,GAtBQ;EAAC,GAAA,EAuBd,QAvBc;EAQT,IAAA,EAgBJ,SAhBY;EAAA,aAAA,EAAA;IAAmC,KAAA,EAkB5C,KAlB4C;IAAlB,OAAA,EAAA,MAAA;IAChC,UAAA,CAAA,EAAA,MAAA;;aACA,EAAA;IAA4B,KAAA,EAAA;MAC5B,MAAA,EAqBS,oBArBT,CAAA,kBAAA,CAAA,GAqBoD,sBArBpD,CAAA,qBAAA,CAAA;MAAO,UAAA,EAsBM,SAtBN,EAAA,GAAA,SAAA;IAEA,CAAA;EAIA,CAAA;EAKA,KAAA,EAAA;IAAM,KAAA,EAAA;MACX,KAAA,EAgBM,aAhBN;MACC,aAAA,EAgBa,oBAhBb,GAgBoC,sBAhBpC;IAEG,CAAA;;WAM8C,EAAA;IACvC,KAAA,EAWP,oBAXO,CAAA,gBAAA,CAAA,GAWkC,sBAXlC,CAAA,qBAAA,CAAA;;WAOG,EAAA;IAAuB,KAAA,EAOjC,oBAPiC,CAAA,SAAA,CAAA,GAOC,sBAPD,CAAA,SAAA,CAAA;;SAIQ,EAAA;IAGzC,KAAA,EAAA;MAAkC,MAAA,EAAA,MAAA;MAK/B,MAAA,EAAA,MAAA;IAAM,CAAA;EAiBR,CAAA;EAAQ,UAAA,EAAA;IACd,IAAA,EAAA,MAAA;IACI,KAAA,EAAA,OAAA;EAAK,CAAA;EAIE,aAAA,EAAA;IAAc,KAAA,EAAA,IAAA;;gBAKhB,EAAA;IAAO,KAAA,EAAA,IAAA;;;;;;KAXV;MACN;UACI;;;UAIO,cAAA;WACN;;;;eAII"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -24,6 +24,8 @@ type EcleciaIndexerConfig = {
|
|
|
24
24
|
pollingInterval?: number;
|
|
25
25
|
minimal?: boolean;
|
|
26
26
|
healthCheckPort?: number;
|
|
27
|
+
enablePrometheus?: boolean;
|
|
28
|
+
prometheusPort?: number;
|
|
27
29
|
init?: () => Promise<void>;
|
|
28
30
|
beginTransaction: () => Promise<void>;
|
|
29
31
|
endTransaction: (status: boolean) => Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/types/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;KAsBY,oBAAA;;;;;gCAKoB;;;8BAGF
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../src/types/index.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;KAsBY,oBAAA;;;;;gCAKoB;;;8BAGF;;;;;;;EARlB,cAAA,CAAA,EAAA,MAAoB;EAAA,IAAA,CAAA,EAAA,GAAA,GAgBjB,OAhBiB,CAAA,IAAA,CAAA;kBAKA,EAAA,GAAA,GAYN,OAZM,CAAA,IAAA,CAAA;gBAGF,EAAA,CAAA,MAAA,EAAA,OAAA,EAAA,GAUS,OAVT,CAAA,IAAA,CAAA;;;AAUS,KAI3B,cAAA,GAAiB,cAJU,CAAA,CAIM,aAJN,EAIqB,oBAJrB,EAI2C,UAJ3C,CAAA,CAAA;;AAI3B,KAGA,iBAAA,GAAoB,cAHN,CAAA,CAGsB,aAHtB,EAGqC,oBAHrC,CAAA,CAAA;;AAAmB,KAMjC,UAAA,GAAa,cANoB,GAMH,iBANG;;AAAqC,KAStE,iBATsE,CAAA,CAAA,CAAA,GAAA,QAArD,MAUf,CAVe,GAUX,CAVW,CAUT,CAVS,CAAA,GAAA;EAAc,IAAA,CAAA,EAAA,MAAA;EAG/B,MAAA,CAAA,EAAA,MAAA;EAAiB,SAAA,CAAA,EAAA,MAAA;;;AAAiB,KAelC,QAfkC,CAAA,UAAA,MAeT,iBAfS,CAeS,QAfT,CAAA,CAAA,GAAA,CAAA,CAAA,EAgBzC,CAhByC,EAAA,CAAA,EAiBzC,iBAjByC,CAiBvB,QAjBuB,CAAA,CAiBb,CAjBa,CAAA,EAAA,GAkBzC,OAlByC,CAAA,IAAA,GAAA,IAAA,EAAA,CAAA;AAGlC,KAiBA,QAAA,GAjBU;E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+1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":[],"sources":["../../src/types/index.ts"],"sourcesContent":["/* eslint-disable @stylistic/no-multi-spaces */\nimport {\n BlockResponse, BlockResultsResponse,\n} from \"@cosmjs/tendermint-rpc\";\nimport {\n BlockResultsResponse as BlockResultsResponse38, Event,\n} from \"@cosmjs/tendermint-rpc/build/comet38/responses\";\nimport {\n Validator,\n} from \"cosmjs-types/cosmos/staking/v1beta1/staking\";\nimport {\n TxBody,\n} from \"cosmjs-types/cosmos/tx/v1beta1/tx\";\n\nimport {\n EcleciaIndexer,\n} from \"../indexer\";\nimport {\n CircularBuffer,\n} from \"../promise-queue\";\n\n/** Configuration interface for the Eclesia indexer */\nexport type EcleciaIndexerConfig = {\n startHeight?: number // Block height to start indexing from\n endHeight?: number // Block height to stop indexing at (optional)\n batchSize: number // Number of blocks to process in parallel\n modules: string[] // List of module names to enable\n getNextHeight: () => number | PromiseLike<number> // Function to determine next block to process\n logLevel: \"error\" | \"warn\" | \"info\" | \"http\" | \"verbose\" | \"debug\" | \"silly\" // Logging verbosity level\n rpcUrl: string // Tendermint RPC endpoint URL\n shouldProcessGenesis: () => Promise<boolean> // Whether to process genesis state\n genesisPath?: string // Path to genesis file\n usePolling?: boolean // Use polling instead of WebSocket subscription\n pollingInterval?: number // Interval between polls in milliseconds\n minimal?: boolean // Use minimal indexing mode (blocks only)\n healthCheckPort?: number // Port for health check HTTP server (default: 8080)\n init?: () => Promise<void> // Custom initialization function\n beginTransaction: () => Promise<void> // Function to begin database transaction\n endTransaction: (status: boolean) => Promise<void>
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../../src/types/index.ts"],"sourcesContent":["/* eslint-disable @stylistic/no-multi-spaces */\nimport {\n BlockResponse, BlockResultsResponse,\n} from \"@cosmjs/tendermint-rpc\";\nimport {\n BlockResultsResponse as BlockResultsResponse38, Event,\n} from \"@cosmjs/tendermint-rpc/build/comet38/responses\";\nimport {\n Validator,\n} from \"cosmjs-types/cosmos/staking/v1beta1/staking\";\nimport {\n TxBody,\n} from \"cosmjs-types/cosmos/tx/v1beta1/tx\";\n\nimport {\n EcleciaIndexer,\n} from \"../indexer\";\nimport {\n CircularBuffer,\n} from \"../promise-queue\";\n\n/** Configuration interface for the Eclesia indexer */\nexport type EcleciaIndexerConfig = {\n startHeight?: number // Block height to start indexing from\n endHeight?: number // Block height to stop indexing at (optional)\n batchSize: number // Number of blocks to process in parallel\n modules: string[] // List of module names to enable\n getNextHeight: () => number | PromiseLike<number> // Function to determine next block to process\n logLevel: \"error\" | \"warn\" | \"info\" | \"http\" | \"verbose\" | \"debug\" | \"silly\" // Logging verbosity level\n rpcUrl: string // Tendermint RPC endpoint URL\n shouldProcessGenesis: () => Promise<boolean> // Whether to process genesis state\n genesisPath?: string // Path to genesis file\n usePolling?: boolean // Use polling instead of WebSocket subscription\n pollingInterval?: number // Interval between polls in milliseconds\n minimal?: boolean // Use minimal indexing mode (blocks only)\n healthCheckPort?: number // Port for health check HTTP server (default: 8080)\n enablePrometheus?: boolean // Enable Prometheus metrics server\n prometheusPort?: number // Port for Prometheus metrics server (default: 9090)\n init?: () => Promise<void> // Custom initialization function\n beginTransaction: () => Promise<void> // Function to begin database transaction\n endTransaction: (status: boolean) => Promise<void> // Function to end database transaction\n};\n\n/** Queue for full indexing mode with validator data */\nexport type FullBlockQueue = CircularBuffer<[BlockResponse, BlockResultsResponse, Uint8Array]>;\n\n/** Queue for minimal indexing mode without validator data */\nexport type MinimalBlockQueue = CircularBuffer<[BlockResponse, BlockResultsResponse]>;\n\n/** Union type for block queues */\nexport type BlockQueue = FullBlockQueue | MinimalBlockQueue;\n\n/** Utility type to add height, timestamp, and UUID to event types */\nexport type WithHeightAndUUID<T> = {\n [K in keyof T]: T[K] & {\n uuid?: string // Unique identifier for event tracking\n height?: number // Block height when event occurred\n timestamp?: string // Block timestamp when event occurred\n };\n};\n\n/** Function signature for emitting events asynchronously */\nexport type EmitFunc<K extends keyof WithHeightAndUUID<EventMap>> = (\n t: K,\n e: WithHeightAndUUID<EventMap>[K]\n) => Promise<void | void[]>;\n\nexport type LogEvent = {\n type: \"log\" | \"info\" | \"warning\" | \"error\" | \"verbose\" | \"transient\"\n message: string\n};\nexport type UUIDEvent = {\n uuid: string\n error?: string\n status: boolean\n};\nexport type Events = {\n log: LogEvent\n uuid: UUIDEvent\n \"fatal-error\": {\n error: Error\n message: string\n retryCount?: number\n }\n begin_block: {\n value: {\n events: BlockResultsResponse[\"beginBlockEvents\"] | BlockResultsResponse38[\"finalizeBlockEvents\"]\n validators: Validator[] | undefined\n }\n }\n\n block: {\n value: {\n block: BlockResponse\n block_results: BlockResultsResponse | BlockResultsResponse38\n }\n }\n end_block: {\n value: BlockResultsResponse[\"endBlockEvents\"] | BlockResultsResponse38[\"finalizeBlockEvents\"]\n }\n tx_events: {\n value: BlockResultsResponse[\"results\"] | BlockResultsResponse38[\"results\"]\n }\n tx_memo: {\n value: {\n txHash: string\n txBody: TxBody\n }\n }\n _unhandled: {\n type: string\n event: unknown\n }\n \"periodic/50\": {\n value: null\n }\n \"periodic/100\": {\n value: null\n }\n \"periodic/1000\": {\n value: null\n }\n};\nexport type TxResult<T> = {\n tx: T\n events: Event[]\n};\n\n/** Interface that all indexing modules must implement */\nexport interface IndexingModule {\n indexer: EcleciaIndexer // Reference to the main indexer instance\n name: string // Unique module name\n depends: string[] // Array of module names this module depends on\n provides: string[] // Array of capabilities this module provides\n setup: () => Promise<void> // Async setup function for database schema initialization\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n init: (...args: any[]) => void // Initialization function called by the indexer\n}\n"],"mappings":""}
|