Skip to content

Conversation

@timfish
Copy link
Collaborator

@timfish timfish commented Jan 6, 2024

Closes #9893

This PR adds auto instrumented check-ins for the node-schedule library.

It's not shown in the readme, but scheduleJob can be passed a job name as the first parameter:
https://github.com/node-schedule/node-schedule/blob/c5a4d9a0dbcd5bda4996e089817e5669b5acd95f/lib/schedule.js#L28

import * as Sentry from '@sentry/node';
import * as schedule from 'node-schedule';

const scheduleWithCheckIn = Sentry.cron.instrumentNodeSchedule(schedule);

const job = scheduleWithCheckIn.scheduleJob('my-cron-job', '* * * * *', () => {
  console.log('You will see this message every minute');
});

This PR also adds a check to the cron instrumentation that ensures that you can't create multiple schedules with the same monitor slug.

@timfish timfish force-pushed the feat/node-schedule branch from 1d46469 to 6d1001b Compare January 6, 2024 12:43
@timfish timfish marked this pull request as draft January 6, 2024 12:59
@timfish timfish marked this pull request as ready for review January 7, 2024 00:00
@AbhiPrasad AbhiPrasad merged commit 4745454 into getsentry:develop Jan 8, 2024
@timfish timfish deleted the feat/node-schedule branch January 10, 2024 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Instrumentation for node-schedule library

2 participants