Skip to content

Commit dfe924a

Browse files
ref(crons): Add new timestamps to check-ins (#84990)
Co-authored-by: Josh Ferge <[email protected]>
1 parent 5ac887a commit dfe924a

File tree

3 files changed

+59
-1
lines changed

3 files changed

+59
-1
lines changed

migrations_lockfile.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ remote_subscriptions: 0003_drop_remote_subscription
1515

1616
replays: 0004_index_together
1717

18-
sentry: 0828_add_platform_to_grouphash_metadata
18+
sentry: 0829_add_additional_timestamps_to_checkins
1919

2020
social_auth: 0002_default_auto_field
2121

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Generated by Django 5.1.5 on 2025-02-11 20:06
2+
3+
import django.utils.timezone
4+
from django.db import migrations, models
5+
6+
from sentry.new_migrations.migrations import CheckedMigration
7+
8+
9+
class Migration(CheckedMigration):
10+
# This flag is used to mark that a migration shouldn't be automatically run in production.
11+
# This should only be used for operations where it's safe to run the migration after your
12+
# code has deployed. So this should not be used for most operations that alter the schema
13+
# of a table.
14+
# Here are some things that make sense to mark as post deployment:
15+
# - Large data migrations. Typically we want these to be run manually so that they can be
16+
# monitored and not block the deploy for a long period of time while they run.
17+
# - Adding indexes to large tables. Since this can take a long time, we'd generally prefer to
18+
# run this outside deployments so that we don't block them. Note that while adding an index
19+
# is a schema change, it's completely safe to run the operation after the code has deployed.
20+
# Once deployed, run these manually via: https://develop.sentry.dev/database-migrations/#migration-deployment
21+
22+
is_post_deployment = False
23+
24+
dependencies = [
25+
("sentry", "0828_add_platform_to_grouphash_metadata"),
26+
]
27+
28+
operations = [
29+
migrations.AddField(
30+
model_name="monitorcheckin",
31+
name="date_clock",
32+
field=models.DateTimeField(null=True),
33+
),
34+
migrations.AddField(
35+
model_name="monitorcheckin",
36+
name="date_created",
37+
field=models.DateTimeField(default=django.utils.timezone.now, null=True),
38+
),
39+
]

src/sentry/monitors/models.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,25 @@ class MonitorCheckIn(Model):
501501
Represents the time the checkin was made. This CAN BE back-dated in some
502502
cases, and does not necessarily represent the insertion time of the row in
503503
the database.
504+
505+
This date comes from the time relay reiceved the envelope containing the
506+
check-in.
507+
"""
508+
509+
date_clock = models.DateTimeField(null=True)
510+
"""
511+
Represents the "clock time" that this check in was recorded at. Since the
512+
stream of check-ins is processed within the context of a clock that only
513+
moves forward as we process kafka messages, this time represents the time
514+
at which we processed this check-in, in relation to all other tasks (such
515+
as detecting misses)
516+
"""
517+
518+
date_created = models.DateTimeField(default=timezone.now, null=True)
519+
"""
520+
Represents when the check-in was actually recorded into the database. This
521+
is a real wall-clock time and is not tied to the "clock" time that
522+
check-ins are processed in the contenxt of.
504523
"""
505524

506525
date_updated = models.DateTimeField(default=timezone.now)

0 commit comments

Comments
 (0)