: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
fix(metrics): correct fingerprint doc, pin little-endian prefixes (#67531)
Daniel Visca8e8d604a2817
diff --git a/rust/capture-logs/src/metric_record.rs b/rust/capture-logs/src/metric_record.rsindex 9a06d402c54d..f8f05cc0bf95 100644--- a/rust/capture-logs/src/metric_record.rs+++ b/rust/capture-logs/src/metric_record.rs@@ -371,9 +371,10 @@ fn compute_series_fingerprint(hasher.finish() as i64}-/// Length-prefixed so e.g. {"ab":"c"} and {"a":"bc"} can never collide.+/// Length-prefixed so e.g. {"ab":"c"} and {"a":"bc"} can never collide. Lengths are+/// written little-endian (not native `write_u64`) so the id is identical on any host.fn hash_str(hasher: &mut SipHasher13, s: &str) {- hasher.write_u64(s.len() as u64);+ hasher.write(&(s.len() as u64).to_le_bytes());hasher.write(s.as_bytes());}@@ -381,7 +382,7 @@ fn hash_str(hasher: &mut SipHasher13, s: &str) {fn hash_sorted_map(hasher: &mut SipHasher13, map: &HashMap<String, String>) {let mut pairs: Vec<(&str, &str)> = map.iter().map(|(k, v)| (k.as_str(), v.as_str())).collect();pairs.sort_unstable();- hasher.write_u64(pairs.len() as u64);+ hasher.write(&(pairs.len() as u64).to_le_bytes());for (key, value) in pairs {hash_str(hasher, key);hash_str(hasher, value);diff --git a/rust/capture-logs/src/metrics_avro_schema.rs b/rust/capture-logs/src/metrics_avro_schema.rsindex 91c7d559a68c..ac94392a5ec5 100644--- a/rust/capture-logs/src/metrics_avro_schema.rs+++ b/rust/capture-logs/src/metrics_avro_schema.rs@@ -121,7 +121,7 @@ pub const METRICS_AVRO_SCHEMA: &str = r#""name": "series_fingerprint","type": ["null", "long"],"default": null,- "doc": "Stable per-series identity assigned at ingest (hash of metric_name + sorted resource/data-point attributes). Stored verbatim by ClickHouse, never recomputed. u64 bits carried as a signed long."+ "doc": "Stable per-series identity assigned at ingest (hash of metric_name, metric_type, service_name, and sorted resource/data-point attributes). Stored verbatim by ClickHouse, never recomputed. u64 bits carried as a signed long."}]}"#;