From 7fbe58789272299114507146c8b2d364f0973610 Mon Sep 17 00:00:00 2001 From: Fangdun Tsai Date: Tue, 7 Nov 2023 15:19:05 +0800 Subject: [PATCH] fix(core): use From::from --- viz-core/src/middleware/otel/metrics.rs | 2 +- viz-core/src/middleware/otel/tracing.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/viz-core/src/middleware/otel/metrics.rs b/viz-core/src/middleware/otel/metrics.rs index c306d51b..4a42b71a 100644 --- a/viz-core/src/middleware/otel/metrics.rs +++ b/viz-core/src/middleware/otel/metrics.rs @@ -165,7 +165,7 @@ fn build_attributes(req: &Request, http_route: &str) -> Vec { } if let Some(port) = uri .port_u16() - .and_then(|port| i64::try_from(port).ok()) + .map(i64::from) .filter(|port| *port != 80 && *port != 443) { attributes.push(SERVER_PORT.i64(port)); diff --git a/viz-core/src/middleware/otel/tracing.rs b/viz-core/src/middleware/otel/tracing.rs index 1787a476..127e6a4a 100644 --- a/viz-core/src/middleware/otel/tracing.rs +++ b/viz-core/src/middleware/otel/tracing.rs @@ -183,7 +183,7 @@ fn build_attributes(req: &Request, http_route: &str) -> OrderMap { } if let Some(port) = uri .port_u16() - .and_then(|len| i64::try_from(len).ok()) + .map(i64::from) .filter(|port| *port != 80 && *port != 443) { attributes.insert(SERVER_PORT, port.into());