Skip to content

Commit

Permalink
statistics logging
Browse files Browse the repository at this point in the history
  • Loading branch information
themarolt committed Jan 12, 2025
1 parent 48a2a72 commit 5dbe45d
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions services/libs/queue/src/vendors/kafka/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 5dbe45d

Please sign in to comment.