cron Library Integration
Automatically monitor your cron library scheduled jobs with seamless instrumentation.
Use Sentry.cron.instrumentCron
to instrument the CronJob
constructor or CronJob.from
method in the cron library. Pass the name of the cron monitor as a second argument to the function.
Requires SDK version 7.92.0
or higher.
Copied
import * as Sentry from "@sentry/node";
import { CronJob } from "cron";
const CronJobWithCheckIn = Sentry.cron.instrumentCron(
CronJob,
"my-cron-job",
);
// use the constructor
const job = new CronJobWithCheckIn("* * * * *", () => {
console.log("You will see this message every minute");
});
// or from method
const job = CronJobWithCheckIn.from({
cronTime: "* * * * *",
onTick: () => {
console.log("You will see this message every minute");
},
});
Was this helpful?
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").