: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
feat(replay-vision): let rasterize workflows pick their task queue (#102296)
Tue Haulundfdc077de47a9
diff --git a/posthog/settings/temporal.py b/posthog/settings/temporal.pyindex f68d86cd432d..ecbabca4c890 100644--- a/posthog/settings/temporal.py+++ b/posthog/settings/temporal.py@@ -304,6 +304,9 @@ LOGS_VOLUME_TICK_TASK_QUEUE = _set_temporal_task_queue(os.getenv("LOGS_VOLUME_TICK_TASK_QUEUE", "logs-volume-tick-task-queue"))RASTERIZATION_TASK_QUEUE = "rasterization-task-queue" # Not collapsed in dev — separate Node.js worker process+# Replay Vision observation media (thumbnails, clips). Kept off the shared rasterization+# queue so media never competes with customer exports and session video summaries.+RASTERIZATION_MEDIA_TASK_QUEUE = "rasterization-media-task-queue"# Error tracking# Global on/off switch for auto-merging close fingerprints into their nearest issue.diff --git a/posthog/temporal/session_replay/rasterize_recording/types.py b/posthog/temporal/session_replay/rasterize_recording/types.pyindex e53659ebaa43..caf044f31e8a 100644--- a/posthog/temporal/session_replay/rasterize_recording/types.py+++ b/posthog/temporal/session_replay/rasterize_recording/types.py@@ -28,6 +28,9 @@ class RasterizeRecordingInputs(BaseModel, frozen=True):exported_asset_id: intproduct: Literal["session_replay", "replay_vision"] = "session_replay"+ # Routes the render activity. None keeps the shared rasterization queue, so histories+ # recorded before this field existed replay unchanged.+ task_queue: str | None = Noneclass RasterizationActivityInput(BaseModel, frozen=True):diff --git a/posthog/temporal/session_replay/rasterize_recording/workflow.py b/posthog/temporal/session_replay/rasterize_recording/workflow.pyindex 3c9c04044510..9d2bf5e06b94 100644--- a/posthog/temporal/session_replay/rasterize_recording/workflow.py+++ b/posthog/temporal/session_replay/rasterize_recording/workflow.py@@ -204,7 +204,7 @@ class RasterizeRecordingWorkflow(PostHogWorkflow):# Reading a Django setting inside a workflow body is normally banned (it is not part of# recorded history); it is tolerated here because Temporal does not replay-check the# task-queue attribute, and a mid-flight change only redirects retries.- task_queue=settings.RASTERIZATION_TASK_QUEUE,+ task_queue=inputs.task_queue or settings.RASTERIZATION_TASK_QUEUE,start_to_close_timeout=RASTERIZE_RENDER_TIMEOUT,heartbeat_timeout=dt.timedelta(seconds=30),retry_policy=common.RetryPolicy(maximum_attempts=RASTERIZE_RENDER_MAX_ATTEMPTS),diff --git a/posthog/temporal/tests/session_replay/rasterize_recording/test_workflow.py b/posthog/temporal/tests/session_replay/rasterize_recording/test_workflow.pyindex 8f2dd87b5e46..edc7f0cf6fa3 100644--- a/posthog/temporal/tests/session_replay/rasterize_recording/test_workflow.py+++ b/posthog/temporal/tests/session_replay/rasterize_recording/test_workflow.py@@ -448,3 +448,62 @@ def _activity_error() -> ActivityError:activity_id="1",retry_state=None,)++[email protected]("route_to_media", [False, True])+async def test_render_runs_on_the_requested_queue(route_to_media: bool):+ from django.conf import settings++ from posthog.temporal.session_replay.rasterize_recording.types import RasterizationActivityInput++ requested_queue = settings.RASTERIZATION_MEDIA_TASK_QUEUE if route_to_media else None+ expected_queue = requested_queue or settings.RASTERIZATION_TASK_QUEUE+ rendered_on: list[str] = []++ @activity.defn(name="build_rasterization_input")+ async def build_mocked(_exported_asset_id: int) -> BuildRasterizationResult:+ return BuildRasterizationResult(+ activity_input=RasterizationActivityInput(session_id="s", team_id=7, s3_bucket="b", s3_key_prefix="p"),+ render_fingerprint="abc",+ )++ @activity.defn(name="rasterize-recording")+ async def render_mocked(_inputs: dict) -> dict:+ rendered_on.append(activity.info().task_queue)+ return {"s3_uri": "s3://bucket/key", "video_duration_s": 1.0, "playback_speed": 1.0}++ @activity.defn(name="finalize_rasterization")+ async def finalize_noop(_inputs: FinalizeRasterizationInput) -> None:+ pass++ @activity.defn(name="clear_stuck_counter_activity")+ async def clear_noop(_inputs: BumpStuckCounterInput) -> None:+ pass++ task_queue = str(uuid.uuid4())+ async with await WorkflowEnvironment.start_time_skipping() as env:+ await _register_search_attributes(env)+ async with (+ Worker(+ env.client,+ task_queue=task_queue,+ workflows=[RasterizeRecordingWorkflow],+ activities=[build_mocked, finalize_noop, clear_noop],+ workflow_runner=temporalio.worker.UnsandboxedWorkflowRunner(),+ ),+ # Both queues carry a render worker, so a mis-routed render still completes and the+ # assertion below names the wrong queue instead of hanging forever.+ Worker(env.client, task_queue=settings.RASTERIZATION_TASK_QUEUE, activities=[render_mocked]),+ Worker(env.client, task_queue=settings.RASTERIZATION_MEDIA_TASK_QUEUE, activities=[render_mocked]),+ ):+ await env.client.execute_workflow(+ RasterizeRecordingWorkflow.run,+ RasterizeRecordingInputs(exported_asset_id=42, task_queue=requested_queue),+ id=str(uuid.uuid4()),+ task_queue=task_queue,+ retry_policy=RetryPolicy(maximum_attempts=1),+ search_attributes=_search_attributes(),+ )++ assert rendered_on == [expected_queue]