: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(data-imports): stop reporting billing-check redis blips to error tracking (#73388)
Tom Owersb47711b758d6
diff --git a/products/warehouse_sources/backend/temporal/data_imports/row_tracking.py b/products/warehouse_sources/backend/temporal/data_imports/row_tracking.pyindex 367a488a561c..fdc15deb707f 100644--- a/products/warehouse_sources/backend/temporal/data_imports/row_tracking.py+++ b/products/warehouse_sources/backend/temporal/data_imports/row_tracking.py@@ -8,6 +8,7 @@ from django.conf import settingsfrom django.db.models import F, Q, Sumfrom dateutil import parser+from redis import exceptions as redis_exceptionsfrom structlog.types import FilteringBoundLoggerfrom posthog.cloud_utils import get_cached_instance_license@@ -233,6 +234,13 @@ async def will_hit_billing_limit(team_id: int, source: "ExternalDataSource", log)return result+ except redis_exceptions.RedisError as e:+ # The billing check already fails open, so a Redis connectivity blip (e.g. a+ # DNS resolution failure reaching the quota-limiting cache) shouldn't be reported+ # as an error-tracking issue.+ await logger.awarning(f"BillingLimits: Redis error while checking billing limits, failing open: {e}")++ return Falseexcept Exception as e:await logger.adebug(f"BillingLimits: Failed with exception {e}")capture_exception(e)diff --git a/products/warehouse_sources/backend/temporal/data_imports/tests/test_row_tracking.py b/products/warehouse_sources/backend/temporal/data_imports/tests/test_row_tracking.pyindex 6b7aa47c8f31..f13415d58df3 100644--- a/products/warehouse_sources/backend/temporal/data_imports/tests/test_row_tracking.py+++ b/products/warehouse_sources/backend/temporal/data_imports/tests/test_row_tracking.py@@ -12,6 +12,7 @@ from unittest import mockfrom django.test import override_settingsfrom asgiref.sync import sync_to_async+from redis import exceptions as redis_exceptionsfrom structlog.types import FilteringBoundLoggerfrom posthog.models import Team@@ -195,3 +196,25 @@ class TestRowTracking(BaseTest):async with self._setup_redis_rows(20, team_id=another_team.pk):assert await self._run(source, 10) is True++ @pytest.mark.asyncio+ async def test_row_tracking_fails_open_on_redis_error_without_capturing_exception(self):+ # A transient Redis connectivity blip while fetching billing data (e.g. a DNS+ # resolution failure reaching the quota-limiting cache) must fail open like any+ # other billing-check error, but shouldn't be reported to error tracking since+ # the check already tolerates it.+ source = await self._create_source()++ with (+ mock.patch("ee.billing.billing_manager.BillingManager.get_billing") as mock_get_billing,+ mock.patch(+ "products.warehouse_sources.backend.temporal.data_imports.row_tracking.capture_exception"+ ) as mock_capture_exception,+ ):+ mock_get_billing.side_effect = redis_exceptions.ConnectionError(+ "Error -3 connecting to redis:6379. Temporary failure in name resolution."+ )++ assert await self._run(source, 10) is False++ mock_capture_exception.assert_not_called()