diff --git a/crates/sui-rpc-api/src/metrics.rs b/crates/sui-rpc-api/src/metrics.rs index da8cf85150b81..267c649e151b1 100644 --- a/crates/sui-rpc-api/src/metrics.rs +++ b/crates/sui-rpc-api/src/metrics.rs @@ -68,11 +68,20 @@ impl MakeCallbackHandler for RpcMetricsMakeCallbackHandler { let start = Instant::now(); let metrics = self.metrics.clone(); - let path = if let Some(path) = request.extensions.get::() { - Cow::Owned(path.as_str().to_owned()) - } else { - Cow::Borrowed("unknown") - }; + let path = + if let Some(matched_path) = request.extensions.get::() { + if request + .headers + .get(&http::header::CONTENT_TYPE) + .is_some_and(|header| header == tonic::metadata::GRPC_CONTENT_TYPE) + { + Cow::Owned(request.uri.path().to_owned()) + } else { + Cow::Owned(matched_path.as_str().to_owned()) + } + } else { + Cow::Borrowed("unknown") + }; metrics .inflight_requests