Skip to content
Draft
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
440 changes: 364 additions & 76 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion crates/capabilities/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ http = "1"
bytes = "1.4"
futures-core = "0.3"
anyhow = "1"
libdd-capabilities = { git = "https://github.com/DataDog/libdatadog.git", tag = "v43.0.0" }
libdd-capabilities = { git = "https://github.com/DataDog/libdatadog.git", rev = "3bb89cfd2ce3c6f4ee3e4009c74a77e4cf89adf8" }

[dev-dependencies]
wasm-bindgen-test = "0.3"
10 changes: 5 additions & 5 deletions crates/pipeline/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ js-sys = "0.3"
serde = { version = "1.0", features = ["derive"] }
serde_json = "1"
libdatadog-nodejs-capabilities = { path = "../capabilities" }
libdd-capabilities = { git = "https://github.com/DataDog/libdatadog.git", tag = "v43.0.0" }
libdd-common = { git = "https://github.com/DataDog/libdatadog.git", tag = "v43.0.0", default-features = false }
libdd-data-pipeline = { git = "https://github.com/DataDog/libdatadog.git", tag = "v43.0.0", default-features = false, features = ["telemetry"] }
libdd-trace-utils = { git = "https://github.com/DataDog/libdatadog.git", tag = "v43.0.0", default-features = false, features = ["change-buffer"] }
libdd-shared-runtime = { git = "https://github.com/DataDog/libdatadog.git", tag = "v43.0.0", default-features = false }
libdd-capabilities = { git = "https://github.com/DataDog/libdatadog.git", rev = "3bb89cfd2ce3c6f4ee3e4009c74a77e4cf89adf8" }
libdd-common = { git = "https://github.com/DataDog/libdatadog.git", rev = "3bb89cfd2ce3c6f4ee3e4009c74a77e4cf89adf8", default-features = false }
libdd-data-pipeline = { git = "https://github.com/DataDog/libdatadog.git", rev = "3bb89cfd2ce3c6f4ee3e4009c74a77e4cf89adf8", default-features = false, features = ["telemetry"] }
libdd-trace-utils = { git = "https://github.com/DataDog/libdatadog.git", rev = "3bb89cfd2ce3c6f4ee3e4009c74a77e4cf89adf8", default-features = false, features = ["change-buffer"] }
libdd-shared-runtime = { git = "https://github.com/DataDog/libdatadog.git", rev = "3bb89cfd2ce3c6f4ee3e4009c74a77e4cf89adf8", default-features = false }
console_error_panic_hook = "0.1"

[target.'cfg(target_arch = "wasm32")'.dependencies]
Expand Down
4 changes: 2 additions & 2 deletions crates/remote_config/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ description = "Wasm binding for libdatadog's remote config client"
crate-type = ["cdylib", "rlib"]

[dependencies]
libdd-remote-config = { git = "https://github.com/DataDog/libdatadog.git", tag = "v43.0.0", default-features = false, features = ["client", "agentless"] }
libdd-common = { git = "https://github.com/DataDog/libdatadog.git", tag = "v43.0.0", default-features = false }
libdd-remote-config = { git = "https://github.com/DataDog/libdatadog.git", rev = "3bb89cfd2ce3c6f4ee3e4009c74a77e4cf89adf8", default-features = false, features = ["client", "agentless"] }
libdd-common = { git = "https://github.com/DataDog/libdatadog.git", rev = "3bb89cfd2ce3c6f4ee3e4009c74a77e4cf89adf8", default-features = false }
libdatadog-nodejs-capabilities = { path = "../capabilities" }

wasm-bindgen = "0.2"
Expand Down
27 changes: 10 additions & 17 deletions crates/remote_config/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,11 @@ struct FetcherOptions {
process_tags: Vec<String>,
language: String,
tracer_version: String,
/// In agent mode the agent base URL, either `http(s)://host:port` or `unix:///path/to/socket`;
/// in agentless mode the Datadog site, e.g. `https://api.datadoghq.com`.
/// The Datadog site, e.g. `https://api.datadoghq.com`.
url: String,
timeout_ms: u64,
/// Enables agentless if set.
#[serde(default)]
api_key: Option<String>,
#[serde(default)]
hostname: Option<String>,
api_key: String,
hostname: String,
}

/// A single add/update/remove of one remote config file, as diffed against the previous poll.
Expand Down Expand Up @@ -134,11 +130,12 @@ struct FetcherConfig {
runtime_id: String,
client_id: String,
invariants: ConfigInvariants,
agentless: AgentlessConfig,
}

impl FetcherConfig {
async fn build(&self) -> Result<Fetcher, JsValue> {
Ok(SingleChangesFetcher::new(
Ok(SingleChangesFetcher::new_agentless(
SimpleFileStorage::default(),
self.target.clone(),
self.runtime_id.clone(),
Expand All @@ -149,6 +146,7 @@ impl FetcherConfig {
products: vec![],
capabilities: vec![],
},
self.agentless.clone(),
WasmCapabilities::new_without_connection_pooling(),
)
.await
Expand Down Expand Up @@ -188,17 +186,11 @@ impl RemoteConfigFetcher {
let endpoint = libdd_common::Endpoint {
url,
timeout_ms: options.timeout_ms,
api_key: options.api_key.map(Into::into),
api_key: Some(options.api_key.into()),
..Default::default()
};

let agentless = match endpoint.api_key {
Some(_) => Some(
AgentlessConfig::new(options.hostname.unwrap_or_default(), &endpoint)
.map_err(to_js_err)?,
),
None => None,
};
let agentless = AgentlessConfig::new(options.hostname, &endpoint).map_err(to_js_err)?;

let config = FetcherConfig {
target: Target::new(
Expand All @@ -214,8 +206,9 @@ impl RemoteConfigFetcher {
language: options.language,
tracer_version: options.tracer_version,
endpoint,
agentless,
agentless: None,
},
agentless,
};

Ok(RemoteConfigFetcher {
Expand Down
1 change: 1 addition & 0 deletions packages/libdatadog/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ published separately as `@datadog/libdatadog-extras`.

Remote configuration is available from `@datadog/libdatadog/remote-config`.
It uses a dedicated wasm-bindgen artifact that loads only with this entry point.
The fetcher is agentless and requires an API key and hostname.

The package accepts Datadog v0.4 MessagePack payloads and exports them to an
agentless intake. `sendV04()` reports completion through a callback and sends
Expand Down
12 changes: 12 additions & 0 deletions packages/libdatadog/test/remote-config.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ test('keeps remote config out of the universal WASM entry point', () => {
assert.strictEqual(typeof RemoteConfigFetcher, 'function')
})

test('requires agentless credentials', () => {
for (const name of ['apiKey', 'hostname']) {
const options = fetcherOptions()
delete options[name]

assert.throws(
() => new RemoteConfigFetcher(options),
new RegExp('missing field `' + name + '`'),
)
}
})

test('exports agentless remote config from the dedicated entry point', async () => {
const requests = []
const storage = new AsyncLocalStorage()
Expand Down
2 changes: 2 additions & 0 deletions packages/libdatadog/test/types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ const remoteConfigFetcher = new RemoteConfigFetcher({
tracerVersion: '1.0.0',
url: 'http://127.0.0.1:8126',
timeoutMs: 5000,
apiKey: 'api-key',
hostname: 'host',
})

remoteConfigFetcher.setExtraServices([])
Expand Down
4 changes: 2 additions & 2 deletions packages/libdatadog/wasm/remote-config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export interface RemoteConfigFetcherOptions {
tracerVersion: string
url: string
timeoutMs: number
apiKey?: string
hostname?: string
apiKey: string
hostname: string
}

export interface RemoteConfigChange {
Expand Down
Loading