feat(machine id): Add helpers in ddcommon to fetch the machine UUID l…#2163
feat(machine id): Add helpers in ddcommon to fetch the machine UUID l…#2163paullegranddc wants to merge 8 commits into
Conversation
…ike the agent # Motivation We are replicating the agent RC client. One of the thing the agent uses is a stable identity for the agent host, decorrelated from the hostname (as it is not available in som platforms). It fetches the UUID using a library (psutils), for which there exists no strict equivalent in rust. This PR adds code that should be feature equal to the agent # Changes * Add new machine_id module in libdd-common * Fetch machine id on different platform
📚 Documentation Check Results📦
|
Clippy Allow Annotation ReportComparing clippy allow annotations between branches:
Summary by Rule
Annotation Counts by File
Annotation Stats by Crate
About This ReportThis report tracks Clippy allow annotations for specific rules, showing how they've changed in this PR. Decreasing the number of these annotations generally improves code quality. |
🔒 Cargo Deny Results📦
|
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 4b722f4 | Docs | Datadog PR Page | Give us feedback! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e17eaed888
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| &mut hkey, | ||
| ) | ||
| }; | ||
| if status != ERROR_SUCCESS as i32 { |
There was a problem hiding this comment.
Keep Windows status comparisons in u32
On Windows this module fails to type-check because windows-sys 0.52 defines RegOpenKeyExW/RegQueryValueExW as returning WIN32_ERROR (u32), but these checks compare that u32 to ERROR_SUCCESS as i32. Any Windows build of libdd-common that includes this new module will fail before use; compare against ERROR_SUCCESS without the cast here and in the two RegQueryValueExW status checks.
Useful? React with 👍 / 👎.
ekump
left a comment
There was a problem hiding this comment.
LGTM FWIW. I found the code confusing, so suggested some more comments.
| } | ||
|
|
||
| pub fn get_machine_id_impl() -> String { | ||
| let access = if cfg!(target_pointer_width = "32") && is_wow64() { |
There was a problem hiding this comment.
nit: Do you need is_wow64()? The agent always does KEY_READ_ | KEY_WOW64_64KEY Won't KEY_WOW64_64KEY be a no-op on 64-bit?
There was a problem hiding this comment.
Yeah, probably not necessary. I got confused by microsoft doc and claude got defensive
ekump
left a comment
There was a problem hiding this comment.
LGTM FWIW. I found the code confusing, so suggested some more comments.
Artifact Size Benchmark Reportaarch64-alpine-linux-musl
aarch64-unknown-linux-gnu
libdatadog-x64-windows
libdatadog-x86-windows
x86_64-alpine-linux-musl
x86_64-unknown-linux-gnu
|
…ike the agent
Motivation
We are replicating the agent RC client. One of the thing the agent uses is a stable identity for the agent host, decorrelated from the hostname (as it is not available in som platforms).
It fetches the UUID using a library (psutils), for which there exists no strict equivalent in rust.
This PR adds code that should be feature equal to the agent
Changes
What does this PR do?
A brief description of the change being made with this pull request.
Motivation
What inspired you to submit this pull request?
Additional Notes
Anything else we should know when reviewing?
How to test the change?
Describe here in detail how the change can be validated.