: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(ingestion): surface batch splits in debug API and control plane UI (#74543)
José Sequeirae33980618da4
diff --git a/rust/ingestion-consumer/src/debug_recorder.rs b/rust/ingestion-consumer/src/debug_recorder.rsindex 8d984790486d..192bd1b34374 100644--- a/rust/ingestion-consumer/src/debug_recorder.rs+++ b/rust/ingestion-consumer/src/debug_recorder.rs@@ -100,6 +100,16 @@ pub enum DebugEventKind {attempt: u32,reason: &'static str,},+ /// A sub-batch was split into size-bounded chunks before sending+ /// (`reason`: size_estimate — the pre-send estimate exceeded the body cap —+ /// or http_413 — the worker rejected a chunk and it was halved).+ SendSplit {+ worker: String,+ batch_id: String,+ reason: &'static str,+ chunks: usize,+ messages: usize,+ },/// A send exhausted its retries; the messages are deferred for replay.SendExhausted {worker: String,diff --git a/rust/ingestion-consumer/src/transport.rs b/rust/ingestion-consumer/src/transport.rsindex 386e34545e33..ee93c817fdc2 100644--- a/rust/ingestion-consumer/src/transport.rs+++ b/rust/ingestion-consumer/src/transport.rs@@ -249,6 +249,7 @@ impl HttpTransport {// worker. The guard decrements the gauge on every return path.let _in_flight = InFlightGuard::new(worker_url);+ let message_total = messages.len();let mut queue: VecDeque<Vec<SerializedKafkaMessage>> =split_by_size(messages, self.max_body_bytes).into();if queue.len() > 1 {@@ -257,6 +258,13 @@ impl HttpTransport {"reason" => "size_estimate").increment((queue.len() - 1) as u64);+ record_if(&self.debug_recorder, || DebugEventKind::SendSplit {+ worker: worker_url.to_string(),+ batch_id: batch_id.to_string(),+ reason: "size_estimate",+ chunks: queue.len(),+ messages: message_total,+ });}let mut sent: Vec<SerializedKafkaMessage> = Vec::new();@@ -276,6 +284,13 @@ impl HttpTransport {"reason" => "http_413").increment(1);+ record_if(&self.debug_recorder, || DebugEventKind::SendSplit {+ worker: worker_url.to_string(),+ batch_id: batch_id.to_string(),+ reason: "http_413",+ chunks: 2,+ messages: messages.len(),+ });let mut left = messages;let right = left.split_off(left.len() / 2);queue.push_front(right);diff --git a/rust/ingestion-control-plane/src/ui/consumer_debug.html b/rust/ingestion-control-plane/src/ui/consumer_debug.htmlindex 683583ae1a96..3c2dda0ab306 100644--- a/rust/ingestion-control-plane/src/ui/consumer_debug.html+++ b/rust/ingestion-control-plane/src/ui/consumer_debug.html@@ -338,7 +338,7 @@let b = batches[id];if (!b) {b = { id, ts: null, messages: 0, distinct_ids: 0, partitions: [],- assigned: [], flushed: [], deferred: [], retries: [], exhausted: [],+ assigned: [], flushed: [], deferred: [], retries: [], exhausted: [], splits: [],committed: null, events: [] };batches[id] = b;batchOrder.push(id);@@ -361,6 +361,7 @@case "Deferred": b.deferred.push({ reason: ev.reason, groups: ev.groups, ts: ev.ts_ms }); break;case "DeferredFlushed": ev.sub_batches.forEach((s) => b.flushed.push({ ...s, ts: ev.ts_ms })); break;case "SendRetry": b.retries.push({ worker: ev.worker, attempt: ev.attempt, reason: ev.reason, ts: ev.ts_ms }); break;+ case "SendSplit": b.splits.push({ worker: ev.worker, reason: ev.reason, chunks: ev.chunks, messages: ev.messages, ts: ev.ts_ms }); break;case "SendExhausted": b.exhausted.push({ worker: ev.worker, error: ev.error, ts: ev.ts_ms }); break;case "BatchCommitted":b.committed = { accepted: ev.accepted, duration_ms: ev.duration_ms, partitions: ev.partitions, ts: ev.ts_ms };@@ -419,6 +420,7 @@case "BatchCommitted": return ["good", `✓ committed batch <code>${shortId(ev.batch_id)}</code> — ${ev.accepted} msgs in ${ev.duration_ms}ms`];case "BatchFailed": return ["error", `✗ batch failed — ${ev.error}`];case "SendRetry": return ["warn", `↻ retry #${ev.attempt} [${ev.reason}] — ${shortWorker(ev.worker)}, batch <code>${shortId(ev.batch_id)}</code>`];+ case "SendSplit": return ["warn", `✂ split [${ev.reason}] — ${ev.messages} msgs → ${ev.chunks} chunk(s), ${shortWorker(ev.worker)}, batch <code>${shortId(ev.batch_id)}</code>`];case "SendExhausted": return ["error", `✗ send exhausted — ${shortWorker(ev.worker)}: ${ev.error}`];case "WorkerStateChanged": return [ev.to === "unhealthy" ? "error" : ev.to === "healthy" ? "good" : "warn", `worker ${shortWorker(ev.worker)} ${ev.from} → ${ev.to}`];case "WorkerMembership": return ["accent", `worker ${shortWorker(ev.worker)} ${ev.action}`];@@ -464,10 +466,11 @@function workerAgg(b) {const m = {};- const touch = (w) => (m[w] = m[w] || { worker: w, messages: 0, assignedMsgs: 0, flushedMsgs: 0, flushCount: 0, retries: 0, flushed: false, exhausted: false });+ const touch = (w) => (m[w] = m[w] || { worker: w, messages: 0, assignedMsgs: 0, flushedMsgs: 0, flushCount: 0, retries: 0, splits: 0, flushed: false, exhausted: false });b.assigned.forEach((s) => { const x = touch(s.worker); x.messages += s.messages; x.assignedMsgs += s.messages; });b.flushed.forEach((s) => { const x = touch(s.worker); x.messages += s.messages; x.flushedMsgs += s.messages; x.flushed = true; x.flushCount += 1; });b.retries.forEach((r) => (touch(r.worker).retries += 1));+ b.splits.forEach((s) => (touch(s.worker).splits += 1));b.exhausted.forEach((e) => (touch(e.worker).exhausted = true));return Object.values(m);}@@ -492,6 +495,7 @@badges.push(`<span class="badge-min">${workers.length}w</span>`);const retries = b.retries.length;if (retries) badges.push(`<span class="badge-min warn">↻${retries}</span>`);+ if (b.splits.length) badges.push(`<span class="badge-min warn">✂${b.splits.length}</span>`);if (b.deferred.length) badges.push(`<span class="badge-min warn">⏸${b.deferred.length}</span>`);if (b.exhausted.length) badges.push(`<span class="badge-min error">✗${b.exhausted.length}</span>`);return `<div class="brow" data-id="${id}">@@ -516,6 +520,7 @@["distinct_ids", b.distinct_ids],["workers", workers.length],["retries", b.retries.length],+ ["splits", b.splits.length],["stashed", b.deferred.reduce((a, d) => a + d.groups, 0)],].map(([l, n]) => `<div class="stat"><div class="n">${n}</div><div class="l">${l}</div></div>`).join("");@@ -590,6 +595,7 @@const primary = w.assignedMsgs > 0 ? w.assignedMsgs : w.flushedMsgs;const badges = [];if (w.retries) badges.push(`<span class="badge-min warn">↻${w.retries}</span>`);+ if (w.splits) badges.push(`<span class="badge-min warn">✂×${w.splits}</span>`);if (w.flushCount) badges.push(`<span class="badge-min warn">re-routed ×${w.flushCount}</span>`);if (w.exhausted) badges.push(`<span class="badge-min error">exhausted</span>`);if (!w.exhausted && b.committed) badges.push(`<span class="badge-min">✓ acked</span>`);