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.

feat(alerts): add a dedicated orchestration worker queue (#100854)

Jon McCallumea7a0112c136
diff --git a/docs/internal/alerts-product-temporal.md b/docs/internal/alerts-product-temporal.md
index 88ff475a65dc..bd27df842bc9 100644
--- a/docs/internal/alerts-product-temporal.md
+++ b/docs/internal/alerts-product-temporal.md
@@ -1,16 +1,21 @@
# Alerts noop workers
-The Alerts product registers two queues through `products/alerts/backend/facade/temporal.py` and the shared `start_temporal_worker` command:
+The Alerts product registers three queues through `products/alerts/backend/facade/temporal.py` and the shared `start_temporal_worker` command:
-| Setting in `posthog/settings/temporal.py` | Queue | Workflow |
-| ----------------------------------------- | -------------------------------------- | -------------------------- |
-| `ALERTS_PRODUCT_EVALUATION_TASK_QUEUE` | `alerts-product-evaluation-task-queue` | `alerts-product-check-due` |
-| `ALERTS_PRODUCT_DELIVERY_TASK_QUEUE` | `alerts-product-delivery-task-queue` | `alerts-product-deliver` |
+| Setting in `posthog/settings/temporal.py` | Queue | Workflow |
+| ------------------------------------------------ | ------------------------------------------------ | ---------------------------- |
+| `ALERTS_PRODUCT_SHARED_ORCHESTRATION_TASK_QUEUE` | `alerts-product-shared-orchestration-task-queue` | `alerts-product-orchestrate` |
+| `ALERTS_PRODUCT_EVALUATION_TASK_QUEUE` | `alerts-product-evaluation-task-queue` | `alerts-product-check-due` |
+| `ALERTS_PRODUCT_DELIVERY_TASK_QUEUE` | `alerts-product-delivery-task-queue` | `alerts-product-deliver` |
These queue names are hardcoded and stay separate even with `DEBUG=True`.
+Shared orchestration registers only the orchestration workflow, with no activities.
+Each schedule tick starts orchestration, which awaits an evaluation child on the evaluation queue.
+Evaluation runs the probe and starts its independent delivery child on the delivery queue.
Start one worker for each queue:
```bash
+python manage.py start_temporal_worker --task-queue alerts-product-shared-orchestration-task-queue --metrics-port 8104
python manage.py start_temporal_worker --task-queue alerts-product-evaluation-task-queue --metrics-port 8102
python manage.py start_temporal_worker --task-queue alerts-product-delivery-task-queue --metrics-port 8103
```
@@ -27,7 +32,8 @@ only when `CLOUD_DEPLOYMENT=DEV`. The normal deployment migration step runs this
Registration does nothing in production, local development, or other environments, even with `DEBUG=True`.
It does not delete schedules created manually in those environments.
-The schedule starts `alerts-product-check-due` with `{}` on the evaluation queue every minute (UTC).
+The schedule starts `alerts-product-orchestrate` with `{}` on the orchestration queue every minute (UTC).
+There is no routing flag: the flow is tick → orchestration → evaluation → delivery.
It uses SKIP overlap, a one-minute catchup window, a 50-second workflow execution timeout,
and one workflow attempt. Creation does not trigger an immediate run; the next minute starts it.
Delivery has no schedule: evaluation starts its delivery child.
@@ -39,22 +45,46 @@ Verify the Postgres activity result and the delivery child's completion separate
Parent completion does not prove either succeeded. Schedule creation also does not prove worker availability.
Enable production only in a separate rollout after dev verification.
-For local development, start an evaluation run by hand.
+### Shared orchestration rollout and rollback
+
+The deployment identity is `temporal-worker-alerts-product-shared-orchestration`.
+It uses the shared `posthog-cloud` image built by `container-images-cd.yml`, not a separate image build or repository.
+Worker deployment configuration lives outside this repository. Deploying this code must be coordinated with starting the orchestration worker.
+Schedule reconciliation now routes directly to orchestration; merging the code alone does not start a worker process.
+If the dev schedule does not exist yet, start all three workers before the first reconciliation: new schedules start unpaused.
+
+1. Pause the existing dev schedule before deployment so migration-time reconciliation cannot send ticks to a worker that is not ready.
+2. Deploy the code and start the orchestration worker with the command above.
+ Verify it polls `alerts-product-shared-orchestration-task-queue`, and that evaluation and delivery workers remain available.
+3. Run `python manage.py schedule_temporal_workflows` and verify the action starts `alerts-product-orchestrate` on the orchestration queue.
+ Existing pause state is preserved. Resume only after all three workers are ready, then verify the complete workflow chain.
+
+To stop future starts, pause the schedule. Keep all three workers running until orchestration, evaluation, and delivery work drains.
+For rollback, restore the previous schedule action (`alerts-product-check-due` on the evaluation queue) after draining, then roll back the code.
+Do not reconcile with the new code after restoring the old action: reconciliation would route back to orchestration.
+Pausing or changing the schedule does not move or stop queued or running workflows.
+
+### Manual local runs
+
+For local development, start an orchestration run by hand.
The `execute_temporal_workflow` and `start_temporal_workflow` commands do not know these workflows and reject the name, so use the Temporal CLI in the dev stack:
```bash
docker exec posthog-temporal-admin-tools-1 \
temporal workflow start --address temporal:7233 --namespace default \
- --task-queue alerts-product-evaluation-task-queue \
- --type alerts-product-check-due \
- --workflow-id "alerts-product-check-due-manual-$(date +%Y%m%d%H%M%S)" \
+ --task-queue alerts-product-shared-orchestration-task-queue \
+ --type alerts-product-orchestrate \
+ --workflow-id "alerts-product-orchestrate-manual-$(date +%Y%m%d%H%M%S)" \
+ --execution-timeout 50s \
--input '{}'
```
The empty `--input '{}'` becomes the empty `AlertsProductInputs`.
-Watch the evaluation run and its delivery child in the Temporal UI at <http://localhost:8081>.
+Watch orchestration, its evaluation child, and the delivery grandchild in the Temporal UI at <http://localhost:8081>.
-Both workflows accept an empty `AlertsProductInputs` dataclass.
+All three workflows accept an empty `AlertsProductInputs` dataclass.
+Orchestration awaits one evaluation child, with a 40-second execution timeout and one workflow attempt.
+The evaluation child ID includes the orchestration run ID, so each tick starts a distinct evaluation.
Evaluation runs a Postgres connectivity probe; delivery runs an empty activity with no I/O.
Each activity has a 10-second start-to-close timeout and a 30-second schedule-to-close timeout.
Evaluation has one attempt; delivery retains at most three attempts.
@@ -97,7 +127,7 @@ Verify a successful probe, statement timeout and transaction reset through the c
`SELECT 1` alone does not verify the intended database identity, application grants, schema, or write readiness.
These tests do not replace deployment verification.
-Worker registration does not deploy workers. The dev schedule sets the evaluation workflow's
+Worker registration does not deploy workers. The dev schedule sets the orchestration workflow's
50-second execution timeout; manually started workflows must set their own timeout.
## Activity logs
@@ -114,7 +144,7 @@ When a valid OpenTelemetry span is active, both events include hexadecimal `trac
The interceptor does not log inputs, headers, exception messages, or locals, and does not capture exceptions separately.
Telemetry errors cannot replace an activity's result, exception, or cancellation.
Cancellation before the activity starts still propagates; cancellation while writing its finish log cannot replace the completed activity's outcome.
-Workflow logging and workflow bodies are unchanged.
+Evaluation and delivery workflow logging are unchanged.
## Metrics
@@ -134,16 +164,16 @@ Missing finish events are not evidence of success.
## Tracing and deployment verification
-Both deployments must set `TEMPORAL_OTEL_PLUGIN_ENABLED=true`, a nonempty `OTEL_SERVICE_NAME`, and the appropriate OTLP gRPC exporter configuration.
+All three deployments must set `TEMPORAL_OTEL_PLUGIN_ENABLED=true`, a nonempty `OTEL_SERVICE_NAME`, and the appropriate OTLP gRPC exporter configuration.
For example, configure `OTEL_EXPORTER_OTLP_TRACES_ENDPOINT` for the collector and any required credentials or TLS settings.
The shared startup command initializes Temporal's replay-safe provider, and the client registers `OpenTelemetryPlugin(add_temporal_spans=True)`.
Do not add the legacy tracing interceptor or another provider.
The activity logs use the plugin's active attempt span.
-Evaluation, child delivery, and their activity spans retain their trace relationships even when delivery runs after evaluation finishes.
+Orchestration, evaluation, child delivery, and their activity spans retain their trace relationships even when delivery runs after evaluation finishes.
Retries have separate activity attempt spans.
Tests verify local logging, queue-labelled SDK metrics, and trace relationships without an application database or an external collector.
-Charts rollout must separately configure both deployments and verify Prometheus scraping and delivery to the tracing collector.
+Charts rollout must separately configure all three deployments and verify Prometheus scraping and delivery to the tracing collector.
This change does not configure deployments, dashboards, alert rules, or SLO emission.
The `alerts-product` SLO area remains reserved without changes to shared SLO handling or workflow inputs.
diff --git a/posthog/management/commands/start_temporal_worker.py b/posthog/management/commands/start_temporal_worker.py
index 9fb409a84442..5a4e91d12a28 100644
--- a/posthog/management/commands/start_temporal_worker.py
+++ b/posthog/management/commands/start_temporal_worker.py
@@ -156,6 +156,7 @@ from products.alerts.backend.facade.temporal import (
DELIVERY_WORKFLOWS as ALERTS_PRODUCT_DELIVERY_WORKFLOWS,
EVALUATION_ACTIVITIES as ALERTS_PRODUCT_EVALUATION_ACTIVITIES,
EVALUATION_WORKFLOWS as ALERTS_PRODUCT_EVALUATION_WORKFLOWS,
+ SHARED_ORCHESTRATION_WORKFLOWS as ALERTS_PRODUCT_SHARED_ORCHESTRATION_WORKFLOWS,
)
from products.batch_exports.backend.temporal import (
ACTIVITIES as BATCH_EXPORTS_ACTIVITIES,
@@ -549,6 +550,11 @@ _task_queue_specs = [
STAMPHOG_WORKFLOWS,
STAMPHOG_ACTIVITIES,
),
+ (
+ settings.ALERTS_PRODUCT_SHARED_ORCHESTRATION_TASK_QUEUE,
+ ALERTS_PRODUCT_SHARED_ORCHESTRATION_WORKFLOWS,
+ [],
+ ),
(
settings.ALERTS_PRODUCT_EVALUATION_TASK_QUEUE,
ALERTS_PRODUCT_EVALUATION_WORKFLOWS,
diff --git a/posthog/management/commands/test/test_start_temporal_worker.py b/posthog/management/commands/test/test_start_temporal_worker.py
index c3691c4a4e0a..e4ecb88c2aa3 100644
--- a/posthog/management/commands/test/test_start_temporal_worker.py
+++ b/posthog/management/commands/test/test_start_temporal_worker.py
@@ -20,6 +20,7 @@ from products.alerts.backend.facade.temporal import (
DELIVERY_WORKFLOWS,
EVALUATION_ACTIVITIES,
EVALUATION_WORKFLOWS,
+ SHARED_ORCHESTRATION_WORKFLOWS,
)
from products.wizard.backend.facade.temporal import (
ACTIVITIES as WIZARD_ACTIVITIES,
@@ -35,6 +36,7 @@ class _NotADataSyncWorkflow:
"task_queue,expected_workflows,expected_activities",
[
(settings.WIZARD_TASK_QUEUE, WIZARD_WORKFLOWS, WIZARD_ACTIVITIES),
+ ("alerts-product-shared-orchestration-task-queue", SHARED_ORCHESTRATION_WORKFLOWS, []),
("alerts-product-evaluation-task-queue", EVALUATION_WORKFLOWS, EVALUATION_ACTIVITIES),
("alerts-product-delivery-task-queue", DELIVERY_WORKFLOWS, DELIVERY_ACTIVITIES),
],
@@ -43,9 +45,14 @@ def test_queue_registers_workflows_and_activities(
task_queue: str, expected_workflows: Sequence[type], expected_activities: Sequence[Callable[..., object]]
) -> None:
assert expected_workflows
- assert expected_activities
assert set(expected_workflows) <= WORKFLOWS_DICT[task_queue]
- assert set(expected_activities) <= ACTIVITIES_DICT[task_queue]
+ if task_queue == settings.ALERTS_PRODUCT_SHARED_ORCHESTRATION_TASK_QUEUE:
+ assert WORKFLOWS_DICT[task_queue] == set(expected_workflows)
+ assert not expected_activities
+ assert not ACTIVITIES_DICT[task_queue]
+ else:
+ assert expected_activities
+ assert set(expected_activities) <= ACTIVITIES_DICT[task_queue]
# Data-import sources import vendor SDKs (google-ads, etc.) that register protobuf descriptors into a
diff --git a/posthog/settings/temporal.py b/posthog/settings/temporal.py
index ae97a84a8d30..47516b85c79a 100644
--- a/posthog/settings/temporal.py
+++ b/posthog/settings/temporal.py
@@ -265,7 +265,8 @@ TEST_TASK_QUEUE = _set_temporal_task_queue("test-task-queue")
BILLING_TASK_QUEUE = _set_temporal_task_queue("billing-task-queue")
VIDEO_EXPORT_TASK_QUEUE = _set_temporal_task_queue("video-export-task-queue")
ANALYTICS_PLATFORM_TASK_QUEUE = _set_temporal_task_queue("analytics-platform-task-queue")
-# Keep the two noop fleets separate in local development as well as deployed environments.
+# Keep the smoke fleets separate in local development as well as deployed environments.
+ALERTS_PRODUCT_SHARED_ORCHESTRATION_TASK_QUEUE = "alerts-product-shared-orchestration-task-queue"
ALERTS_PRODUCT_EVALUATION_TASK_QUEUE = "alerts-product-evaluation-task-queue"
ALERTS_PRODUCT_DELIVERY_TASK_QUEUE = "alerts-product-delivery-task-queue"
SESSION_REPLAY_TASK_QUEUE = _set_temporal_task_queue("session-replay-task-queue")
diff --git a/products/alerts/backend/facade/temporal.py b/products/alerts/backend/facade/temporal.py
index 3121192308f2..360d48ce2cbe 100644
--- a/products/alerts/backend/facade/temporal.py
+++ b/products/alerts/backend/facade/temporal.py
@@ -5,6 +5,7 @@ from products.alerts.backend.temporal.workflows import (
DELIVERY_WORKFLOWS,
EVALUATION_ACTIVITIES,
EVALUATION_WORKFLOWS,
+ SHARED_ORCHESTRATION_WORKFLOWS,
)
__all__ = [
@@ -12,6 +13,7 @@ __all__ = [
"DELIVERY_WORKFLOWS",
"EVALUATION_ACTIVITIES",
"EVALUATION_WORKFLOWS",
+ "SHARED_ORCHESTRATION_WORKFLOWS",
"AlertsProductTelemetryInterceptor",
"create_alerts_product_check_due_schedule",
]
diff --git a/products/alerts/backend/temporal/schedule.py b/products/alerts/backend/temporal/schedule.py
index 12f7fbd3a625..763485c1b0b6 100644
--- a/products/alerts/backend/temporal/schedule.py
+++ b/products/alerts/backend/temporal/schedule.py
@@ -20,10 +20,10 @@ async def create_alerts_product_check_due_schedule(client: "Client") -> None:
schedule = Schedule(
action=ScheduleActionStartWorkflow(
- "alerts-product-check-due",
+ "alerts-product-orchestrate",
{},
id=SCHEDULE_ID,
- task_queue=settings.ALERTS_PRODUCT_EVALUATION_TASK_QUEUE,
+ task_queue=settings.ALERTS_PRODUCT_SHARED_ORCHESTRATION_TASK_QUEUE,
execution_timeout=dt.timedelta(seconds=50),
retry_policy=RetryPolicy(maximum_attempts=1),
),
diff --git a/products/alerts/backend/temporal/workflows.py b/products/alerts/backend/temporal/workflows.py
index 560818f45cd5..d5ad87039c0d 100644
--- a/products/alerts/backend/temporal/workflows.py
+++ b/products/alerts/backend/temporal/workflows.py
@@ -60,6 +60,7 @@ class AlertsProductCheckDueWorkflow(PostHogWorkflow):
try:
await workflow.execute_activity(
alerts_product_check_due_activity,
+ task_queue=settings.ALERTS_PRODUCT_EVALUATION_TASK_QUEUE,
start_to_close_timeout=dt.timedelta(seconds=10),
schedule_to_close_timeout=dt.timedelta(seconds=30),
retry_policy=RetryPolicy(maximum_attempts=1),
@@ -85,6 +86,23 @@ class AlertsProductCheckDueWorkflow(PostHogWorkflow):
)
[email protected](name="alerts-product-orchestrate")
+class AlertsProductOrchestrateWorkflow(PostHogWorkflow):
+ inputs_cls = AlertsProductInputs
+
+ @workflow.run
+ async def run(self, inputs: AlertsProductInputs) -> None:
+ await workflow.execute_child_workflow(
+ AlertsProductCheckDueWorkflow.run,
+ inputs,
+ id=f"alerts-product-check-due-{workflow.info().run_id}",
+ task_queue=settings.ALERTS_PRODUCT_EVALUATION_TASK_QUEUE,
+ execution_timeout=dt.timedelta(seconds=40),
+ retry_policy=RetryPolicy(maximum_attempts=1),
+ )
+
+
+SHARED_ORCHESTRATION_WORKFLOWS = [AlertsProductOrchestrateWorkflow]
EVALUATION_WORKFLOWS = [AlertsProductCheckDueWorkflow]
EVALUATION_ACTIVITIES = [alerts_product_check_due_activity]
DELIVERY_WORKFLOWS = [AlertsProductDeliverWorkflow]
diff --git a/products/alerts/backend/tests/test_temporal_schedule.py b/products/alerts/backend/tests/test_temporal_schedule.py
index 427079021bf2..7c22c0ba7758 100644
--- a/products/alerts/backend/tests/test_temporal_schedule.py
+++ b/products/alerts/backend/tests/test_temporal_schedule.py
@@ -38,7 +38,10 @@ async def test_dev_schedule_creates_or_updates_with_bounded_policy(already_exist
return_value=MagicMock(schedule=MagicMock(state=state))
)
with (
- override_settings(CLOUD_DEPLOYMENT="DEV", ALERTS_PRODUCT_EVALUATION_TASK_QUEUE="evaluation-test-queue"),
+ override_settings(
+ CLOUD_DEPLOYMENT="DEV",
+ ALERTS_PRODUCT_SHARED_ORCHESTRATION_TASK_QUEUE="orchestration-test-queue",
+ ),
patch(f"{MODULE}.a_schedule_exists", return_value=already_exists) as exists,
patch(f"{MODULE}.a_create_schedule") as create,
patch(f"{MODULE}.a_update_schedule") as update,
@@ -56,10 +59,10 @@ async def test_dev_schedule_creates_or_updates_with_bounded_policy(already_exist
schedule = called.await_args.args[2]
action = schedule.action
assert isinstance(action, ScheduleActionStartWorkflow)
- assert action.workflow == "alerts-product-check-due"
+ assert action.workflow == "alerts-product-orchestrate"
assert list(action.args) == [{}]
assert action.id == SCHEDULE_ID
- assert action.task_queue == "evaluation-test-queue"
+ assert action.task_queue == "orchestration-test-queue"
assert action.execution_timeout == dt.timedelta(seconds=50)
assert action.retry_policy is not None
assert action.retry_policy.maximum_attempts == 1
diff --git a/products/alerts/backend/tests/test_temporal_workflows.py b/products/alerts/backend/tests/test_temporal_workflows.py
index 0eccd5083f11..4f24304ffeeb 100644
--- a/products/alerts/backend/tests/test_temporal_workflows.py
+++ b/products/alerts/backend/tests/test_temporal_workflows.py
@@ -35,6 +35,7 @@ from products.alerts.backend.facade.temporal import (
DELIVERY_WORKFLOWS,
EVALUATION_ACTIVITIES,
EVALUATION_WORKFLOWS,
+ SHARED_ORCHESTRATION_WORKFLOWS,
AlertsProductTelemetryInterceptor,
)
from products.alerts.backend.temporal import postgres
@@ -78,6 +79,13 @@ def postgres_cursor() -> Iterator[MagicMock]:
@pytest.mark.asyncio
@pytest.mark.parametrize("database_error", [False, True])
+ "tick_workflow, tick_queue",
+ [
+ ("alerts-product-check-due", settings.ALERTS_PRODUCT_EVALUATION_TASK_QUEUE),
+ ("alerts-product-orchestrate", settings.ALERTS_PRODUCT_SHARED_ORCHESTRATION_TASK_QUEUE),
+ ],
+)
async def test_each_tick_starts_independent_delivery(
environment: WorkflowEnvironment,
caplog: pytest.LogCaptureFixture,
@@ -86,6 +94,8 @@ async def test_each_tick_starts_independent_delivery(
activity_logs,
postgres_cursor: MagicMock,
database_error: bool,
+ tick_workflow: str,
+ tick_queue: str,
) -> None:
if database_error:
postgres_cursor.execute.side_effect = OperationalError("sensitive connection details")
@@ -102,30 +112,62 @@ async def test_each_tick_starts_independent_delivery(
if activity.info().attempt == 1:
raise ApplicationError("sensitive retry exception")
- async with Worker(
- client,
- task_queue=settings.ALERTS_PRODUCT_EVALUATION_TASK_QUEUE,
- workflows=EVALUATION_WORKFLOWS,
- activities=EVALUATION_ACTIVITIES,
- interceptors=[AlertsProductTelemetryInterceptor()],
- workflow_runner=UnsandboxedWorkflowRunner(),
+ async with (
+ Worker(
+ client,
+ task_queue=settings.ALERTS_PRODUCT_SHARED_ORCHESTRATION_TASK_QUEUE,
+ workflows=SHARED_ORCHESTRATION_WORKFLOWS,
+ workflow_runner=UnsandboxedWorkflowRunner(),
+ ),
+ Worker(
+ client,
+ task_queue=settings.ALERTS_PRODUCT_EVALUATION_TASK_QUEUE,
+ workflows=EVALUATION_WORKFLOWS,
+ activities=EVALUATION_ACTIVITIES,
+ interceptors=[AlertsProductTelemetryInterceptor()],
+ workflow_runner=UnsandboxedWorkflowRunner(),
+ ),
):
for _ in range(2):
parent = await client.start_workflow(
- "alerts-product-check-due",
+ tick_workflow,
AlertsProductInputs(),
id=workflow_id,
- task_queue=settings.ALERTS_PRODUCT_EVALUATION_TASK_QUEUE,
+ task_queue=tick_queue,
execution_timeout=dt.timedelta(seconds=10),
)
assert await parent.result() is None
history = await parent.fetch_history()
+ evaluation_run_id = parent.first_execution_run_id
+ if tick_workflow == "alerts-product-orchestrate":
+ assert not any(
+ event.event_type == EventType.EVENT_TYPE_ACTIVITY_TASK_SCHEDULED for event in history.events
+ )
+ evaluations = [
+ event.start_child_workflow_execution_initiated_event_attributes
+ for event in history.events
+ if event.event_type == EventType.EVENT_TYPE_START_CHILD_WORKFLOW_EXECUTION_INITIATED
+ ]
+ assert len(evaluations) == 1
+ evaluation_event = evaluations[0]
+ assert evaluation_event.workflow_type.name == "alerts-product-check-due"
+ assert evaluation_event.task_queue.name == settings.ALERTS_PRODUCT_EVALUATION_TASK_QUEUE
+ assert evaluation_event.workflow_execution_timeout.ToTimedelta() == dt.timedelta(seconds=40)
+ assert evaluation_event.retry_policy.maximum_attempts == 1
+ assert parent.first_execution_run_id is not None
+ assert parent.first_execution_run_id in evaluation_event.workflow_id
+ evaluation_handle = client.get_workflow_handle(evaluation_event.workflow_id)
+ evaluation_description = await evaluation_handle.describe()
+ assert evaluation_description.status == WorkflowExecutionStatus.COMPLETED
+ evaluation_run_id = evaluation_description.run_id
+ history = await evaluation_handle.fetch_history()
scheduled = [
event.activity_task_scheduled_event_attributes
for event in history.events
if event.event_type == EventType.EVENT_TYPE_ACTIVITY_TASK_SCHEDULED
]
assert len(scheduled) == 1
+ assert scheduled[0].task_queue.name == settings.ALERTS_PRODUCT_EVALUATION_TASK_QUEUE
assert scheduled[0].retry_policy.maximum_attempts == 1
failure_count = sum(
event.event_type == EventType.EVENT_TYPE_ACTIVITY_TASK_FAILED for event in history.events
@@ -139,8 +181,8 @@ async def test_each_tick_starts_independent_delivery(
]
assert len(children) == 1
child_id = children[0].workflow_execution.workflow_id
- assert parent.first_execution_run_id is not None
- assert parent.first_execution_run_id in child_id
+ assert evaluation_run_id is not None
+ assert evaluation_run_id in child_id
assert children[0].workflow_type.name == "alerts-product-deliver"
child_ids.add(child_id)
child_description = await client.get_workflow_handle(child_id).describe()
@@ -168,6 +210,7 @@ async def test_each_tick_starts_independent_delivery(
if event.event_type == EventType.EVENT_TYPE_ACTIVITY_TASK_SCHEDULED
]
assert len(scheduled) == 1
+ assert scheduled[0].task_queue.name == settings.ALERTS_PRODUCT_DELIVERY_TASK_QUEUE
assert scheduled[0].retry_policy.maximum_attempts == 3
updates = sdk_metrics.retrieve_updates()
@@ -189,7 +232,7 @@ async def test_each_tick_starts_independent_delivery(
assert len(spans_by_id) == len(spans)
workflow_spans = [span for span in spans if span.name.startswith("RunWorkflow:")]
activity_spans = [span for span in spans if span.name.startswith("RunActivity:")]
- assert len(workflow_spans) == 4
+ assert len(workflow_spans) == (6 if tick_workflow == "alerts-product-orchestrate" else 4)
assert len(activity_spans) == 6
for delivery in (span for span in workflow_spans if span.name == "RunWorkflow:alerts-product-deliver"):
assert delivery.parent is not None
@@ -201,6 +244,14 @@ async def test_each_tick_starts_independent_delivery(
assert delivery.context.trace_id == child_start.context.trace_id == evaluation.context.trace_id
assert evaluation.end_time is not None and delivery.start_time is not None
assert evaluation.end_time <= delivery.start_time
+ if tick_workflow == "alerts-product-orchestrate":
+ assert evaluation.parent is not None
+ evaluation_start = spans_by_id[evaluation.parent.span_id]
+ assert evaluation_start.name == "StartChildWorkflow:alerts-product-check-due"
+ assert evaluation_start.parent is not None
+ orchestration = spans_by_id[evaluation_start.parent.span_id]
+ assert orchestration.name == "RunWorkflow:alerts-product-orchestrate"
+ assert evaluation.context.trace_id == evaluation_start.context.trace_id == orchestration.context.trace_id
for attempt_span in activity_spans:
assert attempt_span.parent is not None
activity_start = spans_by_id[attempt_span.parent.span_id]