From c3e0a3004e63a6410d307cd2b5ebbecc30dacf42 Mon Sep 17 00:00:00 2001 From: chanyeong Date: Mon, 2 Sep 2024 20:36:57 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20time=20logging=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/kafka/kafka.service.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/kafka/kafka.service.ts b/src/kafka/kafka.service.ts index cbc17d5..a024e2b 100644 --- a/src/kafka/kafka.service.ts +++ b/src/kafka/kafka.service.ts @@ -1,9 +1,4 @@ -import { - Injectable, - OnModuleInit, - OnModuleDestroy, - InternalServerErrorException, -} from '@nestjs/common'; +import { Injectable, OnModuleInit, OnModuleDestroy } from '@nestjs/common'; import { Kafka, EachMessagePayload, Consumer } from 'kafkajs'; import { PuppeteerService } from '../puppeteer/puppeteer.service'; import { MinioClientService } from '../minio/minio-client.service'; @@ -42,6 +37,7 @@ export class KafkaService implements OnModuleInit, OnModuleDestroy { .run({ autoCommit: false, eachMessage: async (payload: EachMessagePayload) => { + const start = Date.now(); const { topic, partition, message } = payload; console.info( `partition: ${partition}, messageOffset: ${message.offset}`, @@ -63,6 +59,8 @@ export class KafkaService implements OnModuleInit, OnModuleDestroy { offset: (BigInt(message.offset) + BigInt(1)).toString(), }, ]); + const end = Date.now(); + console.info(`it took ${end - start} ms to upload!`); }, }) .catch((e) => console.error(`[example/consumer] ${e.message}`, e));