: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(property-vals): add per-tuple count distribution metric at flush (#60580)
Andy Zhao31151ac4f08a
diff --git a/rust/property-vals-rs/src/metrics_consts.rs b/rust/property-vals-rs/src/metrics_consts.rsindex 8a1817335856..2b47e2ba6939 100644--- a/rust/property-vals-rs/src/metrics_consts.rs+++ b/rust/property-vals-rs/src/metrics_consts.rs@@ -2,6 +2,7 @@ pub const EVENTS_RECEIVED: &str = "property_vals_rs_events_received_total";pub const EVENTS_FILTERED: &str = "property_vals_rs_events_filtered_total";pub const TUPLES_AGGREGATED: &str = "property_vals_rs_tuples_aggregated_total";pub const FLUSH_TUPLES: &str = "property_vals_rs_flush_tuples";+pub const FLUSH_TUPLE_COUNT: &str = "property_vals_rs_flush_tuple_count";pub const FLUSH_TOTAL: &str = "property_vals_rs_flushes_total";pub const FLUSH_REASON_TIMER: &str = "timer";pub const FLUSH_REASON_BACKPRESSURE: &str = "backpressure";diff --git a/rust/property-vals-rs/src/worker.rs b/rust/property-vals-rs/src/worker.rsindex e29b7274bb4e..def52be7f46b 100644--- a/rust/property-vals-rs/src/worker.rs+++ b/rust/property-vals-rs/src/worker.rs@@ -117,6 +117,10 @@ pub(crate) async fn flush<P: Producer>(metrics::counter!(FLUSH_TOTAL, "reason" => reason, "worker" => worker).increment(1);metrics::histogram!(FLUSH_TUPLES, "worker" => worker).record(snapshot.len() as f64);+ for (_, count) in &snapshot {+ metrics::histogram!(FLUSH_TUPLE_COUNT, "worker" => worker).record(*count as f64);+ }+if let Err(e) = producer.produce(snapshot.clone()).await {metrics::counter!(PRODUCER_FLUSH_FAILED, "worker" => worker).increment(1);error!(error = %e, "produce failed; restoring counts, retrying next flush");