Skip to content

Commit

Permalink
feat: time logging 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
jcy0308 committed Sep 2, 2024
1 parent 0d155a7 commit c3e0a30
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/kafka/kafka.service.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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}`,
Expand All @@ -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));
Expand Down

0 comments on commit c3e0a30

Please sign in to comment.