mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-05-23 11:57:50 -05:00
Log Routines as spans
This commit is contained in:
parent
2a6c276431
commit
a4ab792896
|
|
@ -1,3 +1,4 @@
|
|||
import * as Sentry from "@sentry/react-router";
|
||||
import { logger } from "../utils/logger";
|
||||
|
||||
export class Routine {
|
||||
|
|
@ -17,14 +18,25 @@ export class Routine {
|
|||
|
||||
async run() {
|
||||
logger.info(`Running routine: ${this.name}`);
|
||||
const startTime = performance.now();
|
||||
try {
|
||||
await this.func();
|
||||
} catch (error) {
|
||||
logger.error(`Error running routine ${this.name}: ${error}`);
|
||||
return;
|
||||
}
|
||||
const endTime = performance.now();
|
||||
logger.info(`Routine ${this.name} completed in ${endTime - startTime}ms`);
|
||||
await Sentry.startSpan(
|
||||
{
|
||||
name: this.name,
|
||||
op: "cron",
|
||||
},
|
||||
async () => {
|
||||
const startTime = performance.now();
|
||||
try {
|
||||
await this.func();
|
||||
} catch (error) {
|
||||
logger.error(`Error running routine ${this.name}: ${error}`);
|
||||
Sentry.captureException(error);
|
||||
return;
|
||||
}
|
||||
const endTime = performance.now();
|
||||
logger.info(
|
||||
`Routine ${this.name} completed in ${endTime - startTime}ms`,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user