: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(api): log the api query budget refusals through a logger that is not clamped to warning (#97592)
Andy Zhao6fc0e47ecc01
diff --git a/posthog/hogql_queries/query_runner.py b/posthog/hogql_queries/query_runner.pyindex ec79c849531d..dd6e62b8a16e 100644--- a/posthog/hogql_queries/query_runner.py+++ b/posthog/hogql_queries/query_runner.py@@ -179,6 +179,9 @@ from products.access_control.backend.facade.user_access_control import (from products.web_analytics.backend.hogql_queries.first_pageview_flag import resolve_first_pageview_filters_modifierlogger = structlog.get_logger(__name__)+# Named so posthog/settings/logs.py can opt it into INFO: the posthoganalytics SDK clamps the+# "posthog" logger tree to WARNING, which would drop the budget line under __name__.+budget_logger = structlog.get_logger("posthog.api_queries_budget")QUERY_EXECUTION_TOTAL = Counter("posthog_query_execution_total",@@ -2537,7 +2540,7 @@ class QueryRunner(ABC, Generic[Q, R, CR]):enforced = _api_queries_budget_enforcement_enabled(self.team)outcome = "enforced" if enforced else "observed"API_QUERIES_BUDGET_LIMITED_COUNTER.labels(outcome=outcome).inc()- logger.info(+ budget_logger.info("api_queries_budget_limited",organization_id=str(self.team.organization_id),team_id=self.team.pk,diff --git a/posthog/settings/logs.py b/posthog/settings/logs.pyindex be55fbfe95ea..7d35d86c3018 100644--- a/posthog/settings/logs.py+++ b/posthog/settings/logs.py@@ -177,6 +177,8 @@ LOGGING: dict[str, Any] = {# at client init, so the source-registry prewarm's INFO lifecycle logs need an# explicit level to be visible."posthog.warehouse_source_prewarm": {"level": "INFO", "handlers": ["console"], "propagate": False},+ # Same clamp: the api query budget logs the team and balance behind every would-be 429 at INFO.+ "posthog.api_queries_budget": {"level": "INFO", "handlers": ["console"], "propagate": False},"products.warehouse_sources.backend.temporal.data_imports.pipelines.pipeline_v3.load": {"level": "DEBUG","handlers": ["console"],