print warning when activity processing exceeds 10 seonds

This commit is contained in:
Hazelnoot 2024-11-18 01:24:23 -05:00
parent e35e92beb9
commit 871c63b48b

View file

@ -105,6 +105,9 @@ export class InboxProcessorService implements OnApplicationShutdown {
// Truncate nanoseconds to microseconds, then scale to milliseconds. // Truncate nanoseconds to microseconds, then scale to milliseconds.
// 123,456,789 ns -> 123,456 us -> 123.456 ms // 123,456,789 ns -> 123,456 us -> 123.456 ms
const duration = Number((endTime - startTime) / 1000n) / 1000; const duration = Number((endTime - startTime) / 1000n) / 1000;
if (duration > 10000) {
this.logger.warn(`Activity ${JSON.stringify(payload.id)} by "${keyId}" took ${(duration / 1000).toFixed(1)} seconds to complete`);
}
log.accepted = result.startsWith('ok'); log.accepted = result.startsWith('ok');
log.duration = duration; log.duration = duration;