: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(dags): stop a dag import from silencing every existing logger (#88158)
Thiago Salvatore8c81f37b3385
diff --git a/posthog/dags/__init__.py b/posthog/dags/__init__.pyindex e02365b89d58..0572f50c37b6 100644--- a/posthog/dags/__init__.py+++ b/posthog/dags/__init__.py@@ -1,6 +1,7 @@import osimport django+from django.apps import apps# setup PostHog Django Projectos.environ.setdefault("DJANGO_SETTINGS_MODULE", "posthog.settings")@@ -9,4 +10,5 @@ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "posthog.settings")# This prevents hanging during database connection in app.ready()os.environ["SERVER_GATEWAY_INTERFACE"] = "ASGI"-django.setup()+if not apps.ready:+ django.setup()diff --git a/posthog/dags/tests/test_loggers.py b/posthog/dags/tests/test_loggers.pyindex 7b107e88562c..291c1465897e 100644--- a/posthog/dags/tests/test_loggers.py+++ b/posthog/dags/tests/test_loggers.py@@ -68,6 +68,15 @@ def test_engine_event_records_are_dropped_but_messages_pass():assert log.filter(_record(dagster_event=None))+def test_importing_the_package_does_not_silence_existing_loggers():+ probe = logging.getLogger("posthog.dags.tests.import_probe")+ probe.disabled = False++ importlib.reload(importlib.import_module("posthog.dags"))++ assert probe.disabled is False++def test_locations_export_single_shared_logger_instance():assert loggers == {"console": structlog_console_logger}