From b274f0ac38247f0126003c3b23201a9fd4e7ce1e Mon Sep 17 00:00:00 2001 From: Christopher-Li Date: Wed, 29 Nov 2023 17:39:31 -0500 Subject: [PATCH] Track lag for block time to ingestion time (#820) --- indexer/services/ender/src/lib/on-message.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/indexer/services/ender/src/lib/on-message.ts b/indexer/services/ender/src/lib/on-message.ts index 1c53defe55..eda6e31a4e 100644 --- a/indexer/services/ender/src/lib/on-message.ts +++ b/indexer/services/ender/src/lib/on-message.ts @@ -20,6 +20,7 @@ import { KafkaMessage, } from 'kafkajs'; import _ from 'lodash'; +import { DateTime } from 'luxon'; import { shouldSkipBlock, @@ -55,6 +56,11 @@ export async function onMessage(message: KafkaMessage): Promise { if (indexerTendermintBlock === undefined) { return; } + stats.timing( + `${config.SERVICE_NAME}.block_time_lag.timing`, + DateTime.now().diff(dateToDateTime(indexerTendermintBlock.time!)).toMillis(), + STATS_NO_SAMPLING, + ); const offset = message.offset; const blockHeight: string = indexerTendermintBlock.height.toString();