: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(replay-vision): register the stuck counter bump on the replay vision worker (#125534)
Tue Haulund10988c4bffc9
diff --git a/products/replay_vision/backend/temporal/__init__.py b/products/replay_vision/backend/temporal/__init__.pyindex b2a6b1fed860..44eaefeac430 100644--- a/products/replay_vision/backend/temporal/__init__.py+++ b/products/replay_vision/backend/temporal/__init__.py@@ -1,6 +1,8 @@from collections.abc import Callablefrom typing import Any+from posthog.temporal.session_replay.rasterize_recording.activities.stuck_counter import bump_stuck_counter_activity+from products.replay_vision.backend.temporal.activities import (advance_backfill_cursor_activity,advance_scanner_watermark_activity,@@ -88,6 +90,8 @@ WORKFLOWS = [VisionAlertCheckWorkflow,]ACTIVITIES: list[Callable[..., Any]] = [+ # ApplyScannerWorkflow bumps the rasterizer's stuck counter on this queue when a render times out.+ bump_stuck_counter_activity,discover_due_vision_alerts_activity,evaluate_vision_alert_batch_activity,drain_vision_alert_matches_activity,diff --git a/products/replay_vision/backend/tests/test_temporal.py b/products/replay_vision/backend/tests/test_temporal.pyindex 8a82e581774f..0fd8ba5ac653 100644--- a/products/replay_vision/backend/tests/test_temporal.py+++ b/products/replay_vision/backend/tests/test_temporal.py@@ -40,6 +40,10 @@ from posthog.models.user import Userfrom posthog.redis import get_async_clientfrom posthog.session_recordings.queries.session_replay_events import SessionEventsPage, SessionReplayEventsfrom posthog.session_recordings.session_recording_v2_service import RecordingBlock+from posthog.temporal.session_replay.rasterize_recording.activities.stuck_counter import (+ BumpStuckCounterInput,+ bump_stuck_counter_activity,+)from products.exports.backend.models.exported_asset import ExportedAssetfrom products.replay_vision.backend.api.observation_progress import _ObservationState, stream_observation_progress@@ -58,7 +62,7 @@ from products.replay_vision.backend.models.replay_observation import (from products.replay_vision.backend.models.replay_observation_usage import ReplayObservationUsagefrom products.replay_vision.backend.models.replay_scanner import ReplayScanner, ScannerModel, ScannerTypefrom products.replay_vision.backend.quota import QuotaSnapshot-from products.replay_vision.backend.temporal import ApplyScannerWorkflow+from products.replay_vision.backend.temporal import ACTIVITIES, ApplyScannerWorkflowfrom products.replay_vision.backend.temporal.activities.call_scanner_provider import (_extract_segments,_inject_known_freeform_tags,@@ -2803,7 +2807,11 @@ class _WorkflowMocks:self.activity_calls: list[tuple[Any, Any]] = []self.child_calls: list[tuple[tuple, dict]] = []- async def execute_activity(self, activity_fn: Any, activity_input: Any, **_: Any) -> Any:+ async def execute_activity(self, activity_fn: Any, activity_input: Any, **kwargs: Any) -> Any:+ # Without a task_queue the call lands on the Replay Vision queue, so its worker must register the activity.+ # pytest.fail raises a BaseException, which the workflow's fail-soft `except Exception` blocks can't swallow.+ if kwargs.get("task_queue") is None and activity_fn not in ACTIVITIES:+ pytest.fail(f"{activity_fn.__name__} is not registered on the Replay Vision worker")self.activity_calls.append((activity_fn, activity_input))if activity_fn in self.activity_errors:raise self.activity_errors[activity_fn]@@ -3025,6 +3033,28 @@ async def test_apply_scanner_workflow_splits_rasterizer_failures_by_cause(assert upload_video_to_gemini_activity not in called+async def test_apply_scanner_workflow_bumps_the_stuck_counter_when_a_render_times_out() -> None:+ mocks = _WorkflowMocks(+ activity_results={+ create_observation_activity: CreateObservationOutput(+ observation_id=uuid.uuid4(), was_created=True, scanner_type=ScannerType.MONITOR+ ),+ ensure_session_asset_activity: EnsureSessionAssetOutput(asset_id=42),+ },+ child_error=_wrap_in_child_workflow_error(+ TemporalTimeoutError("timed out", type=TimeoutType.START_TO_CLOSE, last_heartbeat_details=[])+ ),+ )++ with pytest.raises(Exception):+ await _run_workflow(_build_inputs(session_id="sess-raster"), mocks)++ bumps = [arg for fn, arg in mocks.activity_calls if fn is bump_stuck_counter_activity]+ assert bumps == [BumpStuckCounterInput(team_id=1, session_id="sess-raster")]+ assert mocks.activity_calls[-1][1].error_reason.startswith("rasterization_failed:")++@pytest.mark.asyncio@pytest.mark.parametrize("leaf_message,non_retryable,expected_kind,expected_reason",