Skip to content

Commit

Permalink
fix: set job duration
Browse files Browse the repository at this point in the history
  • Loading branch information
lacolaco committed Sep 24, 2023
1 parent c135069 commit a66ce74
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}),
);
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"compilerOptions": {
"target": "es2021",
"lib": ["es2021"],
"lib": ["es2021", "dom"],
"module": "es2022",
"moduleResolution": "node",
"types": ["@cloudflare/workers-types", "vitest/importMeta"],
Expand Down

0 comments on commit a66ce74

Please sign in to comment.