Skip to content

Commit c878f07

Browse files
wedamijaclaude
andcommitted
fix(huey): Don't monitor periodic tasks with unsupported schedules
Match the Celery beat integration: skip periodic tasks whose schedule can't be expressed as a Sentry Crons monitor config instead of sending check-ins without one. Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 191a0c7 commit c878f07

2 files changed

Lines changed: 25 additions & 13 deletions

File tree

‎sentry_sdk/integrations/huey.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,10 +286,11 @@ def _monitor_periodic_task(
286286
monitor_config = _get_monitor_config(huey, task)
287287
if monitor_config is None:
288288
logger.debug(
289-
"Huey periodic task %r can't be expressed as a Sentry Crons "
290-
"schedule. Sending check-ins without a monitor config.",
289+
"Not monitoring Huey periodic task %r: its schedule can't be "
290+
"expressed as a Sentry Crons schedule.",
291291
task.name,
292292
)
293+
return execute
293294

294295
@wraps(execute)
295296
def _sentry_monitored_execute(*args: "Any", **kwargs: "Any") -> "Any":

‎tests/integrations/huey/test_huey_crons.py‎

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -145,23 +145,34 @@ def report():
145145
assert {c["monitor_slug"] for c in _check_ins(envelopes)} == {"report"}
146146

147147

148-
def test_periodic_task_without_config(sentry_init, capture_envelopes):
148+
def _every_minute(timestamp):
149+
return True
150+
151+
152+
@pytest.mark.parametrize(
153+
"utc, validate_datetime",
154+
[
155+
(True, _every_minute),
156+
(True, crontab(minute="0", hour="0", day="1", day_of_week="1")),
157+
(False, crontab()),
158+
],
159+
)
160+
def test_unsupported_schedule_not_monitored(
161+
sentry_init, capture_envelopes, utc, validate_datetime
162+
):
149163
sentry_init(integrations=[HueyIntegration(monitor_periodic_tasks=True)])
150164
envelopes = capture_envelopes()
151-
huey = MemoryHuey()
152-
153-
def every_minute(timestamp):
154-
return True
165+
huey = MemoryHuey(utc=utc)
166+
calls = []
155167

156-
@huey.periodic_task(every_minute)
168+
@huey.periodic_task(validate_datetime)
157169
def cleanup():
158-
pass
170+
calls.append(1)
159171

160-
_run_periodic_tasks(huey)
172+
_run_periodic_tasks(huey, timestamp=datetime(2026, 6, 1))
161173

162-
check_ins = _check_ins(envelopes)
163-
assert [c["status"] for c in check_ins] == ["in_progress", "ok"]
164-
assert all("monitor_config" not in c for c in check_ins)
174+
assert calls == [1]
175+
assert _check_ins(envelopes) == []
165176

166177

167178
def _config(huey, validate_datetime):

0 commit comments

Comments
 (0)