Skip to content

Commit 90daf56

Browse files
NicoHinderlinggeorge-sentry
authored andcommitted
ref(preprod): Fix build e2e time for reruns (#112527)
Pass a `triggered_at` timestamp when dispatching the size analysis comparison task, so the `preprod.size_analysis.compare.results_e2e` metric measures from dispatch time instead of `artifact.date_added`. This fixes inflated e2e durations on re-runs where the artifact was created much earlier.
1 parent c19c55e commit 90daf56

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

src/sentry/preprod/size_analysis/tasks.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from __future__ import annotations
22

33
import logging
4+
from datetime import datetime
45
from io import BytesIO
56
from typing import Any
67

@@ -53,6 +54,7 @@ def compare_preprod_artifact_size_analysis(
5354
project_id: int,
5455
org_id: int,
5556
artifact_id: int,
57+
triggered_at: str | None = None,
5658
**kwargs: Any,
5759
) -> None:
5860
logger.info(
@@ -266,7 +268,11 @@ def compare_preprod_artifact_size_analysis(
266268
except (ValueError, AttributeError, TypeError):
267269
artifact_type_name = "unknown"
268270

269-
e2e_size_analysis_compare_duration = timezone.now() - artifact.date_added
271+
# TODO: Remove artifact.date_added fallback once all producers pass triggered_at
272+
start_time = (
273+
datetime.fromisoformat(triggered_at) if triggered_at else artifact.date_added
274+
)
275+
e2e_size_analysis_compare_duration = timezone.now() - start_time
270276
metrics.distribution(
271277
"preprod.size_analysis.compare.results_e2e",
272278
e2e_size_analysis_compare_duration.total_seconds(),

src/sentry/preprod/tasks.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,7 @@ def _assemble_preprod_artifact_size_analysis(
679679
"project_id": project.id,
680680
"org_id": org_id,
681681
"artifact_id": artifact_id,
682+
"triggered_at": timezone.now().isoformat(),
682683
}
683684
)
684685

0 commit comments

Comments
 (0)