[Blockchain Watcher] (METRICS) Map block high diff metric (#1397)

* Map block high diff metric

* Map block high diff metric

---------

Co-authored-by: julian merlo <julianmerlo@julians-MacBook-Pro.local>
This commit is contained in:
Julian 2024-05-07 17:14:45 -03:00 committed by GitHub
parent b8e3f43333
commit c3950c4fb9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 66 additions and 11 deletions

View File

@ -112,7 +112,7 @@
},
"sui": {
"network": "mainnet",
"rpcs": ["https://fullnode.mainnet.sui.io:443", "http://m-sui-01.nodes.stable.io:8546"]
"rpcs": ["https://fullnode.mainnet.sui.io:443"]
},
"aptos": {
"network": "mainnet",

View File

@ -91,15 +91,26 @@ export class PollAptos extends RunPollingJob {
chain: "aptos",
commitment: this.cfg.getCommitment(),
};
const lastFrom = this.lastFrom ?? 0n;
const previousFrom = this.previousFrom ?? 0n;
const diffCursor = BigInt(lastFrom) - BigInt(previousFrom);
this.statsRepo.count("job_execution", labels);
this.statsRepo.measure("polling_cursor", this.lastFrom ?? 0n, {
this.statsRepo.measure("polling_cursor", lastFrom, {
...labels,
type: "max",
});
this.statsRepo.measure("polling_cursor", this.previousFrom ?? 0n, {
this.statsRepo.measure("polling_cursor", previousFrom, {
...labels,
type: "current",
});
this.statsRepo.measure("polling_cursor", diffCursor, {
...labels,
type: "diff",
});
}
}

View File

@ -129,15 +129,26 @@ export class PollEvm extends RunPollingJob {
chain: this.cfg.chain ?? "",
commitment: this.cfg.getCommitment(),
};
const latestBlockHeight = this.latestBlockHeight ?? 0n;
const blockHeightCursor = this.blockHeightCursor ?? 0n;
const diffCursor = BigInt(latestBlockHeight) - BigInt(blockHeightCursor);
this.statsRepo.count("job_execution", labels);
this.statsRepo.measure("polling_cursor", this.latestBlockHeight ?? 0n, {
this.statsRepo.measure("polling_cursor", latestBlockHeight, {
...labels,
type: "max",
});
this.statsRepo.measure("polling_cursor", this.blockHeightCursor ?? 0n, {
this.statsRepo.measure("polling_cursor", blockHeightCursor, {
...labels,
type: "current",
});
this.statsRepo.measure("polling_cursor", diffCursor, {
...labels,
type: "diff",
});
}
}

View File

@ -134,15 +134,26 @@ export class PollSolanaTransactions extends RunPollingJob {
chain: "solana",
commitment: this.cfg.commitment,
};
const latestSlot = BigInt(this.latestSlot ?? 0);
const slotCursor = BigInt(this.slotCursor ?? 0);
const diffCursor = latestSlot - slotCursor;
this.statsRepo.count("job_execution", labels);
this.statsRepo.measure("polling_cursor", BigInt(this.latestSlot ?? 0), {
this.statsRepo.measure("polling_cursor", latestSlot, {
...labels,
type: "max",
});
this.statsRepo.measure("polling_cursor", BigInt(this.slotCursor ?? 0n), {
this.statsRepo.measure("polling_cursor", slotCursor, {
...labels,
type: "current",
});
this.statsRepo.measure("polling_cursor", BigInt(diffCursor), {
...labels,
type: "diff",
});
}
/**

View File

@ -110,15 +110,26 @@ export class PollSuiTransactions extends RunPollingJob {
chain: "sui",
commitment: "immediate",
};
const checkpoint = BigInt(this.cursor?.checkpoint ?? 0);
const currentCheckpoint = BigInt(this.currentCheckpoint ?? 0);
const diffCursor = checkpoint - currentCheckpoint;
this.statsRepo.count("job_execution", labels);
this.statsRepo.measure("polling_cursor", BigInt(this.cursor?.checkpoint ?? 0), {
this.statsRepo.measure("polling_cursor", checkpoint, {
...labels,
type: "max",
});
this.statsRepo.measure("polling_cursor", BigInt(this.currentCheckpoint ?? 0n), {
this.statsRepo.measure("polling_cursor", currentCheckpoint, {
...labels,
type: "current",
});
this.statsRepo.measure("polling_cursor", BigInt(diffCursor), {
...labels,
type: "diff",
});
}
}

View File

@ -114,15 +114,26 @@ export class PollWormchain extends RunPollingJob {
chain: this.cfg.chain ?? "",
commitment: this.cfg.getCommitment(),
};
const latestBlockHeight = this.latestBlockHeight ?? 0n;
const blockHeightCursor = this.blockHeightCursor ?? 0n;
const diffCursor = latestBlockHeight - blockHeightCursor;
this.statsRepo.count("job_execution", labels);
this.statsRepo.measure("polling_cursor", this.latestBlockHeight ?? 0n, {
this.statsRepo.measure("polling_cursor", latestBlockHeight, {
...labels,
type: "max",
});
this.statsRepo.measure("polling_cursor", this.blockHeightCursor ?? 0n, {
this.statsRepo.measure("polling_cursor", blockHeightCursor, {
...labels,
type: "current",
});
this.statsRepo.measure("polling_cursor", diffCursor, {
...labels,
type: "diff",
});
}
}