From 69a94423cd504aa579313eede486dd36c2cdfe71 Mon Sep 17 00:00:00 2001 From: Alex Koshelev Date: Mon, 28 Oct 2024 14:22:31 -0700 Subject: [PATCH] Feedback --- ipa-core/Cargo.toml | 2 +- ipa-core/src/net/server/mod.rs | 10 +++++----- ipa-core/src/telemetry/mod.rs | 7 ++++--- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/ipa-core/Cargo.toml b/ipa-core/Cargo.toml index e292155f3..017f67ab6 100644 --- a/ipa-core/Cargo.toml +++ b/ipa-core/Cargo.toml @@ -86,7 +86,7 @@ ipa-prf = [] relaxed-dp = [] [dependencies] -ipa-metrics = { path = "../ipa-metrics", features = [] } +ipa-metrics = { path = "../ipa-metrics" } ipa-metrics-tracing = { optional = true, path = "../ipa-metrics-tracing" } ipa-step = { version = "*", path = "../ipa-step" } ipa-step-derive = { version = "*", path = "../ipa-step-derive" } diff --git a/ipa-core/src/net/server/mod.rs b/ipa-core/src/net/server/mod.rs index 25a5019ae..dc37d3ed6 100644 --- a/ipa-core/src/net/server/mod.rs +++ b/ipa-core/src/net/server/mod.rs @@ -161,7 +161,7 @@ impl MpcHelperServer { TraceLayer::new_for_http() .make_span_with(move |_request: &hyper::Request<_>| tracing.make_span()) .on_request(|request: &hyper::Request<_>, _: &Span| { - counter!(RequestProtocolVersion::from(request.version()), 1); + counter!(RequestProtocolVersion::from(request.version()).as_str(), 1); counter!(REQUESTS_RECEIVED, 1); }), ); @@ -733,15 +733,15 @@ mod e2e_tests { assert_eq!( Some(1), - handle.get_counter_value(RequestProtocolVersion::from(Version::HTTP_11)) + handle.get_counter_value(RequestProtocolVersion::from(Version::HTTP_11).as_str()) ); assert_eq!( Some(1), - handle.get_counter_value(RequestProtocolVersion::from(Version::HTTP_2)) + handle.get_counter_value(RequestProtocolVersion::from(Version::HTTP_2).as_str()) ); assert_eq!( None, - handle.get_counter_value(RequestProtocolVersion::from(Version::HTTP_3)) + handle.get_counter_value(RequestProtocolVersion::from(Version::HTTP_3).as_str()) ); } @@ -768,7 +768,7 @@ mod e2e_tests { assert_eq!( Some(1), - handle.get_counter_value(RequestProtocolVersion::from(Version::HTTP_2)) + handle.get_counter_value(RequestProtocolVersion::from(Version::HTTP_2).as_str()) ); } } diff --git a/ipa-core/src/telemetry/mod.rs b/ipa-core/src/telemetry/mod.rs index 4e704f24c..aae6ea1d4 100644 --- a/ipa-core/src/telemetry/mod.rs +++ b/ipa-core/src/telemetry/mod.rs @@ -31,14 +31,15 @@ pub mod metrics { } } - impl From for &'static str { - fn from(v: RequestProtocolVersion) -> Self { + impl RequestProtocolVersion { + #[must_use] + pub fn as_str(&self) -> &'static str { const HTTP11: &str = "request.protocol.HTTP/1.1"; const HTTP2: &str = "request.protocol.HTTP/2"; const HTTP3: &str = "request.protocol.HTTP/3"; const UNKNOWN: &str = "request.protocol.HTTP/UNKNOWN"; - match v.0 { + match self.0 { Version::HTTP_11 => HTTP11, Version::HTTP_2 => HTTP2, Version::HTTP_3 => HTTP3,