-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
feat(python): Improve crons docs, add upserts #9597
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Bundle ReportChanges will decrease total bundle size by 6 bytes ⬇️
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure about a few things.
## Check-Ins | ||
|
||
Check-in monitoring allows you to track a job's progress by capturing two check-ins: one at the start of your job and another at the end of your job. This two-step process allows Sentry to notify you if your job didn't start when expected (missed) or if it exceeded its maximum runtime (failed). | ||
|
||
If you use the `monitor` decorator/context manager, the SDK will create check-ins for the wrapped code automatically. | ||
|
||
```python | ||
from sentry_sdk.crons import capture_checkin | ||
from sentry_sdk.crons.consts import MonitorStatus | ||
|
||
check_in_id = capture_checkin( | ||
monitor_slug='<monitor-slug>', | ||
status=MonitorStatus.IN_PROGRESS, | ||
) | ||
|
||
# Execute your task here... | ||
|
||
capture_checkin( | ||
monitor_slug='<monitor-slug>', | ||
check_in_id=check_in_id, | ||
status=MonitorStatus.OK, | ||
) | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why this section is here. Maybe call it "Manual check-ins" and move it below the "Upserting Cron Monitors"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just copied the structure from https://docs.sentry.io/platforms/node/crons/ and https://docs.sentry.io/platforms/php/crons/ essentially. But agree this would be better below and renamed. Will do.
) | ||
``` | ||
|
||
## Upserting Cron Monitors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would avoid the word "upsert" and rather call this section: "Adding cron monitor configuration options" or something like this. (and later in the text mention that when you add the monitor_config and no monitor is existing it is created.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed to Configuring Cron Monitors
and added a sentence: If the monitor doesn't exist in Sentry yet, it will be created.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks for adding!
Not released yet -- will merge as soon as there is a release out there with upsert support. |
Pre-merge checklist
If you work at Sentry, you're able to merge your own PR without review, but please don't unless there's a good reason.
Description of changes
With getsentry/sentry-python#2929 we'll be adding cron upserts to the Python SDK.
Also documenting manual check-ins which were missing.
Direct link to preview: https://sentry-docs-git-ivana-python-cron-upsert.sentry.dev/platforms/python/crons/
Extra resources