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(replay): log surfacing scoring tick counts in the message (#107771)

Arno Hillenb934f52d34b5
diff --git a/posthog/temporal/session_replay/surfacing_scoring_sweep/workflow.py b/posthog/temporal/session_replay/surfacing_scoring_sweep/workflow.py
index 9fb8169eca51..deeb61543883 100644
--- a/posthog/temporal/session_replay/surfacing_scoring_sweep/workflow.py
+++ b/posthog/temporal/session_replay/surfacing_scoring_sweep/workflow.py
@@ -73,9 +73,9 @@ class ScoreSessionsBatchWorkflow(PostHogWorkflow):
)
if not plan.chunks:
- workflow.logger.info(
- "surfacing_scoring_sweep.no_work", extra={"estimated": plan.estimated_unscored_sessions}
- )
+ # The structlog chain has no ExtraAdder, so stdlib `extra=` fields never reach the log.
+ # Log fields in this workflow go in the message.
+ workflow.logger.info(f"surfacing_scoring_sweep.no_work estimated={plan.estimated_unscored_sessions}")
return ScoreSessionsBatchResult()
# Activity dispatch order is recorded in Temporal history, so gate the bound for
@@ -123,21 +123,14 @@ def _summarize(chunks: list[ChunkSpec], results: list[ChunkResult | BaseExceptio
if isinstance(r, BaseException):
summary.chunks_failed += 1
if isinstance(r, ActivityError):
- workflow.logger.warning(
- "surfacing_scoring_sweep.chunk_activity_failed",
- extra={"error": str(r)},
- )
+ workflow.logger.warning(f"surfacing_scoring_sweep.chunk_activity_failed error={r}")
continue
summary.total_scored += r.scored
summary.total_fetched += r.fetched
workflow.logger.info(
- "surfacing_scoring_sweep.tick_done",
- extra={
- "chunks_dispatched": summary.chunks_dispatched,
- "chunks_failed": summary.chunks_failed,
- "total_scored": summary.total_scored,
- "total_fetched": summary.total_fetched,
- },
+ f"surfacing_scoring_sweep.tick_done chunks_dispatched={summary.chunks_dispatched} "
+ f"chunks_failed={summary.chunks_failed} total_scored={summary.total_scored} "
+ f"total_fetched={summary.total_fetched}"
)
record_tick_summary(
total_scored=summary.total_scored,
diff --git a/posthog/temporal/tests/session_replay/surfacing_scoring_sweep/test_workflow.py b/posthog/temporal/tests/session_replay/surfacing_scoring_sweep/test_workflow.py
index 7d6850318477..2e917d73cfdd 100644
--- a/posthog/temporal/tests/session_replay/surfacing_scoring_sweep/test_workflow.py
+++ b/posthog/temporal/tests/session_replay/surfacing_scoring_sweep/test_workflow.py
@@ -50,7 +50,9 @@ class TestSummarize:
ChunkResult(chunk_id=2, scored=7, fetched=9),
]
with (
- mock.patch("posthog.temporal.session_replay.surfacing_scoring_sweep.workflow.workflow.logger"),
+ mock.patch(
+ "posthog.temporal.session_replay.surfacing_scoring_sweep.workflow.workflow.logger"
+ ) as mock_logger,
mock.patch(
"posthog.temporal.session_replay.surfacing_scoring_sweep.workflow.record_tick_summary",
) as mock_record_tick_summary,
@@ -60,6 +62,9 @@ class TestSummarize:
total_scored=10, total_fetched=13, chunks_dispatched=3, chunks_failed=1
)
mock_record_tick_summary.assert_called_once_with(total_scored=10, total_fetched=13, chunks_failed=1)
+ mock_logger.info.assert_called_once_with(
+ "surfacing_scoring_sweep.tick_done chunks_dispatched=3 chunks_failed=1 total_scored=10 total_fetched=13"
+ )
def test_record_tick_summary_noops_when_tick_has_no_positive_counts(self) -> None:
chunks = [_chunk(0), _chunk(1)]