Skip to content

Commit

Permalink
feat: instrument brovider full archive node availability
Browse files Browse the repository at this point in the history
  • Loading branch information
wa0x6e committed Jan 20, 2024
1 parent 8e22f9c commit dcab682
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions src/lib/metrics/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,16 @@ const providersTiming = new client.Gauge({
labelNames: ['network', 'status']
});

function refreshProviderTiming() {
const abi = ['function getEthBalance(address addr) view returns (uint256 balance)'];
const wallet = new Wallet(process.env.NFT_CLAIMER_PRIVATE_KEY as string);
const providersFullArchiveNodeAvailability = new client.Gauge({
name: 'provider_full_archive_node_availability',
help: 'Availability of full archive node for each provider',
labelNames: ['network']
});

const abi = ['function getEthBalance(address addr) view returns (uint256 balance)'];
const wallet = new Wallet(process.env.NFT_CLAIMER_PRIVATE_KEY as string);

function refreshProviderTiming() {
Object.values(networks).forEach(async network => {
const end = providersTiming.startTimer({ network: network.key });
let status = 0;
Expand All @@ -198,9 +204,24 @@ function refreshProviderTiming() {
});
}

function refreshFullArchiveNodeChecker() {
Object.values(networks).forEach(async network => {
const { key, start, multicall } = network;
try {
const provider = snapshot.utils.getProvider(key);

await provider.getBalance(multicall, start);
providersFullArchiveNodeAvailability.set({ network: key }, 1);
} catch (e: any) {
providersFullArchiveNodeAvailability.set({ network: key }, 0);
}
});
}

async function run() {
try {
refreshProviderTiming();
refreshFullArchiveNodeChecker();
} catch (e) {
capture(e);
} finally {
Expand Down

0 comments on commit dcab682

Please sign in to comment.