Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(node): Instrumentation for node-schedule library #10086

Merged
merged 2 commits into from
Jan 8, 2024

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 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
55 checks passed
@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