: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
chore(tasks): resolve 10s to 60s in temporal activity latency histograms (#104325)
Alessandro Pogliaghi3b51253788c4
diff --git a/posthog/temporal/common/worker.py b/posthog/temporal/common/worker.pyindex 1b477e5d3dce..198e73267be6 100644--- a/posthog/temporal/common/worker.py+++ b/posthog/temporal/common/worker.py@@ -91,6 +91,8 @@ from products.tasks.backend.facade.temporal import (TASKS_RUN_TOKENS_HISTOGRAM_METRICS,TASKS_RUN_TURNS_HISTOGRAM_BUCKETS,TASKS_RUN_TURNS_HISTOGRAM_METRICS,+ TASKS_SDK_LATENCY_HISTOGRAM_BUCKETS,+ TASKS_SDK_LATENCY_HISTOGRAM_METRICS,)logger = get_write_only_logger()@@ -374,6 +376,13 @@ async def create_worker(itertools.repeat(DATA_MODELING_LATENCY_HISTOGRAM_BUCKETS),))+ if task_queue == settings.TASKS_TASK_QUEUE:+ histogram_bucket_overrides |= dict(+ zip(+ TASKS_SDK_LATENCY_HISTOGRAM_METRICS,+ itertools.repeat(TASKS_SDK_LATENCY_HISTOGRAM_BUCKETS),+ )+ )runtime = Runtime(telemetry=TelemetryConfig(diff --git a/products/tasks/backend/facade/temporal.py b/products/tasks/backend/facade/temporal.pyindex aa4bef0d5406..34239a1bf73c 100644--- a/products/tasks/backend/facade/temporal.py+++ b/products/tasks/backend/facade/temporal.py@@ -25,6 +25,8 @@ from products.tasks.backend.temporal.metrics import (TASKS_RUN_TOKENS_HISTOGRAM_METRICS,TASKS_RUN_TURNS_HISTOGRAM_BUCKETS,TASKS_RUN_TURNS_HISTOGRAM_METRICS,+ TASKS_SDK_LATENCY_HISTOGRAM_BUCKETS,+ TASKS_SDK_LATENCY_HISTOGRAM_METRICS,)from products.tasks.backend.temporal.process_task.activities.post_slack_update import (PostSlackUpdateInput,@@ -42,6 +44,8 @@ __all__ = ["TASKS_RUN_TOKENS_HISTOGRAM_METRICS","TASKS_RUN_TURNS_HISTOGRAM_BUCKETS","TASKS_RUN_TURNS_HISTOGRAM_METRICS",+ "TASKS_SDK_LATENCY_HISTOGRAM_BUCKETS",+ "TASKS_SDK_LATENCY_HISTOGRAM_METRICS","WORKFLOWS","PostSlackUpdateInput","ProcessTaskWorkflow",diff --git a/products/tasks/backend/temporal/metrics.py b/products/tasks/backend/temporal/metrics.pyindex 5f07ff5065b4..4083ffed8df0 100644--- a/products/tasks/backend/temporal/metrics.py+++ b/products/tasks/backend/temporal/metrics.py@@ -38,6 +38,37 @@ TASKS_LATENCY_HISTOGRAM_BUCKETS = [3_600_000.0,]+TASKS_SDK_LATENCY_HISTOGRAM_METRICS = (+ "temporal_activity_execution_latency",+ "temporal_activity_schedule_to_start_latency",+ "temporal_workflow_task_execution_latency",+)+TASKS_SDK_LATENCY_HISTOGRAM_BUCKETS = [+ 1.0,+ 10.0,+ 20.0,+ 50.0,+ 100.0,+ 200.0,+ 250.0,+ 500.0,+ 1_000.0,+ 2_500.0,+ 5_000.0,+ 10_000.0,+ 15_000.0,+ 20_000.0,+ 30_000.0,+ 45_000.0,+ 60_000.0,+ 90_000.0,+ 120_000.0,+ 180_000.0,+ 300_000.0,+ 600_000.0,+ 1_000_000.0,+]+TASKS_LAUNCH_PREPARATION_HISTOGRAM_METRICS = ("tasks_modal_launch_preparation_latency",)TASKS_LAUNCH_PREPARATION_HISTOGRAM_BUCKETS = [100.0,