Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 25 additions & 2 deletions Cargo.lock

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

256 changes: 256 additions & 0 deletions LICENSE-3rdparty.yml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions ddcommon/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ tokio-rustls = { version = "0.26", default-features = false, optional = true }
serde = { version = "1.0", features = ["derive"] }
static_assertions = "1.1.0"
libc = "0.2"
const_format = "0.2.34"

[target.'cfg(windows)'.dependencies.windows-sys]
version = "0.52"
Expand Down
3 changes: 3 additions & 0 deletions ddcommon/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ pub type HttpClient = hyper_migration::HttpClient;
pub type HttpResponse = hyper_migration::HttpResponse;
pub type HttpRequestBuilder = hyper::http::request::Builder;

// Used by tag! macro
pub use const_format;

#[derive(Clone, PartialEq, Eq, Hash, Debug, Serialize, Deserialize)]
pub struct Endpoint {
#[serde(serialize_with = "serialize_uri", deserialize_with = "deserialize_uri")]
Expand Down
4 changes: 2 additions & 2 deletions ddcommon/src/tag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ impl Tag {
/// all tag validation is currently done client-side). If the key or value
/// aren't known at compile-time, then use [Tag::new].
// todo: what's a good way to keep these in-sync with Tag::from_value?
// This can be a little more strict because it's compitle-time evaluated.
// This can be a little more strict because it's compile-time evaluated.
// https://docs.datadoghq.com/getting_started/tagging/#define-tags
#[macro_export]
macro_rules! tag {
Expand All @@ -48,7 +48,7 @@ macro_rules! tag {
// which checks that the whole thing doesn't end with a colon.
$crate::tag::const_assert!(!$val.is_empty());

const COMBINED: &'static str = concat!($key, ":", $val);
const COMBINED: &'static str = $crate::const_format::concatcp!($key, ":", $val);

// Tags must start with a letter. This is more restrictive than is
// required (could be a unicode alphabetic char) and can be lifted
Expand Down
1 change: 0 additions & 1 deletion profiling-ffi/src/exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -520,7 +520,6 @@ mod tests {
parsed_event_json["internal"],
json!({"libdatadog_version": env!("CARGO_PKG_VERSION")})
);
assert_eq!(parsed_event_json["tags_profiler"], json!(""));
assert_eq!(parsed_event_json["version"], json!("4"));

// TODO: Assert on contents of attachments, as well as on the headers/configuration for the
Expand Down
4 changes: 3 additions & 1 deletion profiling/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ harness = false
[dependencies]
anyhow = "1.0"
bitmaps = "3.2.0"
byteorder = { version = "1.5", features = ["std"] }
bytes = "1.1"
chrono = {version = "0.4", default-features = false, features = ["std", "clock"]}
const_format = "0.2.34"
datadog-alloc = {path = "../alloc"}
ddcommon = {path = "../ddcommon"}
derivative = "2.2.0"
Expand All @@ -43,9 +45,9 @@ prost = "0.12"
rustc-hash = { version = "1.1", default-features = false }
serde = {version = "1.0", features = ["derive"]}
serde_json = {version = "1.0"}
target-triple = "0.1.4"
tokio = {version = "1.23", features = ["rt", "macros"]}
tokio-util = "0.7.1"
byteorder = { version = "1.5", features = ["std"] }

[dev-dependencies]
bolero = "0.13"
Expand Down
20 changes: 18 additions & 2 deletions profiling/src/exporter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use tokio::runtime::Runtime;
use tokio_util::sync::CancellationToken;

use ddcommon::{
azure_app_services, connector, hyper_migration, Endpoint, HttpClient, HttpResponse,
azure_app_services, connector, hyper_migration, tag, Endpoint, HttpClient, HttpResponse,
};

pub mod config;
Expand Down Expand Up @@ -155,6 +155,19 @@ impl ProfileExporter {
})
}

/// The target triple. This is a string like:
/// - aarch64-apple-darwin
/// - x86_64-unknown-linux-gnu
///
/// The name is which is a misnomer, it traditionally had 3 pieces, but
/// it's commonly 4+ fragments today.
const TARGET_TRIPLE: &'static str = target_triple::TARGET;

#[inline]
fn runtime_platform_tag(&self) -> Tag {
tag!("runtime_platform", ProfileExporter::TARGET_TRIPLE)
}

#[allow(clippy::too_many_arguments)]
/// Build a Request object representing the profile information provided.
///
Expand Down Expand Up @@ -216,7 +229,10 @@ impl ProfileExporter {
});
}

tags_profiler.pop(); // clean up the trailing comma
// Since this is the last tag, we add it without a comma afterward. If
// any tags get added after this one, you'll need to add the comma
// between them.
tags_profiler.push_str(self.runtime_platform_tag().as_ref());

let attachments: Vec<String> = files_to_compress_and_export
.iter()
Expand Down
19 changes: 16 additions & 3 deletions profiling/tests/form.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,22 @@ mod tests {
parsed_event_json["internal"],
json!({"libdatadog_version": env!("CARGO_PKG_VERSION")})
);
assert_eq!(
parsed_event_json["tags_profiler"],
json!("service:php,host:bits")
let tags_profiler = parsed_event_json["tags_profiler"]
.as_str()
.unwrap()
.split(',')
.collect::<Vec<_>>();
assert!(tags_profiler.contains(&"service:php"));
assert!(tags_profiler.contains(&"host:bits"));
let runtime_platform = tags_profiler
.iter()
.find(|tag| tag.starts_with("runtime_platform:"))
.expect("runtime_platform tag should exist");
assert!(
runtime_platform.starts_with(&format!("runtime_platform:{}", std::env::consts::ARCH)),
"expected platform tag to start with runtime_platform:{} but got '{}'",
std::env::consts::ARCH,
runtime_platform
);
assert_eq!(parsed_event_json["version"], json!("4"));
}
Expand Down