getsentry / sentry-python

The official Python SDK for Sentry.io
https://sentry.io/for/python/
MIT License
1.88k stars 493 forks source link

Crons Celery: automatically clean up tasks that are no longer in use #3125

Closed gaprl closed 4 weeks ago

gaprl commented 4 months ago

Our Celery integration makes it easy to set up multiple monitors, sometimes more than 100 at once. However, if changes are made to these tasks that apply to all monitors simultaneously—for example, changing an environment name from prod to us — all monitors will start emitting "missed" errors.

Ideally, our Celery integration would track these changes and automatically clean up any old environments or monitors for tasks that no longer exist.

evanpurkhiser commented 4 months ago

Ideally, our Celery integration would track these changes and automatically clean up any old environments or monitors for tasks that no longer exist.

This is probably not going to happen since the SDKs do not maintain state.

szokeasaurusrex commented 4 months ago

This is probably not going to happen since the SDKs do not maintain state.

I believe @evanpurkhiser is correct here: the SDK would need to have a list of the currently running cron jobs that are being monitored to implement this change, but we don't have such a list as far as I know. My understanding is that we emit checkins (including monitor upserts) as cron jobs are run, without storing any information about them in the SDK

gaprl commented 4 months ago

This is probably not going to happen since the SDKs do not maintain state.

I believe @evanpurkhiser is correct here: the SDK would need to have a list of the currently running cron jobs that are being monitored to implement this change, but we don't have such a list as far as I know. My understanding is that we emit checkins (including monitor upserts) as cron jobs are run, without storing any information about them in the SDK

Right, I realize this is tricky. Any ideas how we can make this easier? We've had this scenario come up a couple of times, not only from us internally, but from customers as well. Is a UI-based bulk management solution the best way forward?

antonpirker commented 4 months ago

Yes, a solution in the UI is the only way. The SDK does now know about config changes and I also think we should not implement something like this.

szokeasaurusrex commented 4 weeks ago

@gaprl @antonpirker gonna close this issue for now, since as @antonpirker mentioned in his previous comment, there is not really any way we can do this in the SDK