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(batch-exports): Avoid logger caching (#102292)

Tomás Farías Santana60664853b75b
diff --git a/products/batch_exports/backend/tests/temporal/pipeline/test_consumer.py b/products/batch_exports/backend/tests/temporal/pipeline/test_consumer.py
index e75cd20c117b..82679eab5e40 100644
--- a/products/batch_exports/backend/tests/temporal/pipeline/test_consumer.py
+++ b/products/batch_exports/backend/tests/temporal/pipeline/test_consumer.py
@@ -1,4 +1,5 @@
import asyncio
+from collections.abc import Iterator
import pytest
from unittest.mock import MagicMock, patch
@@ -6,6 +7,9 @@ from unittest.mock import MagicMock, patch
import pyarrow as pa
from structlog.testing import capture_logs
+from posthog.temporal.common.logger import get_write_only_logger
+
+from products.batch_exports.backend.temporal.pipeline import consumer as consumer_module
from products.batch_exports.backend.temporal.pipeline.consumer import Consumer, run_consumer_from_stage
from products.batch_exports.backend.temporal.pipeline.transformer import Chunk
from products.batch_exports.backend.temporal.queue import RecordBatchQueue
@@ -13,6 +17,12 @@ from products.batch_exports.backend.temporal.queue import RecordBatchQueue
pytestmark = [pytest.mark.asyncio]
[email protected](autouse=True, scope="module")
+def fresh_consumer_logger(configure_logger_auto: None) -> Iterator[None]:
+ with patch.object(consumer_module, "LOGGER", get_write_only_logger(consumer_module.__name__)):
+ yield
+
+
class NoOpConsumer(Consumer):
async def consume_chunk(self, data: bytes):
pass