Skip to content

Commit 659af46

Browse files
feat(crons): Remove legacy celery based tasks (#70288)
1 parent c80a36b commit 659af46

File tree

9 files changed

+16
-1331
lines changed

9 files changed

+16
-1331
lines changed

src/sentry/conf/server.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -731,8 +731,6 @@ def SOCIAL_AUTH_DEFAULT_USERNAME() -> str:
731731
"sentry.snuba.tasks",
732732
"sentry.replays.tasks",
733733
"sentry.monitors.tasks.clock_pulse",
734-
"sentry.monitors.tasks.check_missed",
735-
"sentry.monitors.tasks.check_timeout",
736734
"sentry.monitors.tasks.detect_broken_monitor_envs",
737735
"sentry.tasks.app_store_connect",
738736
"sentry.tasks.assemble",

src/sentry/monitors/clock_dispatch.py

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,13 @@
33
import logging
44
from datetime import datetime, timedelta, timezone
55

6-
import sentry_sdk
76
from arroyo import Topic as ArroyoTopic
87
from arroyo.backends.kafka import KafkaPayload, KafkaProducer, build_kafka_configuration
98
from django.conf import settings
109
from sentry_kafka_schemas.codecs import Codec
1110
from sentry_kafka_schemas.schema_types.monitors_clock_tick_v1 import ClockTick
1211

13-
from sentry import options
1412
from sentry.conf.types.kafka_definition import Topic, get_topic_codec
15-
from sentry.monitors.tasks.check_missed import check_missing
16-
from sentry.monitors.tasks.check_timeout import check_timeout
1713
from sentry.utils import metrics, redis
1814
from sentry.utils.arroyo_producer import SingletonProducer
1915
from sentry.utils.kafka_config import get_kafka_producer_cluster_options, get_topic_definition
@@ -63,19 +59,15 @@ def _dispatch_tick(ts: datetime):
6359
sentry.io, when we deploy we restart the celery beat worker and it will
6460
skip any tasks it missed)
6561
"""
66-
if options.get("crons.use_clock_pulse_consumer"):
67-
if settings.SENTRY_EVENTSTREAM != "sentry.eventstream.kafka.KafkaEventStream":
68-
# XXX(epurkhiser): Unclear what we want to do if we're not using kafka
69-
return
62+
if settings.SENTRY_EVENTSTREAM != "sentry.eventstream.kafka.KafkaEventStream":
63+
# XXX(epurkhiser): Unclear what we want to do if we're not using kafka
64+
return
7065

71-
message: ClockTick = {"ts": ts.timestamp()}
72-
payload = KafkaPayload(None, CLOCK_TICK_CODEC.encode(message), [])
66+
message: ClockTick = {"ts": ts.timestamp()}
67+
payload = KafkaPayload(None, CLOCK_TICK_CODEC.encode(message), [])
7368

74-
topic = get_topic_definition(Topic.MONITORS_CLOCK_TICK)["real_topic_name"]
75-
_clock_tick_producer.produce(ArroyoTopic(topic), payload)
76-
else:
77-
check_missing.delay(current_datetime=ts)
78-
check_timeout.delay(current_datetime=ts)
69+
topic = get_topic_definition(Topic.MONITORS_CLOCK_TICK)["real_topic_name"]
70+
_clock_tick_producer.produce(ArroyoTopic(topic), payload)
7971

8072

8173
def try_monitor_clock_tick(ts: datetime, partition: int):
@@ -150,20 +142,14 @@ def try_monitor_clock_tick(ts: datetime, partition: int):
150142
# task run, backfill those ticks. This can happen when one partition has
151143
# slowed down too much and is missing a minutes worth of check-ins
152144
if last_ts is not None and slowest_part_ts > last_ts + 60:
153-
if options.get("crons.use_clock_pulse_consumer"):
154-
# We only want to do backfills when we're using the clock tick
155-
# consumer, otherwise the celery tasks may process out of order
156-
backfill_tick = datetime.fromtimestamp(last_ts + 60, tz=timezone.utc)
157-
while backfill_tick < tick:
158-
extra = {"reference_datetime": str(backfill_tick)}
159-
logger.info("monitors.consumer.clock_tick_backfill", extra=extra)
160-
161-
_dispatch_tick(backfill_tick)
162-
backfill_tick = backfill_tick + timedelta(minutes=1)
163-
else:
164-
with sentry_sdk.push_scope() as scope:
165-
scope.set_extra("last_ts", last_ts)
166-
scope.set_extra("slowest_part_ts", slowest_part_ts)
167-
sentry_sdk.capture_message("Monitor task dispatch minute skipped")
145+
# We only want to do backfills when we're using the clock tick
146+
# consumer, otherwise the celery tasks may process out of order
147+
backfill_tick = datetime.fromtimestamp(last_ts + 60, tz=timezone.utc)
148+
while backfill_tick < tick:
149+
extra = {"reference_datetime": str(backfill_tick)}
150+
logger.info("monitors.consumer.clock_tick_backfill", extra=extra)
151+
152+
_dispatch_tick(backfill_tick)
153+
backfill_tick = backfill_tick + timedelta(minutes=1)
168154

169155
_dispatch_tick(tick)

src/sentry/monitors/tasks/check_missed.py

Lines changed: 0 additions & 151 deletions
This file was deleted.

src/sentry/monitors/tasks/check_timeout.py

Lines changed: 0 additions & 95 deletions
This file was deleted.

src/sentry/utils/sdk.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,6 @@
7474
"sentry.profiles.task.process_profile": 0.01,
7575
"sentry.tasks.derive_code_mappings.process_organizations": settings.SAMPLED_DEFAULT_RATE,
7676
"sentry.tasks.derive_code_mappings.derive_code_mappings": settings.SAMPLED_DEFAULT_RATE,
77-
"sentry.monitors.tasks.check_missing": 1.0,
78-
"sentry.monitors.tasks.mark_environment_missing": 0.05,
79-
"sentry.monitors.tasks.check_timeout": 1.0,
80-
"sentry.monitors.tasks.mark_checkin_timeout": 0.05,
8177
"sentry.monitors.tasks.clock_pulse": 1.0,
8278
"sentry.tasks.auto_enable_codecov": settings.SAMPLED_DEFAULT_RATE,
8379
"sentry.dynamic_sampling.tasks.boost_low_volume_projects": 1.0,

tests/sentry/monitors/consumers/test_clock_tick_consumer.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
ScheduleType,
2727
)
2828
from sentry.testutils.cases import TestCase
29-
from sentry.testutils.helpers.options import override_options
3029

3130
partition = Partition(Topic("test"), 0)
3231

@@ -61,7 +60,6 @@ def test_simple(mock_dispatch_check_timeout, mock_dispatch_check_missing):
6160

6261
class MonitorsClockTickEndToEndTest(TestCase):
6362
@override_settings(SENTRY_EVENTSTREAM="sentry.eventstream.kafka.KafkaEventStream")
64-
@override_options({"crons.use_clock_pulse_consumer": True})
6563
def test_end_to_end(self):
6664
ts = timezone.now().replace(second=0, microsecond=0)
6765

0 commit comments

Comments
 (0)