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.

chore(temporal): restore structlog config after each temporal test (#110751)

Bernat Torresd6a0180db6ff
diff --git a/posthog/temporal/conftest.py b/posthog/temporal/conftest.py
new file mode 100644
index 000000000000..52da7f021658
--- /dev/null
+++ b/posthog/temporal/conftest.py
@@ -0,0 +1,19 @@
+from collections.abc import Iterator
+
+import pytest
+
+import structlog
+
+
[email protected](autouse=True)
+def _restore_structlog_config() -> Iterator[None]:
+ # configure_logger replaces the process-wide structlog config. Without this restore, a test that
+ # binds the logger to its own event loop leaves that binding to every later test on the worker,
+ # which then produces log lines to a closed loop.
+ previous_config = structlog.get_config()
+ previously_configured = structlog.is_configured()
+ yield
+ if previously_configured:
+ structlog.configure(**previous_config)
+ else:
+ structlog.reset_defaults()