mirror of
https://github.com/Sendouc/sendou.ink.git
synced 2026-08-28 14:18:04 -05:00
Log Routines as spans
This commit is contained in:
@@ -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`,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user