diff --git a/indexer/services/ender/__tests__/lib/on-message.test.ts b/indexer/services/ender/__tests__/lib/on-message.test.ts index 9b5766006d..58aef89a4a 100644 --- a/indexer/services/ender/__tests__/lib/on-message.test.ts +++ b/indexer/services/ender/__tests__/lib/on-message.test.ts @@ -761,7 +761,7 @@ describe('on-message', () => { expect(stats.increment).toHaveBeenCalledWith(`${config.SERVICE_NAME}.block_already_parsed`, 1); expect(stats.increment).toHaveBeenCalledWith('ender.received_kafka_message', 1); - expect(stats.timing).toHaveBeenCalledWith( + expect(stats.timing).not.toHaveBeenCalledWith( 'ender.message_time_in_queue', expect.any(Number), 1, { topic: KafkaTopics.TO_ENDER }); }); diff --git a/indexer/services/ender/src/lib/on-message.ts b/indexer/services/ender/src/lib/on-message.ts index c33be095d7..4187b6aead 100644 --- a/indexer/services/ender/src/lib/on-message.ts +++ b/indexer/services/ender/src/lib/on-message.ts @@ -49,7 +49,6 @@ export async function onMessage(message: KafkaMessage): Promise { const start: number = Date.now(); const indexerTendermintBlock: IndexerTendermintBlock | undefined = getIndexerTendermintBlock( message, - start, ); if (indexerTendermintBlock === undefined) { return; @@ -66,6 +65,15 @@ export async function onMessage(message: KafkaMessage): Promise { return; } + stats.timing( + `${config.SERVICE_NAME}.message_time_in_queue`, + start - Number(message.timestamp), + STATS_NO_SAMPLING, + { + topic: KafkaTopics.TO_ENDER, + }, + ); + let success: boolean = false; const txId: number = await Transaction.start(); await Transaction.setIsolationLevel(txId, IsolationLevel.READ_UNCOMMITTED); @@ -141,7 +149,6 @@ export async function onMessage(message: KafkaMessage): Promise { */ function getIndexerTendermintBlock( message: KafkaMessage, - start: number, ): IndexerTendermintBlock | undefined { if (!message || !message.value || !message.timestamp) { stats.increment(`${config.SERVICE_NAME}.empty_kafka_message`, 1); @@ -151,15 +158,6 @@ function getIndexerTendermintBlock( }); return undefined; } - - stats.timing( - `${config.SERVICE_NAME}.message_time_in_queue`, - start - Number(message.timestamp), - STATS_NO_SAMPLING, - { - topic: KafkaTopics.TO_ENDER, - }, - ); try { const messageValueBinary: Uint8Array = new Uint8Array(message.value); logger.info({