Skip to content

Commit 6c7ed88

Browse files
authored
fix(deps): upgrade libdatadog (#1039)
## Overview - Upgrade libdatadog dependencies from 158b594 to c8121f4 (v28), adapting to upstream API changes (hyper_migration → http_common, HyperClient → HttpClient, new use_system_resolver field on Endpoint, SendData no longer Clone) - Rename hyper_client module to http_client to match the upstream naming change - Fix dual-shipping to additional endpoints: previously TracerHeaderTags::default() was used (losing all tracer metadata headers like datadog-meta-lang, datadog-meta-tracer-version, etc.). Now the real header tags are preserved through the aggregation pipeline and used for additional endpoints - Avoid unnecessary full TracerPayloadCollection clone in trace_processor by only cloning inner V07 payloads for stats generation ## Changes - Bump all libdd-* crates to rev c8121f4 in Cargo.toml / Cargo.lock - Adapt to hyper_migration → http_common rename across trace_agent, stats_processor, stats_flusher, and http_client - Add use_system_resolver: false to all Endpoint constructions (new required field) hyper_client.rs → http_client.rs - Rename module and type alias (HyperClient → HttpClient) - Update all consumers (trace_flusher, stats_flusher, mod.rs) Trace flusher refactor - Adapt to SendData no longer being Clone: construct per-endpoint SendData objects by cloning inner V07 payloads instead of cloning the whole SendData - Remove override_endpoint parameter from send_traces — each SendData now carries its own target endpoint - Simplify retry logic comments (endpoint tracking is no longer relevant) Preserve TracerHeaderTags for additional endpoints - Introduce OwnedTracerHeaderTags — an owned version of TracerHeaderTags<'a> that can be stored across async boundaries - Add header_tags field to SendDataBuilderInfo and thread it through the aggregation pipeline - Use real header tags (via to_tracer_header_tags()) when constructing SendData for additional endpoints instead of TracerHeaderTags::default() Trace processor optimization - Clone only inner V07 payloads for stats generation instead of cloning the entire TracerPayloadCollection before building SendData ## Tests - cargo check passes - cargo test --lib passes (481 tests) - Verify dual-shipped traces to additional endpoints include correct datadog-meta-* headers with DD_APM_ADDITIONAL_ENDPOINTS configured
1 parent 9a355cf commit 6c7ed88

File tree

11 files changed

+209
-167
lines changed

11 files changed

+209
-167
lines changed

bottlecap/Cargo.lock

Lines changed: 12 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bottlecap/Cargo.toml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,12 @@ indexmap = {version = "2.11.0", default-features = false}
6767
# be found in the clippy.toml file adjacent to this Cargo.toml.
6868
datadog-protos = { version = "0.1.0", default-features = false, git = "https://github.com/DataDog/saluki/", rev = "f863626dbfe3c59bb390985fa6530b0621c2a0a2"}
6969
ddsketch-agent = { version = "0.1.0", default-features = false, git = "https://github.com/DataDog/saluki/", rev = "f863626dbfe3c59bb390985fa6530b0621c2a0a2"}
70-
libdd-common = { git = "https://github.com/DataDog/libdatadog", rev = "158b59471f1132e3cb36023fa3c46ccb2dd0eda1" }
71-
libdd-trace-protobuf = { git = "https://github.com/DataDog/libdatadog", rev = "158b59471f1132e3cb36023fa3c46ccb2dd0eda1" }
72-
libdd-trace-utils = { git = "https://github.com/DataDog/libdatadog", rev = "158b59471f1132e3cb36023fa3c46ccb2dd0eda1" , features = ["mini_agent"] }
73-
libdd-trace-normalization = { git = "https://github.com/DataDog/libdatadog", rev = "158b59471f1132e3cb36023fa3c46ccb2dd0eda1" }
74-
libdd-trace-obfuscation = { git = "https://github.com/DataDog/libdatadog", rev = "158b59471f1132e3cb36023fa3c46ccb2dd0eda1" }
75-
libdd-trace-stats = { git = "https://github.com/DataDog/libdatadog", rev = "158b59471f1132e3cb36023fa3c46ccb2dd0eda1" }
70+
libdd-common = { git = "https://github.com/DataDog/libdatadog", rev = "c8121f422d2c8d219f8d421ff3cdb1fcbe9e8b09" }
71+
libdd-trace-protobuf = { git = "https://github.com/DataDog/libdatadog", rev = "c8121f422d2c8d219f8d421ff3cdb1fcbe9e8b09" }
72+
libdd-trace-utils = { git = "https://github.com/DataDog/libdatadog", rev = "c8121f422d2c8d219f8d421ff3cdb1fcbe9e8b09" , features = ["mini_agent"] }
73+
libdd-trace-normalization = { git = "https://github.com/DataDog/libdatadog", rev = "c8121f422d2c8d219f8d421ff3cdb1fcbe9e8b09" }
74+
libdd-trace-obfuscation = { git = "https://github.com/DataDog/libdatadog", rev = "c8121f422d2c8d219f8d421ff3cdb1fcbe9e8b09" }
75+
libdd-trace-stats = { git = "https://github.com/DataDog/libdatadog", rev = "c8121f422d2c8d219f8d421ff3cdb1fcbe9e8b09" }
7676
dogstatsd = { git = "https://github.com/DataDog/serverless-components", rev = "2eb009a59ed07ffcaf174db1c31af413365e9bc6", default-features = false }
7777
datadog-fips = { git = "https://github.com/DataDog/serverless-components", rev = "2eb009a59ed07ffcaf174db1c31af413365e9bc6", default-features = false }
7878
libddwaf = { version = "1.28.1", git = "https://github.com/DataDog/libddwaf-rust", rev = "d1534a158d976bd4f747bf9fcc58e0712d2d17fc", default-features = false, features = ["serde"] }
Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
// Copyright 2023-Present Datadog, Inc. https://www.datadoghq.com/
22
// SPDX-License-Identifier: Apache-2.0
33

4-
//! Hyper-based HTTP client for trace and stats flushers.
4+
//! HTTP client for trace and stats flushers.
55
//!
66
//! This module provides the HTTP client type required by `libdd_trace_utils`
77
//! for sending traces and stats to Datadog intake endpoints.
88
99
use hyper_http_proxy;
1010
use hyper_rustls::HttpsConnectorBuilder;
11-
use libdd_common::{GenericHttpClient, hyper_migration};
11+
use libdd_common::{GenericHttpClient, http_common};
1212
use rustls::RootCertStore;
1313
use rustls_pki_types::CertificateDer;
1414
use std::error::Error;
@@ -20,7 +20,7 @@ use tracing::debug;
2020
/// Type alias for the HTTP client used by trace and stats flushers.
2121
///
2222
/// This is the client type expected by `libdd_trace_utils::SendData::send()`.
23-
pub type HyperClient =
23+
pub type HttpClient =
2424
GenericHttpClient<hyper_http_proxy::ProxyConnector<libdd_common::connector::Connector>>;
2525

2626
/// Initialize the crypto provider needed for setting custom root certificates.
@@ -35,7 +35,7 @@ fn ensure_crypto_provider_initialized() {
3535
let () = &*INIT_CRYPTO_PROVIDER;
3636
}
3737

38-
/// Creates a new hyper-based HTTP client with the given configuration.
38+
/// Creates a new HTTP client with the given configuration.
3939
///
4040
/// This client is compatible with `libdd_trace_utils` and supports:
4141
/// - HTTPS proxy configuration
@@ -54,7 +54,7 @@ fn ensure_crypto_provider_initialized() {
5454
pub fn create_client(
5555
proxy_https: Option<&String>,
5656
tls_cert_file: Option<&String>,
57-
) -> Result<HyperClient, Box<dyn Error>> {
57+
) -> Result<HttpClient, Box<dyn Error>> {
5858
// Create the base connector with optional custom TLS config
5959
let connector = if let Some(ca_cert_path) = tls_cert_file {
6060
// Ensure crypto provider is initialized before creating TLS config
@@ -84,10 +84,7 @@ pub fn create_client(
8484
.enable_http1()
8585
.build();
8686

87-
debug!(
88-
"HYPER_CLIENT | Added root certificate from {}",
89-
ca_cert_path
90-
);
87+
debug!("HTTP_CLIENT | Added root certificate from {}", ca_cert_path);
9188

9289
// Construct the Connector::Https variant directly
9390
libdd_common::connector::Connector::Https(https_connector)
@@ -100,14 +97,14 @@ pub fn create_client(
10097
let proxy =
10198
hyper_http_proxy::Proxy::new(hyper_http_proxy::Intercept::Https, proxy.parse()?);
10299
let proxy_connector = hyper_http_proxy::ProxyConnector::from_proxy(connector, proxy)?;
103-
let client = hyper_migration::client_builder().build(proxy_connector);
100+
let client = http_common::client_builder().build(proxy_connector);
104101
debug!(
105-
"HYPER_CLIENT | Proxy connector created with proxy: {:?}",
102+
"HTTP_CLIENT | Proxy connector created with proxy: {:?}",
106103
proxy_https
107104
);
108105
Ok(client)
109106
} else {
110107
let proxy_connector = hyper_http_proxy::ProxyConnector::new(connector)?;
111-
Ok(hyper_migration::client_builder().build(proxy_connector))
108+
Ok(http_common::client_builder().build(proxy_connector))
112109
}
113110
}

bottlecap/src/traces/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// SPDX-License-Identifier: Apache-2.0
33

44
pub mod context;
5-
pub mod hyper_client;
5+
pub mod http_client;
66
pub mod propagation;
77
pub mod proxy_aggregator;
88
pub mod proxy_flusher;

bottlecap/src/traces/stats_flusher.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use tokio::sync::OnceCell;
88

99
use crate::config;
1010
use crate::lifecycle::invocation::processor::S_TO_MS;
11-
use crate::traces::hyper_client::{self, HyperClient};
11+
use crate::traces::http_client::{self, HttpClient};
1212
use crate::traces::stats_aggregator::StatsAggregator;
1313
use dogstatsd::api_key::ApiKeyFactory;
1414
use libdd_common::Endpoint;
@@ -24,7 +24,7 @@ pub struct StatsFlusher {
2424
/// Cached HTTP client, lazily initialized on first use.
2525
/// TODO: `StatsFlusher` and `TraceFlusher` both hit trace.agent.datadoghq.{site} and could
2626
/// share a single HTTP client for better connection pooling.
27-
http_client: OnceCell<HyperClient>,
27+
http_client: OnceCell<HttpClient>,
2828
}
2929

3030
impl StatsFlusher {
@@ -72,6 +72,7 @@ impl StatsFlusher {
7272
api_key: Some(api_key_clone.into()),
7373
timeout_ms: self.config.flush_timeout * S_TO_MS,
7474
test_token: None,
75+
use_system_resolver: false,
7576
}
7677
}
7778
})
@@ -176,11 +177,11 @@ impl StatsFlusher {
176177
///
177178
/// Returns `None` if client creation fails. The error is logged but not cached,
178179
/// allowing retry on subsequent calls.
179-
async fn get_or_init_http_client(&self) -> Option<&HyperClient> {
180+
async fn get_or_init_http_client(&self) -> Option<&HttpClient> {
180181
match self
181182
.http_client
182183
.get_or_try_init(|| async {
183-
hyper_client::create_client(
184+
http_client::create_client(
184185
self.config.proxy_https.as_ref(),
185186
self.config.tls_cert_file.as_ref(),
186187
)

bottlecap/src/traces/stats_processor.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ use axum::{
1212
use tokio::sync::mpsc::Sender;
1313
use tracing::{debug, error};
1414

15-
use libdd_common::hyper_migration;
15+
use libdd_common::http_common;
1616
use libdd_trace_protobuf::pb;
1717
use libdd_trace_utils::stats_utils;
1818

19-
use super::trace_agent::MAX_CONTENT_LENGTH;
2019
use crate::http::extract_request_body;
20+
use crate::traces::trace_agent::MAX_CONTENT_LENGTH;
2121

2222
#[async_trait]
2323
pub trait StatsProcessor {
@@ -66,7 +66,7 @@ impl StatsProcessor for ServerlessStatsProcessor {
6666
// deserialize trace stats from the request body, convert to protobuf structs (see
6767
// trace-protobuf crate)
6868
let mut stats: pb::ClientStatsPayload =
69-
match stats_utils::get_stats_from_request_body(hyper_migration::Body::from_bytes(body))
69+
match stats_utils::get_stats_from_request_body(http_common::Body::from_bytes(body))
7070
.await
7171
{
7272
Ok(result) => result,

bottlecap/src/traces/trace_agent.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ use crate::{
4343
trace_processor,
4444
},
4545
};
46-
use libdd_common::hyper_migration;
46+
use libdd_common::http_common;
4747
use libdd_trace_protobuf::pb;
4848
use libdd_trace_utils::trace_utils::{self};
4949

@@ -503,22 +503,22 @@ impl TraceAgent {
503503

504504
let tracer_header_tags = (&parts.headers).into();
505505

506-
let (body_size, mut traces) = match version {
507-
ApiVersion::V04 => match trace_utils::get_traces_from_request_body(
508-
hyper_migration::Body::from_bytes(body),
509-
)
510-
.await
511-
{
512-
Ok(result) => result,
513-
Err(err) => {
514-
return error_response(
515-
StatusCode::INTERNAL_SERVER_ERROR,
516-
format!("Error deserializing trace from request body: {err}"),
517-
);
506+
let (body_size, mut traces): (usize, Vec<Vec<pb::Span>>) = match version {
507+
ApiVersion::V04 => {
508+
match trace_utils::get_traces_from_request_body(http_common::Body::from_bytes(body))
509+
.await
510+
{
511+
Ok(result) => result,
512+
Err(err) => {
513+
return error_response(
514+
StatusCode::INTERNAL_SERVER_ERROR,
515+
format!("Error deserializing trace from request body: {err}"),
516+
);
517+
}
518518
}
519-
},
519+
}
520520
ApiVersion::V05 => match trace_utils::get_v05_traces_from_request_body(
521-
hyper_migration::Body::from_bytes(body),
521+
http_common::Body::from_bytes(body),
522522
)
523523
.await
524524
{

0 commit comments

Comments
 (0)