Skip to content

Commit 74593d2

Browse files
authored
chore(issues): Log details on very old time-to-post-process (#68590)
We are seeing a handful of time-to-post-process metrics recorded which have very large durations, in some cases >1 month. Logging some additional information on these groups should help us investigate more. The test here is a bit overkill but for now ensures that we're not accidentally logging on every single group.
1 parent 6191626 commit 74593d2

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

src/sentry/tasks/post_process.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,13 +747,23 @@ def get_event_raise_exception() -> Event:
747747
metric_tags["occurrence_type"] = group_event.group.issue_type.slug
748748

749749
if not is_reprocessed and event.data.get("received"):
750+
duration = time() - event.data["received"]
750751
metrics.timing(
751752
"events.time-to-post-process",
752-
time() - event.data["received"],
753+
duration,
753754
instance=event.data["platform"],
754755
tags=metric_tags,
755756
)
756757

758+
# We see occasional metrics being recorded with very old data,
759+
# temporarily log some information about these groups to help
760+
# investigate.
761+
if duration and duration > 604_800: # 7 days (7*24*60*60)
762+
logger.warning(
763+
"tasks.post_process.old_time_to_post_process",
764+
extra={"group_id": group_id, "project_id": project_id, "duration": duration},
765+
)
766+
757767

758768
def run_post_process_job(job: PostProcessJob):
759769
group_event = job["event"]

tests/sentry/tasks/test_post_process.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,24 @@ def test_processing_cache_cleared_with_commits(self):
186186
)
187187
assert event_processing_store.get(cache_key) is None
188188

189+
@patch("sentry.utils.metrics.timing")
190+
@patch("sentry.tasks.post_process.logger")
191+
def test_time_to_process_metric(self, logger_mock, metric_timing_mock):
192+
event = self.create_event(data={}, project_id=self.project.id)
193+
self.call_post_process_group(
194+
is_new=True,
195+
is_regression=False,
196+
is_new_group_environment=True,
197+
event=event,
198+
)
199+
metric_timing_mock.assert_any_call(
200+
"events.time-to-post-process",
201+
mock.ANY,
202+
instance=mock.ANY,
203+
tags={"occurrence_type": mock.ANY},
204+
)
205+
logger_mock.warning.assert_not_called()
206+
189207

190208
class DeriveCodeMappingsProcessGroupTestMixin(BasePostProgressGroupMixin):
191209
def _create_event(

0 commit comments

Comments
 (0)