feat(libdatadog): add apm data pipeline - #205
Conversation
Overall package sizeSelf size: 52.79 MB Dependency sizes| name | version | self size | total size | |------|---------|-----------|------------|🤖 This report was automatically generated by heaviest-objects-in-the-universe |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 5040c623ed
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| } | ||
|
|
||
| #[derive(Clone, Debug)] | ||
| struct WasmCapabilities; |
There was a problem hiding this comment.
Is there a reason to not use the existing wasm implementation ? You seem to be doing the same thing all over again as crates/capabilities of this repository.
There was a problem hiding this comment.
Plus, you seem to lose some of the features / introduce regressions
There was a problem hiding this comment.
Is there a reason to not use the existing wasm implementation ? You seem to be doing the same thing all over again as crates/capabilities of this repository.
We cannot use libdatadog as a do-everything package. Right now the repository is in a pretty bad state and we need to split it up better, but in the meantime this was the only way to ship something usable quickly.
Plus, you seem to lose some of the features / introduce regressions
Can you enumerate them?
There was a problem hiding this comment.
Actually, let me look into that further, I think I have an idea to minimally restructure the library and allow shipping things in a way that will work for all consumers.
| libdd-capabilities-impl = { git = "https://github.com/DataDog/libdatadog.git", rev = "4678752b4be5bec7e55112598eb1b9491ddd9cc6" } | ||
| libdd-data-pipeline = { git = "https://github.com/DataDog/libdatadog.git", rev = "4678752b4be5bec7e55112598eb1b9491ddd9cc6" } | ||
| libdd-shared-runtime = { git = "https://github.com/DataDog/libdatadog.git", rev = "4678752b4be5bec7e55112598eb1b9491ddd9cc6" } |
There was a problem hiding this comment.
It would be better to use release version of these on crates.io, or release tags of github at least. We can release and/or publish if need be.
There was a problem hiding this comment.
You might want to add similar options as root level Cargo.toml, depending on what you wish you can have link time optimizations, optimize the artifact for size, stripping the binary etc.
In fact you could want to have it another artifact of the top level workspace, instead of making a workspace here.
There was a problem hiding this comment.
You might want to add similar options as root level Cargo.toml, depending on what you wish you can have link time optimizations, optimize the artifact for size, stripping the binary etc.
For some reason the binary is small anyway, but will look into it further.
In fact you could want to have it another artifact of the top level workspace, instead of making a workspace here.
Then it would be shipped with the root package which we cannot use.
| # The agentless v0.4 path does not compile or evaluate user-provided patterns. | ||
| # Use the smaller regex engine so the full engine and its Unicode tables are | ||
| # removed by the WASM linker. | ||
| libdd-common = { git = "https://github.com/DataDog/libdatadog.git", rev = "4678752b4be5bec7e55112598eb1b9491ddd9cc6", default-features = false, features = ["regex-lite"] } |
There was a problem hiding this comment.
It seems like you don't actually use libdd-common, if this is "just" to enable regex-lite, you should be able to do it directly from libdd-data-pipeline, if not it's something we should fix our side, but I'm pretty sure it's the case.
| let exporter = self.take_exporter()?; | ||
| let result = exporter | ||
| .send_async(payload.as_ref()) | ||
| .await | ||
| .map(|_| ()) | ||
| .map_err(|error| Error::from_reason(format!("data-pipeline export failed: {error}"))); | ||
| self.restore_exporter(exporter)?; |
There was a problem hiding this comment.
If the future is dropped in flight, the teardown happens and restore_exporter is never called, is it ? That would brick the exporter.
| .as_f64() | ||
| .filter(|number| number.is_finite() && *number >= 0.0 && *number <= f64::from(u32::MAX)) | ||
| .ok_or_else(|| JsValue::from_str(&format!("{key} must be an unsigned integer")))?; | ||
| Ok(Some(number as u32)) |
| .filter(|number| number.is_finite() && *number >= 0.0 && *number <= f64::from(u32::MAX)) | ||
| .ok_or_else(|| JsValue::from_str(&format!("{key} must be an unsigned integer")))?; |
There was a problem hiding this comment.
nit: iiuc, this would accept floats, even though the error says uint.
|
|
||
| fn optional_string(value: &JsValue, key: &str) -> Result<Option<String>, JsValue> { | ||
| let value = Reflect::get(value, &JsValue::from_str(key))?; | ||
| if value.is_undefined() { |
There was a problem hiding this comment.
Shouldn't null have the same behaviour here ?
| )) | ||
| })?; | ||
| let body = Reflect::get(&response, &JsValue::from_str("body")).map_err(js_error)?; | ||
| let body = Uint8Array::new(&body).to_vec(); |
There was a problem hiding this comment.
status is validated just above with .as_f64().ok_or_else(...), but body isn't. new Uint8Array(x) doesn't throw on bad input, a non-object is treated as a length, so body: 123 yields 123 zero bytes and body: undefined yields an empty one, so a malformed response would silently become plausible-looking data rather than an error
| let _guard = SleepGuard(promise.clone()); | ||
| let _ = JsFuture::from(promise).await; |
There was a problem hiding this comment.
nit: SleepGuard fires cancelSleep even on normal completion, clearTimeout on a fired timer is a no-op, so harmless, but a wasted boundary crossing per retry.
|
Also, just noticed the compression feature is not active here, if it's not a deliberate choice you might want to turn that on. |
bengl
left a comment
There was a problem hiding this comment.
There are simply too many changes in this PR unrelated to the PR title, making it very difficult to review.
| match res_config { | ||
| Ok(config) => { | ||
| let config_entries: Vec<ConfigEntry> = config | ||
| let envp = self |
There was a problem hiding this comment.
For readability, please keep stylistic changes to separate PRs unless the linter forces you into it.
There was a problem hiding this comment.
717d360 to
7195850
Compare
|
The reviewability concern is addressed with a real GitHub stack: #207 contains the package foundation, this PR contains only the APM data pipeline, and #208 contains reporting/guardrails. |
7195850 to
11737ee
Compare
11737ee to
bba341d
Compare
| requests.get(id)?.cancel() | ||
| } | ||
|
|
||
| function sleep (id, milliseconds) { |
There was a problem hiding this comment.
Let's fix capabilities at some point so we don't have to do this weird sleep (TODO/non-blocker)
d546bbb to
2c86378
Compare
2c86378 to
ed2d9da
Compare
ed2d9da to
4e0885b
Compare
|
@Aaalibaba42 The implementation was basically rewritten at this point, please have another look. The PR is significantly smaller as unrelated changes were moved to other PRs in the stack. |
Summary
Adds the APM data pipeline to the universal package introduced by the previous
PR in this stack. Native and WASM expose equivalent pipeline behavior while
sharing the retry, timeout, and backoff implementation in Rust.
Details
data_pipelinebindings backed by libdatadog revision322d9336fed24dcf78a214f488b0fd3fb9583ba6.pipeline orchestration and retries in Rust.
wasm-bindgen-futuresfor WASM.backoff.
Package restructuring belongs to the previous PR; dependency and binary-size
reporting belongs to the next PR. This PR is now only the data-pipeline delta.
Validation
timeouts, cancellation, idle-process behavior, and worker teardown.
Generated by Codex.
Stack created with GitHub Stacks CLI • Give Feedback 💬