Skip to content

Commit 3a32f23

Browse files
authored
feat(metrics-extraction): Add condition to update on-demand row (#64659)
### Summary This will cause the row to always be updated, which fixes the trouble with all the widget queries date modified being set to when the migration ran (Feb 5th) despite them likely being older than an on demand row
1 parent c4dc41d commit 3a32f23

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/sentry/options/defaults.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1702,6 +1702,12 @@
17021702
default=False,
17031703
flags=FLAG_AUTOMATOR_MODIFIABLE,
17041704
)
1705+
# Overrides modified date and always updates the row. Can be removed if not needed later.
1706+
register(
1707+
"on_demand.update_on_demand_modified",
1708+
default=False,
1709+
flags=FLAG_AUTOMATOR_MODIFIABLE,
1710+
)
17051711

17061712
register(
17071713
"delightful_metrics.minimetrics_sample_rate",

src/sentry/tasks/on_demand_metrics.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
import sentry_sdk
88
from celery.exceptions import SoftTimeLimitExceeded
9+
from django.utils import timezone
910

1011
from sentry import options
1112
from sentry.api.utils import get_date_range_from_params
@@ -295,6 +296,11 @@ def _set_widget_on_demand_state(
295296
if on_demand.can_extraction_be_auto_overridden():
296297
on_demand.extraction_state = extraction_state
297298

299+
if options.get("on_demand.update_on_demand_modified"):
300+
# Only temporarily required to check we've updated data on rows the task has passed
301+
# Or updated to pass the check against widget query date_modified.
302+
on_demand.date_modified = timezone.now()
303+
298304
on_demand.spec_hashes = spec_hashes
299305
on_demand.save()
300306

0 commit comments

Comments
 (0)