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
87 changes: 46 additions & 41 deletions bottlecap/Cargo.lock

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

14 changes: 7 additions & 7 deletions bottlecap/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ indexmap = {version = "2.11.0", default-features = false}
# be found in the clippy.toml file adjacent to this Cargo.toml.
datadog-protos = { version = "0.1.0", default-features = false, git = "https://github.com/DataDog/saluki/", rev = "f863626dbfe3c59bb390985fa6530b0621c2a0a2"}
ddsketch-agent = { version = "0.1.0", default-features = false, git = "https://github.com/DataDog/saluki/", rev = "f863626dbfe3c59bb390985fa6530b0621c2a0a2"}
libdd-capabilities = { git = "https://github.com/DataDog/libdatadog", rev = "db05e1f8408a76075efb37ecec544d2e74217e57" }
libdd-common = { git = "https://github.com/DataDog/libdatadog", rev = "db05e1f8408a76075efb37ecec544d2e74217e57", default-features = false }
libdd-trace-protobuf = { git = "https://github.com/DataDog/libdatadog", rev = "db05e1f8408a76075efb37ecec544d2e74217e57" }
libdd-trace-utils = { git = "https://github.com/DataDog/libdatadog", rev = "db05e1f8408a76075efb37ecec544d2e74217e57", default-features = false, features = ["mini_agent"] }
libdd-trace-normalization = { git = "https://github.com/DataDog/libdatadog", rev = "db05e1f8408a76075efb37ecec544d2e74217e57" }
libdd-trace-obfuscation = { git = "https://github.com/DataDog/libdatadog", rev = "db05e1f8408a76075efb37ecec544d2e74217e57", default-features = false }
libdd-trace-stats = { git = "https://github.com/DataDog/libdatadog", rev = "db05e1f8408a76075efb37ecec544d2e74217e57", default-features = false }
libdd-capabilities = { git = "https://github.com/DataDog/libdatadog", rev = "48da0d82cb32b43d4cdece35b794c9bcbc275a03" }
libdd-common = { git = "https://github.com/DataDog/libdatadog", rev = "48da0d82cb32b43d4cdece35b794c9bcbc275a03", default-features = false }
libdd-trace-protobuf = { git = "https://github.com/DataDog/libdatadog", rev = "48da0d82cb32b43d4cdece35b794c9bcbc275a03" }
libdd-trace-utils = { git = "https://github.com/DataDog/libdatadog", rev = "48da0d82cb32b43d4cdece35b794c9bcbc275a03", default-features = false, features = ["mini_agent"] }
libdd-trace-normalization = { git = "https://github.com/DataDog/libdatadog", rev = "48da0d82cb32b43d4cdece35b794c9bcbc275a03" }
libdd-trace-obfuscation = { git = "https://github.com/DataDog/libdatadog", rev = "48da0d82cb32b43d4cdece35b794c9bcbc275a03", default-features = false }
libdd-trace-stats = { git = "https://github.com/DataDog/libdatadog", rev = "48da0d82cb32b43d4cdece35b794c9bcbc275a03", default-features = false }
datadog-opentelemetry = { git = "https://github.com/DataDog/dd-trace-rs", rev = "f51cefc4ad24bec81b38fb2f36b1ed93f21ae913", default-features = false }
dogstatsd = { git = "https://github.com/DataDog/serverless-components", rev = "5b68f50f49c9defbfed4d25bd621e2a86405a972", default-features = false }
datadog-fips = { git = "https://github.com/DataDog/serverless-components", rev = "5b68f50f49c9defbfed4d25bd621e2a86405a972", default-features = false }
Expand Down
26 changes: 21 additions & 5 deletions bottlecap/src/traces/http_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ use hyper_http_proxy;
use hyper_rustls::HttpsConnectorBuilder;
use libdd_capabilities::{
MaybeSend,
http::{HttpClientTrait, HttpError},
http::{HttpClientCapability, HttpError},
sleep::SleepCapability,
};
use libdd_common::http_common::{self, Body, GenericHttpClient};
use rustls::RootCertStore;
Expand All @@ -21,6 +22,7 @@ use std::fs::File;
use std::future::Future;
use std::io::BufReader;
use std::sync::{Arc, LazyLock};
use std::time::Duration;
use tracing::debug;

type InnerClient =
Expand All @@ -29,8 +31,8 @@ type InnerClient =
/// HTTP client used by trace and stats flushers.
///
/// Wraps a hyper client preconfigured with optional proxy and TLS settings, and
/// implements [`HttpClientTrait`] so it can be passed to `libdd_trace_utils`
/// senders such as `SendData::send`.
/// implements [`HttpClientCapability`] and [`SleepCapability`] so it can be
/// passed to `libdd_trace_utils` senders such as `SendData::send`.
#[derive(Clone, Debug)]
pub struct HttpClient {
inner: InnerClient,
Expand All @@ -42,10 +44,10 @@ impl HttpClient {
}
}

impl HttpClientTrait for HttpClient {
impl HttpClientCapability for HttpClient {
#[allow(clippy::expect_used)]
fn new_client() -> Self {
// Required by `HttpClientTrait` but never invoked on bottlecap's code
// Required by `HttpClientCapability` but never invoked on bottlecap's code
// paths — production builds the client via
// `create_client(proxy, tls_cert, skip_ssl)`. Routing this fallback
// through the same constructor keeps the failure mode and error
Expand Down Expand Up @@ -76,6 +78,20 @@ impl HttpClientTrait for HttpClient {
}
}

impl SleepCapability for HttpClient {
Comment thread
lucaspimentel marked this conversation as resolved.
fn new() -> Self {
// Required by `SleepCapability` but never invoked on bottlecap's code
// paths — production builds the client via
// `create_client(proxy, tls_cert, skip_ssl)`. Mirror `new_client()` so
// the failure mode stays consistent with the rest of the module.
<Self as HttpClientCapability>::new_client()
}

fn sleep(&self, duration: Duration) -> impl Future<Output = ()> + MaybeSend {
tokio::time::sleep(duration)
}
}

/// Initialize the crypto provider needed for setting custom root certificates.
fn ensure_crypto_provider_initialized() {
static INIT_CRYPTO_PROVIDER: LazyLock<()> = LazyLock::new(|| {
Expand Down
2 changes: 1 addition & 1 deletion bottlecap/src/traces/stats_flusher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::traces::http_client::HttpClient;
use crate::traces::stats_aggregator::StatsAggregator;
use bytes::Bytes;
use dogstatsd::api_key::ApiKeyFactory;
use libdd_capabilities::http::HttpClientTrait;
use libdd_capabilities::http::HttpClientCapability;
use libdd_common::Endpoint;
use libdd_trace_protobuf::pb;
use libdd_trace_utils::stats_utils;
Expand Down
Loading
Loading