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(grafana): stop reporting exhausted 429/503 retries as error-tracking noise (#80034)

Tom Owers4cf3a41728a6
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/grafana/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/grafana/source.py
index 1d6807034455..088496d8d315 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/grafana/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/grafana/source.py
@@ -150,6 +150,12 @@ Self-hosted Grafana OSS can alternatively authenticate with a username and passw
HOST_NOT_ALLOWED_ERROR: "The Grafana host is not allowed. Please use your instance's public URL.",
}
+ def get_retryable_errors(self) -> set[str]:
+ # `_make_fetch` already retries a 429/5xx in-line with backoff (see grafana.py); if that
+ # budget is still exhausted, the failure is a transient Grafana-side blip rather than a
+ # bug here, and Temporal's activity retry will pick the sync back up.
+ return {"(retryable)"}
+
def _build_auth(self, config: GrafanaSourceConfig) -> GrafanaAuth:
return GrafanaAuth(
method=config.auth_method.selection,
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/grafana/tests/test_grafana_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/grafana/tests/test_grafana_source.py
index 5c0c33827eac..c96bdc7e7777 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/grafana/tests/test_grafana_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/grafana/tests/test_grafana_source.py
@@ -14,6 +14,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.grafana.gr
TOKEN_AUTH,
GrafanaAuth,
GrafanaResumeConfig,
+ GrafanaRetryableError,
)
from products.warehouse_sources.backend.temporal.data_imports.sources.grafana.settings import ENDPOINTS
from products.warehouse_sources.backend.temporal.data_imports.sources.grafana.source import GrafanaSource
@@ -82,6 +83,16 @@ class TestGrafanaSource:
def test_non_retryable_errors(self, expected_key):
assert expected_key in self.source.get_non_retryable_errors()
+ @pytest.mark.parametrize("status_code", [429, 503])
+ def test_retryable_status_error_matches_retryable_pattern(self, status_code):
+ # `fetch()` in grafana.py raises this after its own tenacity retries are exhausted; it
+ # must stay classified as retryable rather than paging on every remaining Temporal attempt.
+ patterns = self.source.get_retryable_errors()
+ error = GrafanaRetryableError(
+ f"Grafana API error (retryable): status={status_code}, url=https://yourstack.grafana.net/api/annotations"
+ )
+ assert any(pattern in str(error) for pattern in patterns)
+
def test_get_schemas_returns_all_endpoints(self):
schemas = self.source.get_schemas(self.config, self.team_id)
assert {s.name for s in schemas} == set(ENDPOINTS)