feat(library-config): add macOS and Windows process context#2238
feat(library-config): add macOS and Windows process context#2238cataphract wants to merge 3 commits into
Conversation
📚 Documentation Check Results📦
|
🔒 Cargo Deny Results📦
|
BenchmarksComparisonBenchmark execution time: 2026-07-14 23:41:01 Comparing candidate commit 954186b in PR branch Found 0 performance improvements and 2 performance regressions! Performance is the same for 140 metrics, 0 unstable metrics.
|
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 011c154962
ℹ️ 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".
| for module in modules.into_iter().take(actual_module_count) { | ||
| // SAFETY: module was returned by K32EnumProcessModules and the symbol name is | ||
| // NUL-terminated. | ||
| let symbol = unsafe { GetProcAddress(module, c"otel_process_ctx_v2".as_ptr().cast()) }; |
There was a problem hiding this comment.
Export the Windows context symbol
On Windows this path only searches each module's PE export table via GetProcAddress (reader/windows.rs:105). The writer symbol is only #[no_mangle]; when libdd is consumed as a staticlib and linked into another executable/DLL, that does not create a PE export, so a reader built without process-context-writer cannot discover metadata published by the static writer and reports NotFound. Please add the same kind of export directive/dllexport for the production symbol that the test has to add explicitly.
Useful? React with 👍 / 👎.
| fn make_discoverable(&mut self) { | ||
| otel_process_ctx_v2.store(self.start_addr.as_ptr().cast(), Ordering::Release); |
There was a problem hiding this comment.
Clear stale macOS context pointers after fork
On macOS, when minherit(..., VM_INHERIT_NONE) succeeds, a forked child does not inherit the mmap but it does inherit this non-null atomic pointer. reader/macos.rs::discover_header treats any non-null value as published, so a child that creates a reader before republishing caches an unmapped address and read() returns the retryable EFAULT/WouldBlock path instead of NotFound. Forking runtimes can then spin on a context that can never become readable until something republishes; clear or validate the exported pointer after fork before making it discoverable.
Useful? React with 👍 / 👎.
| target_os = "linux", | ||
| any(feature = "process-context-reader", feature = "process-context-writer") | ||
| ))] | ||
| #[cfg(any(feature = "process-context-reader", feature = "process-context-writer"))] |
There was a problem hiding this comment.
Keep process context gated to supported OSes
With process-context-writer still enabled by default, this now compiles otel_process_ctx on every target, but the module only defines the writer/reader platform types for Linux, macOS, and Windows. Any default-feature build of libdd-library-config for another target now fails at compile time instead of simply omitting process-context support as before; please keep this top-level cfg restricted to the OSes with implementations or add fallback stubs.
Useful? React with 👍 / 👎.
011c154 to
7c33bad
Compare
e5a142d to
a9e0f0e
Compare
🎉 All green!🧪 All tests passed 🎯 Code Coverage (details) 🔗 Commit SHA: 954186b | Docs | Datadog PR Page | Give us feedback! |
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
|
a9e0f0e to
97138bc
Compare
7122e8d to
954186b
Compare
What does this PR do?
This is 3/3 in the stacked process-context series and depends on #2237.
It adds process-context publishing and same-process reading on macOS and Windows while reusing the shared protocol introduced by the preceding PRs:
otel_process_ctx_v2and discovers it withdlsym;GetProcAddress;Why?
The OpenTelemetry process-context discovery convention based on
/proc/self/mapsis Linux-specific. macOS and Windows therefore need an explicit exported-symbol discovery mechanism and platform-native memory-copy primitives, while the publication format and reader validation can remain shared.Keeping this as the top layer isolates the new platform support from the Linux reorganization in #2228 and the Linux behavior updates in #2237.
Impact
The platform-agnostic process-context API now works on Linux, macOS, and Windows. Linux behavior is unchanged by this layer. On macOS and Windows, tracer metadata can be published and read within the current process through the exported process-context symbol.
Validation
Validated at this commit with:
Stack