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.

fix(data-warehouse): drop per-team labels from consumer batch metrics (#83786)

estefania0429be5ae989
diff --git a/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline_v3/batch_consumer.py b/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline_v3/batch_consumer.py
index 01c455977490..310cc046b07c 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline_v3/batch_consumer.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline_v3/batch_consumer.py
@@ -837,8 +837,6 @@ class BatchConsumer:
Binds structlog contextvars so every downstream log line (including loader calls)
routes to log_entries under the right schema/workflow before any logger fires.
"""
- team_id = str(batch.team_id)
- schema_id = batch.schema_id
attempt = batch.latest_attempt + 1
workflow_id = batch.metadata.get("workflow_id") or ""
@@ -880,7 +878,7 @@ class BatchConsumer:
# cumulative TTL and get abandoned mid-group. The pre-commit check in
# _process_single_inner stays a fail-closed verify.
await self._renew_ownership(lock_conn, batch)
- return await self._process_single_inner(batch, attempt, team_id, schema_id, lock_conn)
+ return await self._process_single_inner(batch, attempt, lock_conn)
finally:
self._inflight_started.pop(batch.id, None)
structlog.contextvars.unbind_contextvars(*bound_keys)
@@ -889,8 +887,6 @@ class BatchConsumer:
self,
batch: PendingBatch,
attempt: int,
- team_id: str,
- schema_id: str,
lock_conn: psycopg.AsyncConnection[Any] | None = None,
) -> bool:
if attempt > self._config.max_attempts:
@@ -931,9 +927,7 @@ class BatchConsumer:
batch_id=batch.id,
run_uuid=batch.run_uuid,
)
- self._metrics.batches_processed_total.labels(
- team_id=team_id, schema_id=schema_id, status="skipped"
- ).inc()
+ self._metrics.batches_processed_total.labels(status="skipped").inc()
return False
# Pre-increment: if we OOM during processing, recovery sees attempt=N+1
@@ -965,9 +959,7 @@ class BatchConsumer:
await self._adapter.after_batch_processed(status_conn, batch=batch)
duration = time.monotonic() - start
- self._metrics.batch_processing_duration_seconds.labels(team_id=team_id, schema_id=schema_id).observe(
- duration
- )
+ self._metrics.batch_processing_duration_seconds.observe(duration)
await self._verify_ownership(lock_conn, batch)
await self._adapter.update_status(
@@ -977,7 +969,7 @@ class BatchConsumer:
attempt=attempt,
batch_created_at=batch.created_at,
)
- self._metrics.batches_processed_total.labels(team_id=team_id, schema_id=schema_id, status="success").inc()
+ self._metrics.batches_processed_total.labels(status="success").inc()
logger.info(
self._event("batch_processed_ok"),
batch_id=batch.id,
@@ -990,7 +982,7 @@ class BatchConsumer:
except OwnershipLostError:
raise
except Exception as err:
- self._metrics.batches_processed_total.labels(team_id=team_id, schema_id=schema_id, status="error").inc()
+ self._metrics.batches_processed_total.labels(status="error").inc()
self._metrics.batch_retry_total.labels(attempt=str(attempt), error_type=type(err).__name__).inc()
await self._handle_batch_failure(batch, attempt, err, lock_conn=lock_conn, status_conn=status_conn)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline_v3/postgres_queue/metrics.py b/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline_v3/postgres_queue/metrics.py
index 427b0b8cd7a5..ded54b7c8c19 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline_v3/postgres_queue/metrics.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline_v3/postgres_queue/metrics.py
@@ -13,16 +13,18 @@ from prometheus_client import Counter, Gauge, Histogram
# merely slow one — p95 sat "pinned at 5s" while real polls took minutes.
POLL_DURATION_BUCKETS = (0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0, 2.5, 5.0, 15.0, 60.0, 150.0, 300.0)
+# Deliberately not labeled by team/schema: every (team, schema) combo mints
+# series forever (12 per combo on the histogram), and no dashboard or alert
+# reads them. Per-team debugging belongs in the structured logs.
BATCHES_PROCESSED_TOTAL = Counter(
"warehouse_pg_consumer_batches_processed_total",
"Total batches processed by the Postgres consumer",
- labelnames=["team_id", "schema_id", "status"],
+ labelnames=["status"],
)
BATCH_PROCESSING_DURATION_SECONDS = Histogram(
"warehouse_pg_consumer_batch_processing_duration_seconds",
"Duration of individual batch processing",
- labelnames=["team_id", "schema_id"],
buckets=(0.5, 1.0, 2.5, 5.0, 10.0, 30.0, 60.0, 120.0, 300.0, 600.0),
)
@@ -209,12 +211,11 @@ def make_consumer_metrics(prefix: str) -> ConsumerMetrics:
batches_processed_total=Counter(
f"{p}_batches_processed_total",
f"Total batches processed by the {prefix} Postgres consumer",
- labelnames=["team_id", "schema_id", "status"],
+ labelnames=["status"],
),
batch_processing_duration_seconds=Histogram(
f"{p}_batch_processing_duration_seconds",
"Duration of individual batch processing",
- labelnames=["team_id", "schema_id"],
buckets=(0.5, 1.0, 2.5, 5.0, 10.0, 30.0, 60.0, 120.0, 300.0, 600.0),
),
batch_retry_total=Counter(