Export metric for total ETH RPC count by methods

This commit is contained in:
Nabarun 2024-07-12 16:03:16 +05:30
parent 2217cd3ffb
commit e4192e7f77
2 changed files with 8 additions and 1 deletions

View File

@ -82,6 +82,12 @@ export const isSyncingHistoricalBlocks = new client.Gauge({
});
isSyncingHistoricalBlocks.set(Number(undefined));
export const ethRpcCount = new client.Counter({
name: 'watcher_eth_rpc_total',
help: 'Total number of ETH RPC requests',
labelNames: ['method', 'provider']
});
export const ethRpcErrors = new client.Counter({
name: 'watcher_eth_rpc_errors',
help: 'Number of ETH RPC request errors',

View File

@ -22,7 +22,7 @@ import { ResultEvent } from './indexer';
import { EventInterface, EthFullBlock, EthFullTransaction } from './types';
import { BlockHeight } from './database';
import { Transaction } from './graph/utils';
import { ethRpcErrors, ethRpcRequestDuration } from './metrics';
import { ethRpcCount, ethRpcErrors, ethRpcRequestDuration } from './metrics';
const JSONbigNative = JSONbig({ useNativeBigInt: true });
@ -379,6 +379,7 @@ export class MonitoredStaticJsonRpcProvider extends providers.StaticJsonRpcProvi
// Rethrow the error
throw err;
} finally {
ethRpcCount.inc({ method, provider: this.connection.url }, 1);
endTimer();
}
}