diff --git a/Cargo.lock b/Cargo.lock index 93c5cf2a0..d0c3b607a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1376,6 +1376,7 @@ name = "datadog-trace-normalization" version = "10.0.0" dependencies = [ "anyhow", + "criterion", "datadog-trace-protobuf", "duplicate", "rand", diff --git a/trace-normalization/src/normalize_utils.rs b/trace-normalization/src/normalize_utils.rs index 0c52db03e..a1ba981da 100644 --- a/trace-normalization/src/normalize_utils.rs +++ b/trace-normalization/src/normalize_utils.rs @@ -26,7 +26,7 @@ pub fn normalize_service(svc: &mut String) { truncate_utf8(svc, MAX_SERVICE_LEN); normalize_tag(svc); if svc.is_empty() { - *svc = DEFAULT_SERVICE_NAME.to_owned(); + DEFAULT_SERVICE_NAME.clone_into(svc); } } @@ -35,13 +35,14 @@ pub fn normalize_name(name: &mut String) { truncate_utf8(name, MAX_NAME_LEN); normalize_metric_name(name); if name.is_empty() { - *name = DEFAULT_SPAN_NAME.to_owned(); + DEFAULT_SPAN_NAME.clone_into(name); } } +#[allow(clippy::ptr_arg)] pub fn normalize_resource(resource: &mut String, name: &str) { if resource.is_empty() { - *resource = name.to_owned(); + name.clone_into(resource); } } @@ -55,7 +56,7 @@ pub fn normalize_span_start_duration(start: &mut i64, duration: &mut i64) { if *duration < 0 { *duration = 0; } - if *duration > std::i64::MAX - *start { + if *duration > i64::MAX - *start { *duration = 0; } diff --git a/trace-utils/src/trace_utils.rs b/trace-utils/src/trace_utils.rs index 2fc455095..9e4cad24b 100644 --- a/trace-utils/src/trace_utils.rs +++ b/trace-utils/src/trace_utils.rs @@ -1,13 +1,8 @@ // Copyright 2023-Present Datadog, Inc. https://www.datadoghq.com/ // SPDX-License-Identifier: Apache-2.0 -use anyhow::Context; -use futures::stream::FuturesUnordered; -use futures::StreamExt; -use hyper::http::HeaderValue; -use hyper::{body::Buf, Body, Client, HeaderMap, Method, Response, StatusCode}; -use log::{error, info}; -use serde::{Deserialize, Serialize}; +use hyper::{body::Buf, Body}; +use log::error; use std::cmp::Ordering; use std::collections::{HashMap, HashSet}; @@ -144,7 +139,7 @@ pub fn get_root_span_index(trace: &[pb::Span]) -> anyhow::Result { // Do a first pass to find if we have an obvious root span (starting from the end) since some // clients put the root span last. - for (i, span) in trace.into_iter().enumerate().rev() { + for (i, span) in trace.iter().enumerate().rev() { if span.parent_id == 0 { return Ok(i); }