Skip to content

Commit

Permalink
Rethrow errors in overridden send provider method
Browse files Browse the repository at this point in the history
  • Loading branch information
prathamesh0 committed May 15, 2024
1 parent 41183f1 commit 0baafcd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
27 changes: 13 additions & 14 deletions packages/util/src/metrics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,19 @@ export const ethRpcErrors = new client.Counter({
help: 'Number of ETH RPC request errors',
labelNames: ['method', 'provider']
});
ethRpcErrors.reset();

export const ethRpcRequestDuration = new client.Gauge({
name: 'watcher_eth_rpc_request_duration',
help: 'ETH RPC request duration (in seconds)',
labelNames: ['method', 'provider']
});

const upstreamEndpointsMetric = new client.Gauge({
name: 'watcher_config_upstream_endpoints',
help: 'Configured upstream ETH RPC endpoints',
labelNames: ['provider']
});

// Export metrics on a server
const app: Application = express();

Expand Down Expand Up @@ -159,6 +164,13 @@ export const startMetricsServer = async (config: Config, indexer: IndexerInterfa
});
};

export const setActiveUpstreamEndpointMetric = ({ upstream }: Config, currentEndpointIndex: number): void => {
const endpoints = upstream.ethServer.rpcProviderEndpoints;
endpoints.forEach((endpoint, index) => {
upstreamEndpointsMetric.set({ provider: endpoint }, Number(index === currentEndpointIndex));
});
};

const registerDBSizeMetrics = async ({ database, jobQueue }: Config): Promise<void> => {
const [watcherConn, jobQueueConn] = await Promise.all([
createConnection({
Expand Down Expand Up @@ -234,16 +246,3 @@ const registerWatcherConfigMetrics = async ({ server, upstream, jobQueue }: Conf
watcherConfigMetric.set({ category: 'jobqueue', field: 'historical_logs_block_range' }, Number(jobQueue.historicalLogsBlockRange));
watcherConfigMetric.set({ category: 'jobqueue', field: 'historical_max_fetch_ahead' }, Number(jobQueue.historicalMaxFetchAhead));
};

const upstreamEndpointsMetric = new client.Gauge({
name: 'watcher_config_upstream_endpoints',
help: 'Configured upstream ETH RPC endpoints',
labelNames: ['provider']
});

export const setActiveUpstreamEndpointMetric = ({ upstream }: Config, currentEndpointIndex: number): void => {
const endpoints = upstream.ethServer.rpcProviderEndpoints;
endpoints.forEach((endpoint, index) => {
upstreamEndpointsMetric.set({ provider: endpoint }, Number(index === currentEndpointIndex));
});
};
2 changes: 1 addition & 1 deletion packages/util/src/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ export class MonitoredStaticJsonRpcProvider extends providers.StaticJsonRpcProvi
// Ignore errors on fetching future blocks and if block is null (in case of filecoin)
if (err.code === ethersErrors.SERVER_ERROR && err.error) {
if (err.error.message === FUTURE_BLOCK_ERROR || err.error.message === NULL_BLOCK_ERROR) {
return;
throw err;
}
}

Expand Down

0 comments on commit 0baafcd

Please sign in to comment.