Skip to content

Instrumentation for node-cron library #9892

Closed

Description

@AbhiPrasad

Problem Statement

Auto-instrumentation for https://www.npmjs.com/package/node-cron that wraps cron.schedule calls in a Sentry cron monitor.

Solution Brainstorm

needs to be opt-in, so an integration that they can add.

Activity

  1. changed the title [-]Instrumentation for Node cron library[/-] [+]Instrumentation for node-cron library[/+] on Dec 18, 2023
  2. timfish commented on Dec 18, 2023

    @timfish
    Collaborator

    I guess Sentry does not support month/day names like node-cron does?

    For month and week day you also may use names or short names. e.g:

    var cron = require('node-cron');
    
    cron.schedule('* * * January,September Sunday', () => {
      console.log('running on Sundays of January and September');
    });

    Or with short names:

    var cron = require('node-cron');
    
    cron.schedule('* * * Jan,Sep Sun', () => {
      console.log('running on Sundays of January and September');
    });
  3. gaprl commented on Dec 18, 2023

    @gaprl

    I guess Sentry does not support month/day names like node-cron does?

    Hey @timfishk, correct, Crons only supports the crontab syntax. However, we could parse it in the front-end and send it like this to Sentry: * * * January,September Sunday becomes * * * 1,7 0 which would represent the same thing.

    Seems like they are already doing something similar here: src/convert-expression/index.js#L51-L62

  4. gaprl commented on Dec 18, 2023

    @gaprl

    Ideally we could automatically instrument all monitors by doing something like:

    import cron from 'node-cron';
    
    Sentry.withMonitorIntegration(cron);
    
    cron.schedule('* * * * *', () => {
      console.log('running a task every minute');
    });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions