diff options
| author | Hazelnoot <acomputerdog@gmail.com> | 2024-11-18 01:18:45 -0500 |
|---|---|---|
| committer | Hazelnoot <acomputerdog@gmail.com> | 2025-02-16 19:25:04 -0500 |
| commit | e35e92beb9ccdabf5692107966c2cf9c2e91c4dd (patch) | |
| tree | cfb65d4aeb9b8fe53f6573fbf21e485600341528 /packages/backend/src/queue | |
| parent | add missing constraint names to `SkActivityLog` and `SkActivityContext` (diff) | |
| download | sharkey-e35e92beb9ccdabf5692107966c2cf9c2e91c4dd.tar.gz sharkey-e35e92beb9ccdabf5692107966c2cf9c2e91c4dd.tar.bz2 sharkey-e35e92beb9ccdabf5692107966c2cf9c2e91c4dd.zip | |
log inbound activity duration
Diffstat (limited to 'packages/backend/src/queue')
| -rw-r--r-- | packages/backend/src/queue/processors/InboxProcessorService.ts | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/packages/backend/src/queue/processors/InboxProcessorService.ts b/packages/backend/src/queue/processors/InboxProcessorService.ts index d40104ee9b..242c67359b 100644 --- a/packages/backend/src/queue/processors/InboxProcessorService.ts +++ b/packages/backend/src/queue/processors/InboxProcessorService.ts @@ -98,9 +98,16 @@ export class InboxProcessorService implements OnApplicationShutdown { } try { + const startTime = process.hrtime.bigint(); const result = await this._process(job, log); + const endTime = process.hrtime.bigint(); + + // Truncate nanoseconds to microseconds, then scale to milliseconds. + // 123,456,789 ns -> 123,456 us -> 123.456 ms + const duration = Number((endTime - startTime) / 1000n) / 1000; log.accepted = result.startsWith('ok'); + log.duration = duration; log.result = result; return result; @@ -249,7 +256,7 @@ export class InboxProcessorService implements OnApplicationShutdown { delete activity.id; } - // Attach log to verified user + // Record verified user in log if (log) { log.verified = true; log.authUser = authUser.user; @@ -361,7 +368,6 @@ export class InboxProcessorService implements OnApplicationShutdown { at: new Date(), verified: false, accepted: false, - result: 'not processed', activity, keyId, host, |