Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert local root span id to u64, fix clippy lints #80

Merged
merged 10 commits into from
Jan 11, 2023
12 changes: 6 additions & 6 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion ddcommon-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[package]
name = "ddcommon-ffi"
version = "1.0.1"
version = "2.0.0"
edition = "2021"
license = "Apache-2.0"

Expand Down
2 changes: 1 addition & 1 deletion ddcommon-ffi/src/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ impl<T> From<alloc::vec::Vec<T>> for Vec<T> {
impl From<anyhow::Error> for Vec<u8> {
fn from(err: anyhow::Error) -> Self {
let mut vec = vec![];
write!(vec, "{}", err).expect("write to vec to always succeed");
write!(vec, "{err}").expect("write to vec to always succeed");
Self::from(vec)
}
}
Expand Down
2 changes: 1 addition & 1 deletion ddcommon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
edition = "2021"
license = "Apache-2.0"
name = "ddcommon"
version = "1.0.1"
version = "2.0.0"

[lib]
crate-type = ["lib"]
Expand Down
6 changes: 3 additions & 3 deletions ddcommon/src/tag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ impl Tag {

let mut chars = chunk.chars();
if chars.next() == Some(':') {
return Err(format!("tag '{}' begins with a colon", chunk).into());
return Err(format!("tag '{chunk}' begins with a colon").into());
}
if chars.last() == Some(':') {
return Err(format!("tag '{}' ends with a colon", chunk).into());
return Err(format!("tag '{chunk}' ends with a colon").into());
}

Ok(Tag {
Expand All @@ -74,7 +74,7 @@ impl Tag {
let key = key.as_ref();
let value = value.as_ref();

Tag::from_value(format!("{}:{}", key, value))
Tag::from_value(format!("{key}:{value}"))
}
}

Expand Down
6 changes: 3 additions & 3 deletions ddtelemetry-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@

[package]
name = "ddtelemetry-ffi"
version = "1.0.1"
version = "2.0.0"
edition = "2021"

[lib]
crate-type = ["lib", "staticlib", "cdylib"]

[dependencies]
ddtelemetry = { path = "../ddtelemetry", version = "1.0.1" }
ddcommon-ffi = { path = "../ddcommon-ffi", version = "1.0.1" }
ddtelemetry = { path = "../ddtelemetry" }
ddcommon-ffi = { path = "../ddcommon-ffi" }
paste = "1"
libc = "0.2"
2 changes: 1 addition & 1 deletion ddtelemetry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
edition = "2021"
license = "Apache 2.0"
name = "ddtelemetry"
version = "1.0.1"
version = "2.0.0"

[dependencies]
anyhow = {version = "1.0"}
Expand Down
2 changes: 1 addition & 1 deletion ddtelemetry/benches/ipc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ fn criterion_benchmark(c: &mut Criterion) {
_ => panic!("shouldn't happen"),
};

println!("Total requests handled: {}", requests_received);
println!("Total requests handled: {requests_received}");

drop(transport);
worker.join().unwrap();
Expand Down
10 changes: 5 additions & 5 deletions ddtelemetry/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl FromEnv {
let agent_host =
env::var(DD_AGENT_HOST).unwrap_or_else(|_| String::from(DEFAULT_AGENT_HOST));

format!("http://{}:{}", agent_host, agent_port)
format!("http://{agent_host}:{agent_port}")
}

fn get_intake_base_url() -> String {
Expand All @@ -63,9 +63,9 @@ impl FromEnv {

if let Ok(dd_site) = env::var(DD_SITE) {
if dd_site.is_empty() {
format!("{}.{}", PROD_INTAKE_FORMAT_PREFIX, DEFAULT_DD_SITE)
format!("{PROD_INTAKE_FORMAT_PREFIX}.{DEFAULT_DD_SITE}")
} else {
format!("{}.{}", PROD_INTAKE_FORMAT_PREFIX, dd_site)
format!("{PROD_INTAKE_FORMAT_PREFIX}.{dd_site}")
}
} else {
String::from(STAGING_INTAKE)
Expand All @@ -77,9 +77,9 @@ impl FromEnv {

let telemetry_url = if api_key.is_some() {
let telemetry_intake_base_url = Self::get_intake_base_url();
format!("{}{}", telemetry_intake_base_url, DIRECT_TELEMETRY_URL_PATH)
format!("{telemetry_intake_base_url}{DIRECT_TELEMETRY_URL_PATH}")
} else {
format!("{}{}", &agent_url, AGENT_TELEMETRY_URL_PATH)
format!("{}{AGENT_TELEMETRY_URL_PATH}", &agent_url)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting -- is there no extended way for format! that can embed &agent_url directly?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, the inline format values can only contain simple identifiers https://rust-lang.github.io/rfcs/2795-format-args-implicit-identifiers.html

For the sake of uniformity, maybe named arguments would be better

Suggested change
format!("{}{AGENT_TELEMETRY_URL_PATH}", &agent_url)
format!("{agent_url}{AGENT_TELEMETRY_URL_PATH}", agent_url=&agent_url)

};

let telemetry_uri = Uri::from_str(&telemetry_url).ok()?;
Expand Down
2 changes: 1 addition & 1 deletion ddtelemetry/src/fork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ pub mod tests {
sock_a.read_to_string(&mut out).unwrap();

assert_child_exit!(pid);
assert_eq!(format!("child-{}", pid), out);
assert_eq!(format!("child-{pid}"), out);
}

#[test]
Expand Down
3 changes: 1 addition & 2 deletions ddtelemetry/src/ipc/platform/unix/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ mod tests {
fs::File,
io::{self, Read, Seek, Write},
os::unix::prelude::{AsRawFd, RawFd},
path::Path,
};

use crate::ipc::platform::{metadata::ChannelMetadata, unix::message::MAX_FDS};
Expand Down Expand Up @@ -53,7 +52,7 @@ mod tests {
.map(|p| format!("{}", p))
.unwrap_or_else(|| "self".into());

let fds_path = Path::new("/proc").join(proc).join("fd");
let fds_path = std::path::Path::new("/proc").join(proc).join("fd");
let fds = std::fs::read_dir(fds_path)?
.filter_map(|r| r.ok())
.filter_map(|r| {
Expand Down
4 changes: 2 additions & 2 deletions ddtelemetry/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,14 +212,14 @@ mod test {
for (i, &a) in assertions.iter().enumerate() {
if a(e) {
if used[i] {
panic!("Assertion {} has been used multiple times", i);
panic!("Assertion {i} has been used multiple times");
}
found = true;
break;
}
}
if !found {
panic!("No assertion found for elem {:?}", e)
panic!("No assertion found for elem {e:?}")
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion profiling-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[package]
name = "datadog-profiling-ffi"
version = "1.0.1"
version = "2.0.0"
edition = "2021"
license = "Apache-2.0"

Expand Down
14 changes: 5 additions & 9 deletions profiling-ffi/src/profiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,22 +353,20 @@ pub extern "C" fn ddog_prof_Profile_add(
///
/// # Arguments
/// * `profile` - a reference to the profile that will contain the samples.
/// * `local_root_span_id` - the value of the local root span id label to look for.
/// * `local_root_span_id`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor: This is a weird change -- was it intentional?

/// * `endpoint` - the value of the endpoint label to add for matching samples.
///
/// # Safety
/// The `profile` ptr must point to a valid Profile object created by this
/// module.
/// This call is _NOT_ thread-safe.
#[no_mangle]
pub unsafe extern "C" fn ddog_prof_Profile_set_endpoint<'a>(
pub unsafe extern "C" fn ddog_prof_Profile_set_endpoint(
profile: &mut datadog_profiling::profile::Profile,
local_root_span_id: CharSlice<'a>,
endpoint: CharSlice<'a>,
local_root_span_id: u64,
endpoint: CharSlice,
) {
let local_root_span_id = local_root_span_id.to_utf8_lossy();
let endpoint = endpoint.to_utf8_lossy();

profile.add_endpoint(local_root_span_id, endpoint);
}

Expand Down Expand Up @@ -451,9 +449,7 @@ pub unsafe extern "C" fn ddog_prof_Profile_serialize(
Some(x) if *x < 0 => None,
Some(x) => Some(Duration::from_nanos((*x) as u64)),
};
match || -> anyhow::Result<datadog_profiling::profile::EncodedProfile> {
Ok(profile.serialize(end_time, duration)?)
}() {
match profile.serialize(end_time, duration) {
Ok(ok) => SerializeResult::Ok(ok.into()),
Err(err) => SerializeResult::Err(err.into()),
}
Expand Down
2 changes: 1 addition & 1 deletion profiling/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

[package]
name = "datadog-profiling"
version = "1.0.1"
version = "2.0.0"
edition = "2021"
license = "Apache-2.0"

Expand Down
2 changes: 1 addition & 1 deletion profiling/src/exporter/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub fn agent(base_url: Uri) -> anyhow::Result<Endpoint> {
Some(pq) => {
let path = pq.path();
let path = path.strip_suffix('/').unwrap_or(path);
Some(format!("{}/profiling/v1/input", path).parse()?)
Some(format!("{path}/profiling/v1/input").parse()?)
}
};
parts.path_and_query = p_q;
Expand Down
Loading