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.

refactor(alerts): name the configuration a delivery preview carries (#109606)

Jimmy Zhu19173ef54695
diff --git a/products/alerts/backend/facade/contracts.py b/products/alerts/backend/facade/contracts.py
index 8c339fe443fc..7e95314635a1 100644
--- a/products/alerts/backend/facade/contracts.py
+++ b/products/alerts/backend/facade/contracts.py
@@ -243,13 +243,13 @@ class GroupTransition:
class AlertDeliveryPreview:
"""What delivery would send. The PoC records it instead of contacting a destination.
- `alert_id` is the configuration's id, which a history row carries as `configuration_id`, not
- as its own `alert_id` column. A delivery addresses its rows by that column, the transition's
- `grouping_key` and `evaluation_key` together; joining on the row's `alert_id` finds nothing.
+ A delivery addresses its history rows by `configuration_id`, the transition's `grouping_key`
+ and `evaluation_key` together. The rows also carry an `alert_id`, which is the
+ `PlatformAlert` instance rather than the configuration, so nothing here is joined to it.
"""
source: SourceKind
- alert_id: str
+ configuration_id: str
alert_name: str
evaluation_key: str
destination_names: tuple[str, ...]
diff --git a/products/alerts/backend/temporal/workflows.py b/products/alerts/backend/temporal/workflows.py
index d66806d36d41..02dab365fd78 100644
--- a/products/alerts/backend/temporal/workflows.py
+++ b/products/alerts/backend/temporal/workflows.py
@@ -98,7 +98,7 @@ async def alerts_platform_deliver_preview_activity(preview: AlertDeliveryPreview
await LOGGER.ainfo(
"alerts_platform_delivery_preview",
source=preview.source.value,
- alert_id=preview.alert_id,
+ configuration_id=preview.configuration_id,
alert_name=preview.alert_name,
evaluation_key=preview.evaluation_key,
destinations=list(preview.destination_names),
diff --git a/products/logs/backend/alert_source_cycle.py b/products/logs/backend/alert_source_cycle.py
index f55d34552e72..625ec56e366c 100644
--- a/products/logs/backend/alert_source_cycle.py
+++ b/products/logs/backend/alert_source_cycle.py
@@ -306,10 +306,10 @@ def _delivery(
)
return recorded, AlertDeliveryPreview(
source=SourceKind.LOGS,
- alert_id=str(check.id),
+ configuration_id=str(check.id),
alert_name=check.name,
# The recorded key unchanged, so a delivery can address the row the check wrote. The
- # workflow id that has to be unique across alerts joins this to `alert_id` itself.
+ # workflow id that has to be unique across alerts joins this to the configuration itself.
evaluation_key=recorded.evaluation_key,
destination_names=tuple(destination.name for destination in destinations),
# One transition with an empty grouping key. Logs does not group yet, and delivery
diff --git a/products/logs/backend/temporal/alert_evaluate.py b/products/logs/backend/temporal/alert_evaluate.py
index ff4983aa4e71..5cb6376e0318 100644
--- a/products/logs/backend/temporal/alert_evaluate.py
+++ b/products/logs/backend/temporal/alert_evaluate.py
@@ -104,7 +104,7 @@ class LogsAlertEvaluateWorkflow(PostHogWorkflow):
workflow.start_child_workflow(
"alerts-platform-deliver-preview",
preview,
- id=f"alerts-deliver-preview-{preview.alert_id}:{preview.evaluation_key}",
+ id=f"alerts-deliver-preview-{preview.configuration_id}:{preview.evaluation_key}",
task_queue=settings.ALERTS_PLATFORM_DELIVERY_TASK_QUEUE,
parent_close_policy=workflow.ParentClosePolicy.ABANDON,
execution_timeout=dt.timedelta(minutes=1),