:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(activities): include alert IDs in exception tracking for cohort queries (#57777)
Jon McCallum6e24b0c12e95
diff --git a/products/logs/backend/temporal/activities.py b/products/logs/backend/temporal/activities.pyindex 891fbc67b48b..9ccbd502fcfa 100644--- a/products/logs/backend/temporal/activities.py+++ b/products/logs/backend/temporal/activities.py@@ -632,12 +632,15 @@ def _run_cohort_query(cohort: _AlertCohort) -> _CohortQueryResult:if cohort_size == 1:return _CohortQueryResult(per_alert={str(cohort.alerts[0].id): _PrefetchedQuery(error=e)})+ alert_ids = [str(a.id) for a in cohort.alerts]+classified = classify_alert_error(e)if classified.is_transient:logger.warning("Batched cohort query failed (transient); skipping per-alert fallback",team_id=team_id,cohort_size=cohort_size,+ alert_ids=alert_ids,error=str(e),classification=classified.code,)@@ -648,10 +651,11 @@ def _run_cohort_query(cohort: _AlertCohort) -> _CohortQueryResult:"Batched cohort query failed; falling back to per-alert queries",team_id=team_id,cohort_size=cohort_size,+ alert_ids=alert_ids,error=str(e),classification=classified.code,)- capture_exception(e, {"team_id": team_id, "cohort_size": cohort_size})+ capture_exception(e, {"team_id": team_id, "cohort_size": cohort_size, "alert_ids": alert_ids})_safe_record("cohort_query_fallback counter", increment_cohort_query_fallback, "batched_failure")return _run_per_alert_queries(cohort)