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
284 changes: 259 additions & 25 deletions Cargo.lock

Large diffs are not rendered by default.

6,709 changes: 4,959 additions & 1,750 deletions LICENSE-3rdparty.yml

Large diffs are not rendered by default.

8 changes: 6 additions & 2 deletions examples/cxx/build-and-run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,11 @@ if ($USE_MSVC) {
$ExampleCpp,
$CRATE_LIB,
$CXX_BRIDGE_LIB,
"ws2_32.lib", "advapi32.lib", "userenv.lib", "ntdll.lib", "bcrypt.lib", "ole32.lib"
# Note: when linking Rust staticlibs from C++, native system libraries that Rust
# would normally link automatically for Rust binaries must be provided here.
#
# `rustls-platform-verifier` uses the Windows certificate APIs (Cert*), which live in Crypt32.
"ws2_32.lib", "advapi32.lib", "userenv.lib", "ntdll.lib", "bcrypt.lib", "ole32.lib", "crypt32.lib"
)

# Add extra MSVC libraries if specified
Expand Down Expand Up @@ -174,7 +178,7 @@ if ($USE_MSVC) {
$ExampleCpp,
"`"$CXX_BRIDGE_LIB`"",
"`"$CRATE_LIB`"",
"-lws2_32", "-ladvapi32", "-luserenv", "-lntdll", "-lbcrypt"
"-lws2_32", "-ladvapi32", "-luserenv", "-lntdll", "-lbcrypt", "-lcrypt32"
)

# Add extra GNU libraries if specified
Expand Down
13 changes: 12 additions & 1 deletion examples/cxx/build-and-run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,21 @@ echo "📚 CXX bridge library: $CXX_BRIDGE_LIB"

echo "🔨 Compiling C++ example..."
# Platform-specific linker flags
#
# Note: when linking Rust staticlibs from C++, native system libraries that Rust
# would normally link automatically for Rust binaries must be provided here.
#
# - macOS: Security/CoreFoundation for TLS root store access
# - Windows: Crypt32 for `rustls-platform-verifier` (Cert* APIs)
if [[ "$OSTYPE" == "darwin"* ]]; then
PLATFORM_LIBS="-framework Security -framework CoreFoundation"
THREAD_LIBS="-lpthread -ldl"
elif [[ "$OSTYPE" == "msys"* || "$OSTYPE" == "cygwin"* || "$OSTYPE" == "win32"* ]]; then
PLATFORM_LIBS="-lcrypt32"
THREAD_LIBS=""
else
PLATFORM_LIBS=""
THREAD_LIBS="-lpthread -ldl"
fi

c++ -std=c++20 $EXTRA_CXX_FLAGS \
Expand All @@ -77,7 +88,7 @@ c++ -std=c++20 $EXTRA_CXX_FLAGS \
"examples/cxx/${EXAMPLE_NAME}.cpp" \
"$CRATE_LIB" \
"$CXX_BRIDGE_LIB" \
-lpthread -ldl $PLATFORM_LIBS $EXTRA_LIBS \
$THREAD_LIBS $PLATFORM_LIBS $EXTRA_LIBS \
-o "examples/cxx/${EXAMPLE_NAME}"

echo "🚀 Running example..."
Expand Down
3 changes: 2 additions & 1 deletion libdd-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ tower-service = "0.3"
cc = "1.1.31"
pin-project = "1"
regex = "1.5"
rustls = { version = "0.23", default-features = false, optional = true }
rustls-native-certs = { version = "0.8.1", optional = true }
thiserror = "1.0"
tokio = { version = "1.23", features = ["rt", "macros"] }
Expand All @@ -45,6 +44,7 @@ version = "0.52"
features = ["Win32_Foundation", "Win32_System_Performance"]

[target.'cfg(unix)'.dependencies]
rustls = { version = "0.23", default-features = false, optional = true, features = ["aws-lc-rs"] }
hyper-rustls = { version = "0.27", default-features = false, features = [
"native-tokio",
"http1",
Expand All @@ -53,6 +53,7 @@ hyper-rustls = { version = "0.27", default-features = false, features = [
], optional = true }

[target.'cfg(not(unix))'.dependencies]
rustls = { version = "0.23", default-features = false, optional = true, features = ["ring"] }
hyper-rustls = { version = "0.27", default-features = false, features = [
"native-tokio",
"http1",
Expand Down
2 changes: 2 additions & 0 deletions libdd-common/src/connector/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ mod https {
INIT_CRYPTO_PROVIDER.call_once(|| {
#[cfg(unix)]
let _ = rustls::crypto::aws_lc_rs::default_provider().install_default();
#[cfg(not(unix))]
let _ = rustls::crypto::ring::default_provider().install_default();
});
}

Expand Down
35 changes: 21 additions & 14 deletions libdd-profiling-ffi/src/exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,15 @@ unsafe fn try_to_url(slice: CharSlice) -> anyhow::Result<hyper::Uri> {
let str: &str = slice.try_to_utf8()?;
#[cfg(unix)]
if let Some(path) = str.strip_prefix("unix://") {
return Ok(exporter::socket_path_to_uri(path.as_ref())?);
return Ok(libdd_common::connector::uds::socket_path_to_uri(
path.as_ref(),
)?);
}
#[cfg(windows)]
if let Some(path) = str.strip_prefix("windows:") {
return Ok(exporter::named_pipe_path_to_uri(path.as_ref())?);
return Ok(libdd_common::connector::named_pipe::named_pipe_path_to_uri(
path.as_ref(),
)?);
}
Ok(hyper::Uri::from_str(str)?)
}
Expand Down Expand Up @@ -142,11 +146,13 @@ pub unsafe extern "C" fn ddog_prof_Exporter_new(
endpoint: ProfilingEndpoint,
) -> Result<Handle<ProfileExporter>> {
wrap_with_ffi_result!({
let library_name = profiling_library_name.to_utf8_lossy().into_owned();
let library_version = profiling_library_version.to_utf8_lossy().into_owned();
let family = family.to_utf8_lossy().into_owned();
let library_name = profiling_library_name.try_to_utf8()?;
let library_version = profiling_library_version.try_to_utf8()?;
let family = family.try_to_utf8()?;
let converted_endpoint = unsafe { try_to_endpoint(endpoint)? };
let tags = tags.map(|tags| tags.iter().cloned().collect());
let tags = tags
.map(|tags| tags.iter().cloned().collect())
.unwrap_or_default();
anyhow::Ok(
ProfileExporter::new(
library_name,
Expand Down Expand Up @@ -238,26 +244,27 @@ pub unsafe extern "C" fn ddog_prof_Exporter_send_blocking(
let exporter = exporter.to_inner_mut()?;
let profile = *profile.take()?;
let files_to_compress_and_export = into_vec_files(files_to_compress_and_export);
let tags = optional_additional_tags.map(|tags| tags.iter().cloned().collect());
let tags: Vec<Tag> = optional_additional_tags
.map(|tags| tags.iter().cloned().collect())
.unwrap_or_default();
let process_tags_str = optional_process_tags
.map(|cs| cs.try_to_utf8())
.transpose()?;
let internal_metadata = parse_json("internal_metadata", optional_internal_metadata_json)?;
let info = parse_json("info", optional_info_json)?;

let request = exporter.build(
let cancel = cancel.to_inner_mut().ok();
let status = exporter.send_blocking(
profile,
files_to_compress_and_export.as_slice(),
tags.as_ref(),
process_tags_str,
&tags,
internal_metadata,
info,
process_tags_str,
cancel.as_deref(),
)?;

let cancel = cancel.to_inner_mut().ok();
let response = exporter.send(request, cancel.as_deref())?;

anyhow::Ok(HttpStatus(response.status().as_u16()))
anyhow::Ok(HttpStatus(status.as_u16()))
})
}

Expand Down
26 changes: 15 additions & 11 deletions libdd-profiling/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ bench = false
[features]
default = []
cxx = ["dep:cxx", "dep:cxx-build"]
test-utils = ["dep:multipart"]

[[bench]]
name = "main"
Expand All @@ -32,35 +33,38 @@ byteorder = { version = "1.5", features = ["std"] }
bytes = "1.1"
chrono = {version = "0.4", default-features = false, features = ["std", "clock"]}
crossbeam-utils = { version = "0.8.21" }
libdd-alloc = { version = "1.0.0", path = "../libdd-alloc" }
libdd-profiling-protobuf = { version = "1.0.0", path = "../libdd-profiling-protobuf", features = ["prost_impls"] }
libdd-common = { version = "1.0.0", path = "../libdd-common" }
cxx = { version = "1.0", optional = true }
futures = { version = "0.3", default-features = false }
hashbrown = { version = "0.16", default-features = false }
http = "1.0"
hyper = { workspace = true}
http-body-util = "0.1"
hyper-multipart-rfc7578 = "0.9.0"
httparse = "1.9"
indexmap = "2.11"
libdd-alloc = { version = "1.0.0", path = "../libdd-alloc" }
libdd-common = { version = "1.0.0", path = "../libdd-common", default-features = false }
libdd-profiling-protobuf = { version = "1.0.0", path = "../libdd-profiling-protobuf", features = ["prost_impls"] }
mime = "0.3.16"
multipart = { version = "0.18", optional = true }
parking_lot = { version = "0.12", default-features = false }
prost = "0.14.1"
rand = "0.8"
# Use rustls to align with the rest of the workspace (libdd-common, libdd-telemetry, etc.)
# This uses the same TLS stack (rustls + aws-lc-rs/ring) as other crates
reqwest = { version = "0.13", features = ["multipart", "rustls"], default-features = false}
rustc-hash = { version = "1.1", default-features = false }
serde = {version = "1.0", features = ["derive"]}
serde_json = {version = "1.0"}
target-triple = "0.1.4"
thiserror = "2"
tokio = {version = "1.23", features = ["rt", "macros", "net", "io-util", "fs", "sync"]}
tokio-util = "0.7.1"
rand = "0.8"
httparse = "1.9"
multipart = "0.18"
tokio = {version = "1.23", features = ["rt", "macros", "net", "io-util", "fs"]}
tokio-util = { version = "0.7.1", default-features = false }
zstd = { version = "0.13", default-features = false }
cxx = { version = "1.0", optional = true }


[dev-dependencies]
bolero = "0.13"
criterion = "0.5.1"
libdd-profiling = { path = ".", features = ["test-utils"] }
proptest = "1"

[build-dependencies]
Expand Down
Loading
Loading