Skip to content

Commit

Permalink
Fix clippy errors
Browse files Browse the repository at this point in the history
  • Loading branch information
VianneyRuhlmann committed Jun 26, 2024
1 parent f541477 commit 15186f3
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 12 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions trace-normalization/src/normalize_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand All @@ -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);
}
}

Expand All @@ -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;
}

Expand Down
11 changes: 3 additions & 8 deletions trace-utils/src/trace_utils.rs
Original file line number Diff line number Diff line change
@@ -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};

Expand Down Expand Up @@ -144,7 +139,7 @@ pub fn get_root_span_index(trace: &[pb::Span]) -> anyhow::Result<usize> {

// 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);
}
Expand Down

0 comments on commit 15186f3

Please sign in to comment.