Skip to content
Open
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
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.

3 changes: 3 additions & 0 deletions builder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ crashtracker = []
profiling = []
telemetry = []
data-pipeline = []
# Enable zstd compression for the agentless trace intake sender (opt-in: links a C
# library and increases artifact size).
data-pipeline-compression = ["data-pipeline"]
symbolizer = []
library-config = []
log = []
Expand Down
2 changes: 2 additions & 0 deletions builder/src/bin/release.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ pub fn main() {
f.push("ddtelemetry-ffi".to_string());
#[cfg(feature = "data-pipeline")]
f.push("data-pipeline-ffi".to_string());
#[cfg(feature = "data-pipeline-compression")]
f.push("data-pipeline-compression".to_string());
#[cfg(feature = "crashtracker")]
f.push("crashtracker-ffi".to_string());
#[cfg(feature = "symbolizer")]
Expand Down
2 changes: 2 additions & 0 deletions libdd-data-pipeline-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ default = ["cbindgen", "catch_panic"]
catch_panic = []
cbindgen = ["build_common/cbindgen", "libdd-common-ffi/cbindgen"]
regex-lite = ["libdd-data-pipeline/regex-lite"]
# Enable zstd compression for the agentless trace intake sender.
compression = ["libdd-data-pipeline/compression"]

[build-dependencies]
build_common = { path = "../build-common" }
Expand Down
3 changes: 3 additions & 0 deletions libdd-data-pipeline/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ tokio = { version = "1.23", features = [
"test-util",
], default-features = false }
duplicate = "2.0.1"
zstd = { version = "0.13", default-features = false }

[features]
default = ["https", "telemetry"]
Expand Down Expand Up @@ -111,3 +112,5 @@ fips = [
]
test-utils = []
regex-lite = ["libdd-common/regex-lite"]
# Enable zstd compression for the agentless trace intake sender.
compression = ["libdd-trace-utils/compression"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Expose compression through FFI release features

Defining the feature only on libdd-data-pipeline leaves no way for the existing FFI release path to enable it: I checked the Cargo feature wiring and libdd-data-pipeline-ffi does not forward libdd-data-pipeline/compression, while libdd-profiling-ffi only exposes data-pipeline-ffi. In languages consuming the generated FFI artifacts, enabling data-pipeline support will therefore still build uncompressed agentless sends unless a pass-through feature is added.

Useful? React with 👍 / 👎.

18 changes: 16 additions & 2 deletions libdd-data-pipeline/src/agentless/exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use http::HeaderMap;
use libdd_capabilities::{HttpClientCapability, SleepCapability};
use libdd_common::Endpoint;
use libdd_trace_utils::send_with_retry::{
send_with_retry, RetryBackoffType, RetryStrategy, SendWithRetryError,
send_with_retry, CompressionStrategy, RetryBackoffType, RetryStrategy, SendWithRetryError,
};
use tracing::error;

Expand Down Expand Up @@ -46,7 +46,21 @@ pub async fn send_agentless_traces_http<C: HttpClientCapability + SleepCapabilit
None,
);

match send_with_retry(capabilities, &target, json_body, &headers, &retry_strategy).await {
#[cfg(feature = "compression")]
let compression_strategy = CompressionStrategy::Zstd { level: 1 };
Comment thread
paullegranddc marked this conversation as resolved.
#[cfg(not(feature = "compression"))]
let compression_strategy = CompressionStrategy::None;

match send_with_retry(
capabilities,
&target,
json_body,
&headers,
&retry_strategy,
compression_strategy,
)
.await
{
Ok(_) => Ok(()),
Err(e) => Err(map_send_error(e)),
}
Expand Down
13 changes: 11 additions & 2 deletions libdd-data-pipeline/src/otlp/exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use http::HeaderMap;
use libdd_capabilities::{HttpClientCapability, SleepCapability};
use libdd_common::Endpoint;
use libdd_trace_utils::send_with_retry::{
send_with_retry, RetryBackoffType, RetryStrategy, SendWithRetryError,
send_with_retry, CompressionStrategy, RetryBackoffType, RetryStrategy, SendWithRetryError,
};
use std::time::Duration;

Expand Down Expand Up @@ -67,7 +67,16 @@ pub(crate) async fn send_otlp_http<C: HttpClientCapability + SleepCapability>(
None,
);

match send_with_retry(capabilities, &target, body, &headers, &retry_strategy).await {
match send_with_retry(
capabilities,
&target,
body,
&headers,
&retry_strategy,
CompressionStrategy::None,
)
.await
{
Ok(_) => Ok(()),
Err(e) => Err(map_send_error(e).await),
}
Expand Down
39 changes: 28 additions & 11 deletions libdd-data-pipeline/src/trace_exporter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ use libdd_shared_runtime::BlockingRuntime;
use libdd_shared_runtime::{SharedRuntime, WorkerHandle};
use libdd_trace_utils::msgpack_decoder;
use libdd_trace_utils::send_with_retry::{
send_with_retry, RetryStrategy, SendWithRetryError, SendWithRetryResult,
send_with_retry, CompressionStrategy, RetryStrategy, SendWithRetryError, SendWithRetryResult,
};
use libdd_trace_utils::span::{v04::Span, TraceData};
use libdd_trace_utils::trace_utils::TracerHeaderTags;
Expand Down Expand Up @@ -733,6 +733,7 @@ impl<
mp_payload,
&headers,
&strategy,
CompressionStrategy::None,
)
.await;

Expand Down Expand Up @@ -2270,16 +2271,32 @@ mod tests {
fn test_agentless_export_body_shape() {
let server = MockServer::start();
let mock_intake = server.mock(|when, then| {
when.method(POST)
.path("/v1/input")
.body_includes("\"traces\":")
.body_includes("\"spans\":")
.body_includes("\"hostname\":\"h-1\"")
.body_includes("\"languageName\":\"nodejs\"")
.body_includes("\"_dd.compute_stats\":\"1\"")
.body_includes("\"_top_level\":1")
.body_includes("\"_trace_root\":1")
.body_includes("\"parent_id\":\"0000000000000000\"");
fn check_body(body: &str) -> bool {
body.contains("\"traces\":")
&& body.contains("\"spans\":")
&& body.contains("\"hostname\":\"h-1\"")
&& body.contains("\"languageName\":\"nodejs\"")
&& body.contains("\"_dd.compute_stats\":\"1\"")
&& body.contains("\"_top_level\":1")
&& body.contains("\"_trace_root\":1")
&& body.contains("\"parent_id\":\"0000000000000000\"")
}
let when = when.method(POST).path("/v1/input");
#[cfg(feature = "compression")]
let when = when.header("content-encoding", "zstd").is_true(|req| {
let Ok(body) = zstd::decode_all(req.body_ref()) else {
return false;
};
let body = String::from_utf8(body).unwrap();
check_body(&body)
});
#[cfg(not(feature = "compression"))]
let when = when
.is_true(|req| {
let body = String::from_utf8(req.body_vec()).unwrap();
check_body(&body)
});
let _ = when;
then.status(200).body("");
});

Expand Down
2 changes: 2 additions & 0 deletions libdd-profiling-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ ddtelemetry-ffi = ["dep:libdd-telemetry-ffi"]
datadog-log-ffi = ["dep:libdd-log-ffi"]
symbolizer = ["symbolizer-ffi"]
data-pipeline-ffi = ["dep:libdd-data-pipeline-ffi"]
# Enable zstd compression for the agentless trace intake sender.
data-pipeline-compression = ["data-pipeline-ffi", "libdd-data-pipeline-ffi/compression"]
crashtracker-ffi = ["dep:libdd-crashtracker-ffi"]
# Enables the in-process collection of crash-info
crashtracker-collector = ["crashtracker-ffi", "libdd-crashtracker-ffi/collector"]
Expand Down
3 changes: 2 additions & 1 deletion libdd-trace-stats/src/stats_exporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use libdd_capabilities::{HttpClientCapability, MaybeSend, SleepCapability};
use libdd_common::{tag, Endpoint};
use libdd_shared_runtime::Worker;
use libdd_trace_protobuf::pb;
use libdd_trace_utils::send_with_retry::{send_with_retry, RetryStrategy};
use libdd_trace_utils::send_with_retry::{send_with_retry, CompressionStrategy, RetryStrategy};
use libdd_trace_utils::trace_utils::TracerHeaderTags;
use libdd_trace_utils::tracer_metadata::TracerMetadata;
use std::fmt::Debug;
Expand Down Expand Up @@ -224,6 +224,7 @@ impl<Cap: HttpClientCapability + SleepCapability, Con: FlushableConcentrator>
body,
&headers,
&RetryStrategy::default(),
CompressionStrategy::None,
)
.await;

Expand Down
8 changes: 5 additions & 3 deletions libdd-trace-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,9 @@ getrandom = { version = "0.2", features = ["js"] }

[dev-dependencies]
libdd-capabilities-impl = { version = "3.0.0", path = "../libdd-capabilities-impl" }
libdd-common = { path = "../libdd-common", default-features = false, features = ["bench-utils"] }
libdd-common = { path = "../libdd-common", default-features = false, features = [
"bench-utils",
] }
bolero = "0.13"
criterion = "0.5.1"
httpmock = { version = "0.8.0-alpha.1" }
Expand All @@ -88,7 +90,7 @@ tempfile = "3.3.0"
[features]
default = ["https"]
https = ["libdd-common/https", "libdd-capabilities-impl/https"]
mini_agent = ["compression", "libdd-common/use_webpki_roots"]
mini_agent = ["compression", "libdd-common/use_webpki_roots", "dep:flate2"]
test-utils = [
"hyper/server",
"httpmock",
Expand All @@ -99,6 +101,6 @@ test-utils = [
change-buffer = []
# Opt-in switch for crate-internal microbenchmarks (e.g. `vec_map_bench`).
bench-internals = []
compression = ["zstd", "flate2"]
compression = ["zstd"]
# FIPS mode uses the FIPS-compliant cryptographic provider (Unix only)
fips = ["libdd-common/fips", "libdd-capabilities-impl/fips"]
Loading
Loading