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): classify exhausted Clarity connection retries as retryable (#110897)

Tom Owers662ed1175665
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/microsoft_clarity/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/microsoft_clarity/source.py
index 694a636f0559..dd074840d271 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/microsoft_clarity/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/microsoft_clarity/source.py
@@ -63,6 +63,14 @@ class MicrosoftClaritySource(SimpleSource[MicrosoftClaritySourceConfig]):
"429 Client Error": "The Microsoft Clarity daily quota (10 requests per project) has been used up. Try again after the quota resets.",
}
+ def get_retryable_errors(self) -> set[str]:
+ # `_fetch` calls `make_tracked_session` directly rather than through the shared REST
+ # engine, so `DEFAULT_RETRY` already retries a dropped connection or read timeout before
+ # re-raising once that budget is exhausted. urllib3 wraps that as "... Max retries exceeded
+ # with url: ..." regardless of the underlying cause. Temporal then retries the whole
+ # activity, so the failure is transient and self-recovering, not a bug to report.
+ return {"Max retries exceeded with url"}
+
def get_canonical_descriptions(self) -> CanonicalDescriptions:
from products.warehouse_sources.backend.temporal.data_imports.sources.microsoft_clarity.canonical_descriptions import (
CANONICAL_DESCRIPTIONS,
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/microsoft_clarity/tests/test_microsoft_clarity_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/microsoft_clarity/tests/test_microsoft_clarity_source.py
index 74ca474158a9..0d596f224127 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/microsoft_clarity/tests/test_microsoft_clarity_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/microsoft_clarity/tests/test_microsoft_clarity_source.py
@@ -71,6 +71,19 @@ class TestNonRetryableErrors:
observed = "HTTPSConnectionPool(host='www.clarity.ms', port=443): Read timed out."
assert not any(key in observed for key in errors)
+ def test_retryable_errors_match_exhausted_connection_retries(self) -> None:
+ # `make_tracked_session`'s `DEFAULT_RETRY` already retries a read timeout before
+ # re-raising; this is what the exhausted error looks like once it reaches the activity.
+ # Without this classification it gets reported to error tracking as noise on every
+ # occurrence even though Temporal transparently retries the activity.
+ error_msg = (
+ "HTTPSConnectionPool(host='www.clarity.ms', port=443): Max retries exceeded with "
+ "url: /export-data/api/v1/project-live-insights?numOfDays=3 (Caused by "
+ "ReadTimeoutError(\"HTTPSConnectionPool(host='www.clarity.ms', port=443): Read "
+ 'timed out. (read timeout=30)"))'
+ )
+ assert any(pattern in error_msg for pattern in MicrosoftClaritySource().get_retryable_errors())
+
class TestSourceForPipeline:
def test_plumbs_config_into_transport(self, monkeypatch: Any) -> None: