node-cron Integration

Automatically monitor your node-cron scheduled jobs with zero configuration changes.

Use Sentry.cron.instrumentNodeCron to instrument the cron export from the node-cron library. This returns an object with the same API as the original cron export, but with the schedule method instrumented. You can pass the name of the cron monitor and an optional time zone as part of the third options argument to the function.

Requires SDK version 7.92.0 or higher.

Copied
import * as Sentry from "@sentry/node";
import cron from "node-cron";

const cronWithCheckIn = Sentry.cron.instrumentNodeCron(cron);

cronWithCheckIn.schedule(
  "* * * * *",
  () => {
    console.log("running a task every minute");
  },
  { name: "my-cron-job" },
);
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").