From 615cd2a60d6d67e101b2ed54240e124058dbad48 Mon Sep 17 00:00:00 2001 From: Marcello Date: Mon, 4 Nov 2024 14:11:40 +0100 Subject: [PATCH] add cf_block_weight (#79) --- src/metrics/chainflip/gaugeBlockWeight.ts | 12 +++++++----- src/watchers/chainflip.ts | 3 ++- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/metrics/chainflip/gaugeBlockWeight.ts b/src/metrics/chainflip/gaugeBlockWeight.ts index e09150c..1a1fda2 100644 --- a/src/metrics/chainflip/gaugeBlockWeight.ts +++ b/src/metrics/chainflip/gaugeBlockWeight.ts @@ -20,11 +20,13 @@ export const gaugeBlockWeight = async (context: Context): Promise => { logger.debug(`Scraping ${metricName}`); try { - const systemBlockWeights = await api.consts.system.blockWeights; - logger.debug(systemBlockWeights.toJSON()); - - const currentBlockWeight = await api.query.system.blockWeight(); - logger.debug(currentBlockWeight.toJSON()); + const currentBlockWeight = (await api.query.system.blockWeight()).toJSON(); + const totalWeight: number = + // eslint-disable-next-line @typescript-eslint/restrict-plus-operands + currentBlockWeight.mandatory.refTime + + currentBlockWeight.normal.refTime + + currentBlockWeight.operational.refTime; + metric.set(totalWeight); } catch (e) { logger.error(e); } diff --git a/src/watchers/chainflip.ts b/src/watchers/chainflip.ts index ff89026..6bd11b4 100644 --- a/src/watchers/chainflip.ts +++ b/src/watchers/chainflip.ts @@ -25,6 +25,7 @@ import { gaugeWitnessChainTracking, gaugeWitnessCount, gaugeSolanaNonces, + gaugeBlockWeight, } from '../metrics/chainflip'; import { ApiPromise, WsProvider } from '@polkadot/api'; import { customRpcs } from '../utils/customRpcSpecification'; @@ -90,7 +91,7 @@ async function startWatcher(context: Context) { gaugeBuildVersion(context); gaugeValidatorStatus(context); gaugeBtcUtxos(context); - // gaugeBlockWeight(context); + gaugeBlockWeight(context); gaugePendingRedemptions(context); gaugePendingBroadcast(context); gaugeTssRetryQueues(context);