Skip to content

Cron: Add support for parsing Luxon zones #13820

Open

Description

@SerenModz21

Problem Statement

The cron package uses Luxon for time zones. This allows us to specify system to use the system timezone for example. Information about this can be found here: https://github.com/moment/luxon/blob/master/docs/zones.md#specifying-a-zone

However, the problem that currently stands is that these zones aren't supported and thus cause Sentry to show an invalid monitor configuration error for new cron jobs.

luxon-zones

Solution Brainstorm

I believe that Sentry should parse Luxon zones in the automatic cron instrumentation, before sending them to the API. While I do mention providing system (which is also the default if not provided), It's still a limitation to what can be provided. I have included a link to the documentation along with an image for such.

Activity

  1. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Sep 27, 2024
  2. chargome commented on Sep 27, 2024

    @chargome
    Member

    Hi @SerenModz21! Could you provide a code snippet for an invalid configuration?

  3. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Sep 27, 2024
  4. SerenModz21 commented on Sep 27, 2024

    @SerenModz21
    Author

    Hi @chargome,

    Here is the JSON that the Sentry UI shows when hovering over check-in (I have just added the double quotes so that it would be valid JSON):

    {
      "check_in_id": "2d5df2bbab174379a7766da9bb009110",
      "contexts": {
        "trace": {
          "trace_id": "c4efe303546241a2bbba5018c036f97b"
        }
      },
      "environment": "production",
      "monitor_config": {
        "schedule": {
          "type": "crontab",
          "value": "0 */3 * * *"
        },
        "timezone": "system"
      },
      "monitor_slug": "update-leveling",
      "status": "in_progress"
    }

    As for code, I make use of classes and TypeScript decorators to work with my codebase. However, if I had to compact it all down to be minimal and to show it here, this is what it would be:

    import { CronJob } from "cron";
    
    const cronJob = sentry.cron.instrumentCron(CronJob, "update-leveling");
    
    cronjob.from({
      cronTime: "0 */3 * * *",
      onTick: () => { /* code that gets executed */ },
      timeZone: "system"
    });

    The cron jobs themselves work fine and cron jobs that I had existing before explicitly setting the timezone to system also get monitored as expected. This is why I know that it's not a problem with my code but rather Sentry not parsing the Luxon zone and getting the TZ/IANA timezone from it.

    Lastly, I know omitting the timezone or providing a TZ/IANA timezone will resolve the issue. I believe Sentry should still support parsing Luxon's zones.

  5. moved this to Waiting for: Product Owner in GitHub Issues with 👀 3on Sep 27, 2024
  6. chargome commented on Sep 27, 2024

    @chargome
    Member

    @SerenModz21 got it, I'll raise this in the team (but tbh I'm not sure if we'll add Luxon support here). Meanwhile you'll need to parse it yourself and provide the TZ timezone for the config.

  7. moved this from Waiting for: Product Owner to No status in GitHub Issues with 👀 3on Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions