From 39c22b5bb8ed61487aa29de6c5da52c002a3e8b9 Mon Sep 17 00:00:00 2001 From: vianney Date: Wed, 18 Sep 2024 15:02:58 +0200 Subject: [PATCH] Move agent-info to data-pipeline --- Cargo.lock | 19 ++++----------- Cargo.toml | 2 -- agent-info/Cargo.toml | 24 ------------------- data-pipeline/Cargo.toml | 6 +++++ .../src/agent_info}/fetcher.rs | 12 ++++++---- .../src/agent_info/mod.rs | 0 .../src/agent_info}/schema.rs | 0 data-pipeline/src/lib.rs | 1 + .../tests/test_fetch_info.rs | 4 ++-- tools/docker/Dockerfile.build | 7 +++--- 10 files changed, 24 insertions(+), 51 deletions(-) delete mode 100644 agent-info/Cargo.toml rename {agent-info/src => data-pipeline/src/agent_info}/fetcher.rs (97%) rename agent-info/src/lib.rs => data-pipeline/src/agent_info/mod.rs (100%) rename {agent-info/src => data-pipeline/src/agent_info}/schema.rs (100%) rename {agent-info => data-pipeline}/tests/test_fetch_info.rs (95%) diff --git a/Cargo.lock b/Cargo.lock index 1076592ee..037614124 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -17,21 +17,6 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" -[[package]] -name = "agent-info" -version = "13.0.0" -dependencies = [ - "anyhow", - "arc-swap", - "datadog-trace-utils", - "ddcommon", - "httpmock", - "hyper 0.14.28", - "serde", - "serde_json", - "tokio", -] - [[package]] name = "ahash" version = "0.7.8" @@ -1359,6 +1344,7 @@ name = "data-pipeline" version = "13.0.0" dependencies = [ "anyhow", + "arc-swap", "bytes", "criterion", "datadog-ddsketch", @@ -1367,10 +1353,13 @@ dependencies = [ "datadog-trace-utils", "ddcommon", "futures", + "httpmock", "hyper 0.14.28", "log", "rand", "rmp-serde", + "serde", + "serde_json", "tokio", ] diff --git a/Cargo.toml b/Cargo.toml index 5c6091e44..90e67bf9a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,7 +34,6 @@ members = [ "data-pipeline-ffi", "ddsketch", "tinybytes", - "agent-info", ] default-members = [ @@ -70,7 +69,6 @@ default-members = [ "data-pipeline-ffi", "ddsketch", "tinybytes", - "agent-info", ] # https://doc.rust-lang.org/cargo/reference/resolver.html#feature-resolver-version-2 diff --git a/agent-info/Cargo.toml b/agent-info/Cargo.toml deleted file mode 100644 index 3d14fd8ce..000000000 --- a/agent-info/Cargo.toml +++ /dev/null @@ -1,24 +0,0 @@ -[package] -name = "agent-info" -description = "Provides utilities to get config from the /info endpoint of an agent" -rust-version.workspace = true -edition.workspace = true -version.workspace = true -license.workspace = true - -[lib] -bench = false - -[dependencies] -anyhow = "1.0.86" -arc-swap = "1.7.1" -ddcommon = { path = "../ddcommon" } -hyper = { version = "0.14", features = ["client"] } -serde = "1.0.209" -serde_json = "1.0.127" -tokio = "1.37.0" - -[dev-dependencies] -datadog-trace-utils = { path = "../trace-utils", features = ["test-utils"] } -httpmock = "0.7.0" -tokio = { version = "1.37.0", features = ["time", "test-util"] } diff --git a/data-pipeline/Cargo.toml b/data-pipeline/Cargo.toml index 556f38618..d930264b5 100644 --- a/data-pipeline/Cargo.toml +++ b/data-pipeline/Cargo.toml @@ -11,10 +11,13 @@ autobenches = false [dependencies] anyhow = { version = "1.0" } +arc-swap = "1.7.1" futures = { version = "0.3", default-features = false } hyper = {version = "0.14", features = ["client"], default-features = false} log = "0.4" rmp-serde = "1.1.1" +serde = "1.0.209" +serde_json = "1.0.127" bytes = "1.4" tokio = {version = "1.23", features = ["rt"], default-features = false} @@ -34,4 +37,7 @@ path = "benches/main.rs" [dev-dependencies] criterion = "0.5.1" +datadog-trace-utils = { path = "../trace-utils", features = ["test-utils"] } +httpmock = "0.7.0" rand = "0.8.5" +tokio = {version = "1.23", features = ["rt", "time", "test-util"], default-features = false} diff --git a/agent-info/src/fetcher.rs b/data-pipeline/src/agent_info/fetcher.rs similarity index 97% rename from agent-info/src/fetcher.rs rename to data-pipeline/src/agent_info/fetcher.rs index 34e3e1316..136364781 100644 --- a/agent-info/src/fetcher.rs +++ b/data-pipeline/src/agent_info/fetcher.rs @@ -3,7 +3,7 @@ //! Provides utilities to fetch the agent /info endpoint and an automatic fetcher to keep info //! up-to-date -use crate::{schema::AgentInfo, AgentInfoArc}; +use super::{schema::AgentInfo, AgentInfoArc}; use anyhow::{anyhow, Result}; use arc_swap::ArcSwapOption; use ddcommon::{connector::Connector, Endpoint}; @@ -66,7 +66,9 @@ async fn fetch_info_with_state( /// // Define the endpoint /// let endpoint = ddcommon::Endpoint::from_url("http://localhost:8126/info".parse().unwrap()); /// // Fetch the info -/// let agent_info = agent_info::fetch_info(&endpoint).await.unwrap(); +/// let agent_info = data_pipeline::agent_info::fetch_info(&endpoint) +/// .await +/// .unwrap(); /// println!("Agent version is {}", agent_info.info.version.unwrap()); /// # Ok(()) /// # } @@ -92,8 +94,10 @@ pub async fn fetch_info(info_endpoint: &Endpoint) -> Result> { /// // Define the endpoint /// let endpoint = ddcommon::Endpoint::from_url("http://localhost:8126/info".parse().unwrap()); /// // Create the fetcher -/// let fetcher = -/// agent_info::AgentInfoFetcher::new(endpoint, std::time::Duration::from_secs(5 * 60)); +/// let fetcher = data_pipeline::agent_info::AgentInfoFetcher::new( +/// endpoint, +/// std::time::Duration::from_secs(5 * 60), +/// ); /// // Get the Arc to access the info /// let agent_info_arc = fetcher.get_info(); /// // Start the runner diff --git a/agent-info/src/lib.rs b/data-pipeline/src/agent_info/mod.rs similarity index 100% rename from agent-info/src/lib.rs rename to data-pipeline/src/agent_info/mod.rs diff --git a/agent-info/src/schema.rs b/data-pipeline/src/agent_info/schema.rs similarity index 100% rename from agent-info/src/schema.rs rename to data-pipeline/src/agent_info/schema.rs diff --git a/data-pipeline/src/lib.rs b/data-pipeline/src/lib.rs index f0a1fcb61..aee3f1967 100644 --- a/data-pipeline/src/lib.rs +++ b/data-pipeline/src/lib.rs @@ -6,6 +6,7 @@ //! project at this state is to provide a basic API in order to test its viability and integration //! in different languages. +pub mod agent_info; #[allow(missing_docs)] pub mod span_concentrator; #[allow(missing_docs)] diff --git a/agent-info/tests/test_fetch_info.rs b/data-pipeline/tests/test_fetch_info.rs similarity index 95% rename from agent-info/tests/test_fetch_info.rs rename to data-pipeline/tests/test_fetch_info.rs index 2c3e81a2a..4803f0a83 100644 --- a/agent-info/tests/test_fetch_info.rs +++ b/data-pipeline/tests/test_fetch_info.rs @@ -4,7 +4,7 @@ #[cfg(test)] mod require_test_agent { mod fetch_info_test { - use agent_info::fetch_info; + use data_pipeline::agent_info::fetch_info; use datadog_trace_utils::test_utils::datadog_test_agent::DatadogTestAgent; use ddcommon::Endpoint; @@ -26,8 +26,8 @@ mod require_test_agent { } mod agent_info_fetcher_test { - use agent_info::AgentInfoFetcher; use arc_swap::access::Access; + use data_pipeline::agent_info::AgentInfoFetcher; use datadog_trace_utils::test_utils::datadog_test_agent::DatadogTestAgent; use ddcommon::Endpoint; use std::time::Duration; diff --git a/tools/docker/Dockerfile.build b/tools/docker/Dockerfile.build index 568e9d82c..bc0eeba96 100644 --- a/tools/docker/Dockerfile.build +++ b/tools/docker/Dockerfile.build @@ -20,7 +20,7 @@ ENV CARGO_HOME="/root/.cargo" WORKDIR /build RUN apk update \ - && apk add --no-cache \ + && apk add --no-cache \ build-base \ cargo \ cmake \ @@ -33,7 +33,7 @@ RUN apk update \ unzip \ bash \ clang16-libclang \ - && mkdir /usr/local/src + && mkdir /usr/local/src # Tell docker to use bash as the default SHELL ["/bin/bash", "-c"] @@ -45,7 +45,7 @@ SHELL ["/bin/bash", "-c"] FROM alpine_base as alpine_aws_cli RUN apk add --no-cache aws-cli \ - && rm -rf /var/cache/apk/* + && rm -rf /var/cache/apk/* RUN aws --version # Just to make sure its installed alright @@ -69,7 +69,6 @@ RUN cargo search nothing --limit 1 # create stubs to cache compilation of dependendencies COPY [ "Cargo.lock", "Cargo.toml", "./"] COPY "alloc/Cargo.toml" "alloc/" -COPY "agent-info/Cargo.toml" "agent-info/" COPY "build-common/Cargo.toml" "build-common/" COPY "crashtracker/Cargo.toml" "crashtracker/" COPY "crashtracker-ffi/Cargo.toml" "crashtracker-ffi/"