Skip to content

Commit

Permalink
Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
akoshelev committed Oct 28, 2024
1 parent ce1afea commit 69a9442
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion ipa-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
10 changes: 5 additions & 5 deletions ipa-core/src/net/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ impl<F: ConnectionFlavor> MpcHelperServer<F> {
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);
}),
);
Expand Down Expand Up @@ -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())
);
}

Expand All @@ -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())
);
}
}
7 changes: 4 additions & 3 deletions ipa-core/src/telemetry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@ pub mod metrics {
}
}

impl From<RequestProtocolVersion> 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,
Expand Down

0 comments on commit 69a9442

Please sign in to comment.