From 5dbe45de7f5c1c1b9cc8dbea9b7626da1507b61c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Uro=C5=A1=20Marolt?= Date: Sun, 12 Jan 2025 10:37:00 +0100 Subject: [PATCH] statistics logging --- services/libs/queue/src/vendors/kafka/client.ts | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/services/libs/queue/src/vendors/kafka/client.ts b/services/libs/queue/src/vendors/kafka/client.ts index 5fadc3b8f..80fd8c76e 100644 --- a/services/libs/queue/src/vendors/kafka/client.ts +++ b/services/libs/queue/src/vendors/kafka/client.ts @@ -364,17 +364,15 @@ export class KafkaQueueService extends LoggerBase implements IQueue { const durations = [...timings] timings = [] + // Get the number of messages left in the queue + const count = await this.getQueueMessageCount(queueConf) + + let message = `Topic has ${count} messages left!` if (durations.length > 0) { const average = durations.reduce((a, b) => a + b, 0) / durations.length - this.log.info( - { topic: queueConf.name }, - `In the last minute ${durations.length} messages were processed - average processing time: ${average.toFixed(2)}ms!`, - ) + message += ` In the last minute ${durations.length} messages were processed - average processing time: ${average.toFixed(2)}ms!` } - - // Get the number of messages left in the queue - const count = await this.getQueueMessageCount(queueConf) - this.log.info({ topic: queueConf.name }, `Topic has ${count} messages left!`) + this.log.info({ topic: queueConf.name }, message) } catch (err) { // do nothing }