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

Try harder to generate a slug for a cron monitor #977

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

stayallive
Copy link
Collaborator

Feedback from Laracon EU: We should have enough data to generate a slug for a scheduled job cron. So this PR tries a bit harder to generate something meaningful.

For job classes we reverse it to get the most interesting part of the name (the actual class name) in the front.

Also added a limit on our side to prevent jobs being not accepted (correctly) by sentry if the slug needs to be truncated. Current limit is 128.

@@ -266,7 +266,7 @@ private function createCheckIn(string $slug, CheckInStatus $status, ?string $id
$options = SentrySdk::getCurrentHub()->getClient()->getOptions();

return new CheckIn(
$slug,
Str::limit($slug, 128, ''),

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about raising an exception here, if the $slug is > 128 characters and cut of the string only, if the slug is autogenerated from a class (in makeSlugForScheduled)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could. But that would make the code a lot more complex (to keep track where the name came from). I'm not sure there is much benefit to this. Especially since there is a very high chance the truncated string is still unique enough unless you are actively trying to break this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants