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

Cron monitor slug truncates if Celerybeat periodic task name contains a 2nd ":" #77692

Open
peterfarrell opened this issue Aug 23, 2024 · 7 comments

Comments

@peterfarrell
Copy link

How do you use Sentry?

Sentry Saas (sentry.io)

Version

2.13.0

Steps to Reproduce

We are using the automatic Celerybeat integration. We are seeing odd slug names being generated by Sentry.

We have several periodic tasks that we have setup with names like:

  • "Office: Send Daily Reminder Email (8:00 am)"
  • "Office: Send Daily Reminder Email (8:30 am)"
  • "Office: Send Daily Reminder Email (9:00 am)"
  • "Office: Send Daily Reminder Email (9:30 am)"

The slugs that get registered in Sentry are:

  • "Office: Send Daily Reminder Email (8:00 am)" -> office-send-daily-birthdayanniversary-email-8
  • "Office: Send Daily Reminder Email (8:30 am)" -> office-send-daily-birthdayanniversary-email-8
  • "Office: Send Daily Reminder Email (9:00 am)" -> office-send-daily-birthdayanniversary-email-9
  • "Office: Send Daily Reminder Email (9:30 am)" -> office-send-daily-birthdayanniversary-email-9

Initially, we thought that the slug name had an undisclosed maximum character length however we discovered that occurs if there is a 2nd : (colon) in the name and it truncates the slug after that.

This had led to some strange results in Cron Monitoring where 2 separate check-ins are made on a monitor configured for a single time:

Image

Expected Result

Expected unique slugs that did not truncate.

Actual Result

Two separate periodic tasks with unique names getting the same slug name due to the truncation.

@szokeasaurusrex
Copy link
Member

@peterfarrell, could you please share a minimal reproduction? I tried to reproduce your error with the code snippet provided below, but got the following monitor slug in Sentry, which was not truncated: office-send-daily-reminder-email-800-am.

In any case, this problem likely does not originate from the SDK, since the SDK appears to send Office: Send Daily Reminder Email (8:00 am) as the monitor slug. Likely, Relay or possibly the Sentry backend are converting the provided text to a valid monitor slug. Depending on what I find from the minimal reproduction you provide, I will transfer this issue to the appropriate repository.

As a workaround, I would suggest setting the task name to a valid monitor slug. Valid monitor slugs can include lowercase letters, numbers, dashes, and underscores. Setting the task name to a valid monitor slug is also probably generally a more robust solution.

@getsantry
Copy link
Contributor

getsantry bot commented Sep 17, 2024

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you remove the label Waiting for: Community, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

@peterfarrell
Copy link
Author

peterfarrell commented Sep 17, 2024

@szokeasaurusrex I can't repro the slug truncation in the SDK just as you found. It appears it's happening upstream which is impacting the auto-instrumentation with Celery Beat.

@sl0thentr0py
Copy link
Member

This is about the backend slugification logic so I will transfer this issue to the main sentry repo and tag the Crons team.

@sl0thentr0py sl0thentr0py transferred this issue from getsentry/sentry-python Sep 18, 2024
@getsantry
Copy link
Contributor

getsantry bot commented Sep 18, 2024

Assigning to @getsentry/support for routing ⏲️

@getsantry
Copy link
Contributor

getsantry bot commented Sep 18, 2024

Routing to @getsentry/product-owners-crons for triage ⏲️

@getsantry getsantry bot moved this from Waiting for: Support to Waiting for: Product Owner in GitHub Issues with 👀 3 Sep 18, 2024
@getsantry getsantry bot moved this to Waiting for: Product Owner in GitHub Issues with 👀 3 Sep 18, 2024
@wedamija
Copy link
Member

This seems easy enough to fix - we just need to fix the slug logic.

We'll need to have a backwards compatibility shim that uses the old logic and matches to a monitor that has that slug if it exists. We might be able to backfill too, but it's a little risky

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

5 participants