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(capture): collapse unmatched path labels to "unknown" (#59902)

Paweł Ledwoń05acb305a93f
diff --git a/rust/Cargo.lock b/rust/Cargo.lock
index bf9afd290a3b..54ba047d9da6 100644
--- a/rust/Cargo.lock
+++ b/rust/Cargo.lock
@@ -1724,7 +1724,6 @@ dependencies = [
"chrono",
"common-alloc",
"common-continuous-profiling",
- "common-metrics",
"common-redis",
"common-types",
"envconfig",
diff --git a/rust/capture/Cargo.toml b/rust/capture/Cargo.toml
index 2fc9a4d35743..af87ad305ae6 100644
--- a/rust/capture/Cargo.toml
+++ b/rust/capture/Cargo.toml
@@ -25,7 +25,6 @@ lifecycle = { path = "../common/lifecycle" }
hyper = { workspace = true }
hyper-util = { workspace = true }
common-alloc = { path = "../common/alloc" }
-common-metrics = { path = "../common/metrics" }
common-continuous-profiling = { path = "../common/continuous_profiling" }
common-redis = { path = "../common/redis" }
common-types = { path = "../common/types" }
diff --git a/rust/capture/src/metrics_middleware.rs b/rust/capture/src/metrics_middleware.rs
index 9dec347e9da0..bb708a61019e 100644
--- a/rust/capture/src/metrics_middleware.rs
+++ b/rust/capture/src/metrics_middleware.rs
@@ -9,9 +9,10 @@ use axum::{
response::IntoResponse,
routing::Router,
};
-use common_metrics::normalize_unmatched_path;
use metrics::gauge;
+const UNMATCHED_PATH_LABEL: &str = "unknown";
+
// Global atomic counter for active connections
static ACTIVE_CONNECTIONS: AtomicUsize = AtomicUsize::new(0);
@@ -41,7 +42,7 @@ pub async fn track_metrics(req: Request<Body>, next: Next) -> impl IntoResponse
let path = if let Some(matched_path) = req.extensions().get::<MatchedPath>() {
matched_path.as_str().to_owned()
} else {
- normalize_unmatched_path(req.uri().path())
+ UNMATCHED_PATH_LABEL.to_owned()
};
let method = req.method().clone();
@@ -90,7 +91,7 @@ where
let path = if let Some(matched) = req.extensions().get::<MatchedPath>() {
matched.as_str().to_owned()
} else {
- normalize_unmatched_path(req.uri().path())
+ UNMATCHED_PATH_LABEL.to_owned()
};
let client_ip = req
.headers()