Skip to content

Commit f6c5733

Browse files
committed
refactor: improve execution time logging in StartNodeProcessor
1 parent 0d1128c commit f6c5733

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/queue/_nodes/processors/start-node.processor.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { EventEmitter2 } from '@nestjs/event-emitter';
55
import { CommandBus, QueryBus } from '@nestjs/cqrs';
66
import { Logger } from '@nestjs/common';
77

8+
import { formatExecutionTime, getTime } from '@common/utils/get-elapsed-time';
89
import { AxiosService } from '@common/axios/axios.service';
910
import { EVENTS } from '@libs/contracts/constants';
1011

@@ -109,21 +110,21 @@ export class StartNodeProcessor extends WorkerHost {
109110
return;
110111
}
111112

112-
const startTime = Date.now();
113+
const startTime = getTime();
113114
const config = await this.queryBus.execute(
114115
new GetPreparedConfigWithUsersQuery(
115116
nodeEntity.activeConfigProfileUuid,
116117
nodeEntity.activeInbounds,
117118
),
118119
);
119120

120-
this.logger.log(`Generated config for node in ${Date.now() - startTime}ms`);
121+
this.logger.log(`Generated config for node in ${formatExecutionTime(startTime)}`);
121122

122123
if (!config.isOk || !config.response) {
123124
throw new Error('Failed to get config for node');
124125
}
125126

126-
const reqStartTime = Date.now();
127+
const reqStartTime = getTime();
127128

128129
const res = await this.axios.startXray(
129130
config.response.config as unknown as Record<string, unknown>,
@@ -132,7 +133,7 @@ export class StartNodeProcessor extends WorkerHost {
132133
nodeEntity.port,
133134
);
134135

135-
this.logger.log(`Started node in ${Date.now() - reqStartTime}ms`);
136+
this.logger.log(`Started node in ${formatExecutionTime(reqStartTime)}`);
136137

137138
if (!res.isOk || !res.response) {
138139
await this.commandBus.execute(

0 commit comments

Comments
 (0)