getsentry / getsentry/sentry

Cron Monitor Never Goes into "Timed Out" State / Stuck In Progress - Testing with time.sleep

Open
#103,632 9 comments 0 reactions 0 assignees View on GitHub
Bug Crons Product Area: Crons python
Dominant language
Python
Stars
44.8k
Forks
4.9k
Avg merge
22h 21m
Merged PRs (30d)
586

Description

### How do you use Sentry?

Self-hosted/on-premise

### Version

2.44.0

### Steps to Reproduce

In Self Hosted Sentry 24.8.0. We have the following test cron monitor. It works fine for "ok" check-ins and failures, but when adding a time.sleep function in order to test Sentry's "Timed Out" state it never reaches it. It always continues to be in the "In Progress" state. We don't know why.

We set runtime in both UI and on client side in config

We have some production cron monitors running and experiencing the same thing, they continue to be in progress state rather than in time out state.

Image

Image

```
import time

import sentry_sdk
from sentry_sdk.crons import monitor

monitor_config = {
"schedule": {"type": "crontab", "value": "*/5 * * *"},
"timezone": "America/Chicago",
# If an expected check-in doesn't come in `checkin_margin`
# minutes, it'll be considered missed
"checkin_margin": 1,
# The check-in is allowed to run for `max_runtime` minutes
# before it's considered failed
"max_runtime": 1,
# It'll take `failure_issue_threshold` consecutive failed
# check-ins to create an issue
"failure_issue_threshold": 1,
# It'll take `recovery_threshold` OK check-ins to resolve
# an issue
"recovery_threshold": 1,
}

@monitor(monitor_slug="test-monitor", monitor_config=monitor_config)
def main():
print("Start")
time.sleep(10 * 60)
print("Finish")

if __name__ == "__main__":
sentry_sdk.init(debug=True)
main()
```

[sentry-debug.log](https://github.com/user-attachments/files/23609635/sentry-debug.log)

[sentry-debug_2.log](https://github.com/user-attachments/files/23609639/sentry-debug_2.log)

### Expected Result

We see the function to report as "Timed out " when max run time is reached. Which we set in both UI and on client side in config

### Actual Result

If we leave the function running in sleep.. it is stuck in progress state rather than timing out.

Image

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with the provided Python Sentry cron monitor and its one-minute check-in margin and maximum runtime. Trace the cron monitor timeout handling using the supplied debug logs, then verify that a sleeping monitor transitions from In Progress to Timed Out after the configured runtime.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
observability
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.