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(data-imports): stop pagespeed insights exhausted retries minting error-tracking noise (#74159)

Tom Owers56f724841540
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/google_pagespeed_insights/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/google_pagespeed_insights/source.py
index d15a38063d16..14325ffa1d70 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/google_pagespeed_insights/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/google_pagespeed_insights/source.py
@@ -109,6 +109,13 @@ Each analysis is a full Lighthouse run and can take several seconds. Each URL is
"403 Client Error: Forbidden for url: https://pagespeedonline.googleapis.com": "Your API key does not have access to the PageSpeed Insights API. Enable the API for your Google Cloud project and check any key restrictions, then reconnect.",
}
+ def get_retryable_errors(self) -> set[str]:
+ # 429/5xx are already retried internally with backoff (see google_pagespeed_insights.py's
+ # tenacity-wrapped `_fetch`); if those retries still exhaust, the failure is transient and
+ # self-recovering, so let Temporal retry the activity without surfacing it as tracked
+ # exception noise.
+ return {"PageSpeed Insights API error (retryable)"}
+
def get_schemas(
self,
config: GooglePageSpeedInsightsSourceConfig,
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/google_pagespeed_insights/tests/test_google_pagespeed_insights_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/google_pagespeed_insights/tests/test_google_pagespeed_insights_source.py
index 44fd8d25d6f7..a3582862931d 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/google_pagespeed_insights/tests/test_google_pagespeed_insights_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/google_pagespeed_insights/tests/test_google_pagespeed_insights_source.py
@@ -101,6 +101,19 @@ class TestGooglePageSpeedInsightsSource:
assert any(status in key and "pagespeedonline.googleapis.com" in key for key in errors)
+ @pytest.mark.parametrize(
+ "error_message",
+ [
+ "PageSpeed Insights API error (retryable): status=429",
+ "PageSpeed Insights API error (retryable): status=500",
+ ],
+ )
+ def test_retryable_errors_match_exhausted_backoff(self, error_message):
+ # `_fetch` already retries 429/5xx internally with backoff; once those attempts are
+ # exhausted, this must stay classified as retryable so it doesn't get tracked as noise.
+ retryable_errors = self.source.get_retryable_errors()
+ assert any(pattern in error_message for pattern in retryable_errors)
+
def test_documented_tables_render_without_credentials(self):
# Exercises the public-docs path: a credential-free placeholder config must list every table.
tables = self.source.get_documented_tables()