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

Scheduled task monitoring #628

Closed
Tracked by #43660
stayallive opened this issue Dec 23, 2022 · 5 comments · Fixed by #659
Closed
Tracked by #43660

Scheduled task monitoring #628

stayallive opened this issue Dec 23, 2022 · 5 comments · Fixed by #659
Assignees

Comments

@stayallive
Copy link
Collaborator

Sentry has a (in beta since forever) CRON monitoring: https://docs.sentry.io/product/crons/.

It would be really sweet if we can somehow automatically set that up for the user based on their scheduled tasks (basically CRONs): https://laravel.com/docs/9.x/scheduling#defining-schedules.

I'm imagining this requires some sort of synchronize command to be run to talk with Sentry and create the correct CRONs on the Sentry server so depending on how this actually works this might be very easy or tricky or out of scope for the SDK. Will require some investigation but it's an interesting idea!

As requested by @ankurk91: #625 (comment).

@ankurk91
Copy link
Contributor

ankurk91 commented Dec 29, 2022

@cleptric
Copy link
Member

cleptric commented Jan 6, 2023

Leaving a link here to a package someone created for the Cron Monitoring feature.

https://github.com/modernmcguire/sentry-cron-monitoring-laravel

@modernben
Copy link

modernben commented Jan 6, 2023

Thanks @cleptric! Author of that ^ package here. Feel free to borrow as much of the code as you'd like.

My option is definitely more of an opt-in as it requires the user to add a method to each of their schedules.

I also played with the idea of a Trait on the job itself with a protected $monitor_id property. I decided against it because I would have to add that to Jobs and Commands and it also wouldn't work for closure based jobs.

Final note if you did want it to be automatic you could use the Events that are fired before/after jobs as referenced in the initial ask by @stayallive. The hard part would be somehow figuring out the monitor id situation. Maybe use the job name as the unique identifier instead of the monitor id? Not sure if that's a good option as you would have to do a text based lookup on your side then. Sounds expensive to me.

Let me know if you have any questions or want to bounce some ideas back and forth.

Thanks!
Ben

@cleptric
Copy link
Member

cleptric commented Jan 6, 2023

Your approach is a valid starting point. Some sort of auto-setup would be nice, but we have to answer a few open questions on the product first.

@denisdulici
Copy link

We currently use the ThenPingMe service and would like to switch to Sentry. They've created the following package for auto-setup:

https://github.com/thenpingme/thenpingme-laravel

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

Successfully merging a pull request may close this issue.

5 participants