Skip to content

: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.

fix(google_analytics): classify exhausted quota retries as retryable noise (#73596)

Tom Owers8495b885194d
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/google_analytics/google_analytics.py b/products/warehouse_sources/backend/temporal/data_imports/sources/google_analytics/google_analytics.py
index b8decefff726..589f8871ed91 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/google_analytics/google_analytics.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/google_analytics/google_analytics.py
@@ -61,6 +61,8 @@ class GoogleAnalyticsQuotaExceededError(Exception):
Deliberately NOT matched by `get_non_retryable_errors` so Temporal retries
the activity later (the resumable source picks up from the last saved
chunk), which is the right recovery for hourly/daily property token quotas.
+ Tagged `(retryable)` so `GoogleAnalyticsSource.get_retryable_errors` can
+ keep this self-recovering failure out of error tracking.
"""
@@ -207,7 +209,8 @@ def _run_report(
if attempt == RUNREPORT_MAX_RETRIES:
if is_quota:
raise GoogleAnalyticsQuotaExceededError(
- f"Data API quota for property '{pid}' still exhausted after {RUNREPORT_MAX_RETRIES} retries"
+ f"Data API quota for property '{pid}' still exhausted after "
+ f"{RUNREPORT_MAX_RETRIES} retries (retryable)"
)
# A transient 5xx that never cleared — surface the HTTPError so Temporal retries the activity.
response.raise_for_status()
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/google_analytics/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/google_analytics/source.py
index 556f89d38740..44e9a92edd9c 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/google_analytics/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/google_analytics/source.py
@@ -70,6 +70,13 @@ class GoogleAnalyticsSource(ResumableSource[GoogleAnalyticsSourceConfig, GoogleA
"ACCESS_TOKEN_SCOPE_INSUFFICIENT": "Insufficient permissions. Please reconnect your Google Analytics account with the required scopes.",
}
+ def get_retryable_errors(self) -> set[str]:
+ # `_run_report` already retries Data API quota exhaustion in-line with backoff; if it's
+ # still exhausted once those retries run out, the property's token quota refills over
+ # time and the resumable source picks up from the last saved chunk, so let Temporal
+ # retry the activity without paging it as a bug.
+ return {"(retryable)"}
+
def get_schemas(
self,
config: GoogleAnalyticsSourceConfig,
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/google_analytics/tests/test_google_analytics_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/google_analytics/tests/test_google_analytics_source.py
index 9d2c4912e47d..20ec55e67100 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/google_analytics/tests/test_google_analytics_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/google_analytics/tests/test_google_analytics_source.py
@@ -262,3 +262,9 @@ def test_non_retryable_errors_cover_auth_failures():
assert "401 Client Error" in errors
assert "403 Client Error" in errors
assert "ACCESS_TOKEN_SCOPE_INSUFFICIENT" in errors
+
+
+def test_retryable_errors_cover_exhausted_quota_retries():
+ error_msg = "Data API quota for property '123456789' still exhausted after 5 retries (retryable)"
+ patterns = GoogleAnalyticsSource().get_retryable_errors()
+ assert any(pattern in error_msg for pattern in patterns)