From a66ce7445ecb074064b87ed6c0d12b5a291a0443 Mon Sep 17 00:00:00 2001 From: Suguru Inatomi Date: Sun, 24 Sep 2023 16:43:25 +0900 Subject: [PATCH] fix: set job duration --- src/worker.ts | 5 +++-- tsconfig.json | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/worker.ts b/src/worker.ts index f97e9ea..6a92a8f 100644 --- a/src/worker.ts +++ b/src/worker.ts @@ -95,15 +95,16 @@ export default { const sentry = initSentry(env.SENTRY_DSN, ctx); sentry.setContext('event', event); const checkInId = sentry.captureCheckIn({ monitorSlug: 'scheduled-feed2social', status: 'in_progress' }); + const now = Date.now(); ctx.waitUntil( execute(env, sentry) .then(() => { - sentry.captureCheckIn({ checkInId, monitorSlug: 'scheduled-feed2social', status: 'ok' }); + sentry.captureCheckIn({ checkInId, monitorSlug: 'scheduled-feed2social', status: 'ok', duration: Date.now() - now }); }) .catch((e) => { console.error(e); sentry.captureException(e); - sentry.captureCheckIn({ checkInId, monitorSlug: 'scheduled-feed2social', status: 'error' }); + sentry.captureCheckIn({ checkInId, monitorSlug: 'scheduled-feed2social', status: 'error', duration: Date.now() - now }); throw e; }), ); diff --git a/tsconfig.json b/tsconfig.json index 1c6e6bf..53ccc9b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,7 +1,7 @@ { "compilerOptions": { "target": "es2021", - "lib": ["es2021"], + "lib": ["es2021", "dom"], "module": "es2022", "moduleResolution": "node", "types": ["@cloudflare/workers-types", "vitest/importMeta"],