: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(experiments): emit recalculation metrics on the activity task queue (#118812)
Rodrigo Ilorob3b78b8704fe
diff --git a/products/experiments/backend/temporal/recalculation_metrics.py b/products/experiments/backend/temporal/recalculation_metrics.pyindex 619f975c4966..f3cb318f836e 100644--- a/products/experiments/backend/temporal/recalculation_metrics.py+++ b/products/experiments/backend/temporal/recalculation_metrics.py@@ -208,8 +208,12 @@ class ExperimentsRecalculationMetricsInterceptor(Interceptor):# Required by `is_task_queue_supported` in `posthog/temporal/common/interceptor.py` — without this attribute# the interceptor is filtered out of every worker and the metrics never emit. The recalc workflow + activities- # are registered on this queue in `posthog/management/commands/start_temporal_worker.py`.- task_queue = settings.EXPERIMENTS_RECALCULATION_TASK_QUEUE+ # run on the first queue, and the metric calculation activity also runs on the second. Both registrations are in+ # `posthog/management/commands/start_temporal_worker.py`.+ task_queue = (+ settings.EXPERIMENTS_RECALCULATION_TASK_QUEUE,+ settings.EXPERIMENTS_RECALCULATION_ACTIVITY_TASK_QUEUE,+ )def intercept_activity(self, next: ActivityInboundInterceptor) -> ActivityInboundInterceptor:return _ActivityInboundInterceptor(super().intercept_activity(next))diff --git a/products/experiments/backend/temporal/test_recalculation_metrics.py b/products/experiments/backend/temporal/test_recalculation_metrics.pyindex 499ce190fee0..7b710a73abc3 100644--- a/products/experiments/backend/temporal/test_recalculation_metrics.py+++ b/products/experiments/backend/temporal/test_recalculation_metrics.py@@ -45,6 +45,11 @@ def test_registered_on_recalculation_queue():assert is_task_queue_supported(settings.EXPERIMENTS_RECALCULATION_TASK_QUEUE, ExperimentsRecalculationMetricsInterceptor)+ # Both queue names alias to one value in test settings, so only the tuple shows a missing activity queue.+ assert ExperimentsRecalculationMetricsInterceptor.task_queue == (+ settings.EXPERIMENTS_RECALCULATION_TASK_QUEUE,+ settings.EXPERIMENTS_RECALCULATION_ACTIVITY_TASK_QUEUE,+ )@parameterized.expand(