Skip to content

Cron: Add support for parsing Luxon zones #13820

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

Open
SerenModz21 opened this issue Sep 27, 2024 · 3 comments
Open

Cron: Add support for parsing Luxon zones #13820

SerenModz21 opened this issue Sep 27, 2024 · 3 comments

Comments

@SerenModz21
Copy link

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.

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Sep 27, 2024
@chargome
Copy link
Member

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

@SerenModz21
Copy link
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.

@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Sep 27, 2024
@chargome
Copy link
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: No status
Development

No branches or pull requests

4 participants