Skip to content

chore(otel-process-ctx): migrate from rustix to libc#1859

Open
yannham wants to merge 4 commits intomainfrom
yannham/process-ctx-migrate-libc
Open

chore(otel-process-ctx): migrate from rustix to libc#1859
yannham wants to merge 4 commits intomainfrom
yannham/process-ctx-migrate-libc

Conversation

@yannham
Copy link
Copy Markdown
Contributor

@yannham yannham commented Apr 9, 2026

What does this PR do?

Migrates the otel_process_ctx module in libdd-library-config from rustix to libc, removing the rustix dependency from that crate entirely.

Motivation

rustix uses the vDSO for some syscalls, which makes Valgrind chokes. This makes tests fail on the dd-trace-rb repo.

Additionally, while rustix offers a nice high-level API, this crate was the only one to use it as a direct dependency. While we may decide later to move toward rustix, I think this should be global to libdatadog, and not a per-crate choices (barring specifc situations/reasons). The change isn't too painful either.

Additional Notes

N/A

How to test the change?

N/A

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 9, 2026

📚 Documentation Check Results

⚠️ 150 documentation warning(s) found

📦 libdd-library-config - 150 warning(s)


Updated: 2026-04-10 11:47:13 UTC | Commit: 7539ed7 | missing-docs job results

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 9, 2026

Clippy Allow Annotation Report

Comparing clippy allow annotations between branches:

  • Base Branch: origin/main
  • PR Branch: origin/yannham/process-ctx-migrate-libc

Summary by Rule

Rule Base Branch PR Branch Change

Annotation Counts by File

File Base Branch PR Branch Change

Annotation Stats by Crate

Crate Base Branch PR Branch Change
clippy-annotation-reporter 5 5 No change (0%)
datadog-ffe-ffi 1 1 No change (0%)
datadog-ipc 21 21 No change (0%)
datadog-live-debugger 6 6 No change (0%)
datadog-live-debugger-ffi 10 10 No change (0%)
datadog-profiling-replayer 4 4 No change (0%)
datadog-remote-config 3 3 No change (0%)
datadog-sidecar 55 55 No change (0%)
libdd-common 10 10 No change (0%)
libdd-common-ffi 12 12 No change (0%)
libdd-data-pipeline 5 5 No change (0%)
libdd-ddsketch 2 2 No change (0%)
libdd-dogstatsd-client 1 1 No change (0%)
libdd-profiling 13 13 No change (0%)
libdd-telemetry 19 19 No change (0%)
libdd-tinybytes 4 4 No change (0%)
libdd-trace-normalization 2 2 No change (0%)
libdd-trace-obfuscation 8 8 No change (0%)
libdd-trace-utils 15 15 No change (0%)
Total 196 196 No change (0%)

About This Report

This 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.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 9, 2026

🔒 Cargo Deny Results

No issues found!

📦 libdd-library-config - ✅ No issues


Updated: 2026-04-10 11:49:07 UTC | Commit: 7539ed7 | dependency-check job results

@datadog-official
Copy link
Copy Markdown

datadog-official bot commented Apr 9, 2026

✅ Tests

🎉 All green!

❄️ No new flaky tests detected
🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 83.33%
Overall Coverage: 71.68% (-0.03%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 7b0145f | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback!

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 9, 2026

Codecov Report

❌ Patch coverage is 83.33333% with 11 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.67%. Comparing base (487fccc) to head (7b0145f).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1859      +/-   ##
==========================================
- Coverage   71.70%   71.67%   -0.04%     
==========================================
  Files         429      429              
  Lines       67887    67913      +26     
==========================================
- Hits        48681    48678       -3     
- Misses      19206    19235      +29     
Components Coverage Δ
libdd-crashtracker 66.05% <ø> (+0.01%) ⬆️
libdd-crashtracker-ffi 34.47% <ø> (ø)
libdd-alloc 98.77% <ø> (ø)
libdd-data-pipeline 86.14% <ø> (-0.13%) ⬇️
libdd-data-pipeline-ffi 72.50% <ø> (-0.68%) ⬇️
libdd-common 79.16% <ø> (ø)
libdd-common-ffi 73.87% <ø> (ø)
libdd-telemetry 65.98% <ø> (ø)
libdd-telemetry-ffi 16.75% <ø> (ø)
libdd-dogstatsd-client 82.64% <ø> (ø)
datadog-ipc 73.10% <ø> (ø)
libdd-profiling 82.13% <ø> (ø)
libdd-profiling-ffi 64.94% <ø> (ø)
datadog-sidecar 30.53% <ø> (-0.31%) ⬇️
datdog-sidecar-ffi 8.77% <ø> (-1.43%) ⬇️
spawn-worker 54.69% <ø> (ø)
libdd-tinybytes 93.16% <ø> (ø)
libdd-trace-normalization 81.71% <ø> (ø)
libdd-trace-obfuscation 87.24% <ø> (ø)
libdd-trace-protobuf 68.25% <ø> (ø)
libdd-trace-utils 88.72% <ø> (ø)
datadog-tracer-flare 86.88% <ø> (ø)
libdd-log 74.69% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@yannham yannham force-pushed the yannham/process-ctx-migrate-libc branch from fc09061 to 60d6541 Compare April 9, 2026 17:00
…d glibc

libc::memfd_create requires glibc >= 2.27, causing a link error on CentOS 7
(glibc 2.17). Use libc::syscall(SYS_memfd_create, ...) instead, which bypasses
the glibc wrapper and works with any glibc version, matching the previous rustix
behavior.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@yannham yannham force-pushed the yannham/process-ctx-migrate-libc branch from d41d013 to 962448b Compare April 10, 2026 08:00
@dd-octo-sts
Copy link
Copy Markdown
Contributor

dd-octo-sts bot commented Apr 10, 2026

Artifact Size Benchmark Report

aarch64-alpine-linux-musl
Artifact Baseline Commit Change
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.a 83.34 MB 83.25 MB --.11% (-96.97 KB) 💪
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.so 7.63 MB 7.63 MB 0% (0 B) 👌
aarch64-unknown-linux-gnu
Artifact Baseline Commit Change
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.a 99.40 MB 99.29 MB --.11% (-115.13 KB) 💪
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.so 10.17 MB 10.10 MB --.68% (-71.03 KB) 💪
libdatadog-x64-windows
Artifact Baseline Commit Change
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.dll 25.16 MB 25.16 MB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.lib 78.21 KB 78.21 KB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.pdb 184.19 MB 184.22 MB +.01% (+24.00 KB) 🔍
/libdatadog-x64-windows/debug/static/datadog_profiling_ffi.lib 917.34 MB 917.34 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.dll 7.88 MB 7.88 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.lib 78.21 KB 78.21 KB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.pdb 23.64 MB 23.64 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/static/datadog_profiling_ffi.lib 46.13 MB 46.13 MB 0% (0 B) 👌
libdatadog-x86-windows
Artifact Baseline Commit Change
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.dll 21.63 MB 21.63 MB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.lib 79.42 KB 79.42 KB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.pdb 188.31 MB 188.30 MB -0% (-8.00 KB) 👌
/libdatadog-x86-windows/debug/static/datadog_profiling_ffi.lib 902.08 MB 902.08 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.dll 6.12 MB 6.12 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.lib 79.42 KB 79.42 KB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.pdb 25.31 MB 25.31 MB 0% (0 B) 👌
/libdatadog-x86-windows/release/static/datadog_profiling_ffi.lib 43.61 MB 43.61 MB 0% (0 B) 👌
x86_64-alpine-linux-musl
Artifact Baseline Commit Change
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.a 74.47 MB 74.38 MB --.12% (-97.24 KB) 💪
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.so 8.52 MB 8.51 MB --.13% (-12.00 KB) 💪
x86_64-unknown-linux-gnu
Artifact Baseline Commit Change
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.a 91.77 MB 91.66 MB --.11% (-108.44 KB) 💪
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.so 10.20 MB 10.18 MB --.15% (-16.40 KB) 💪

@yannham yannham marked this pull request as ready for review April 10, 2026 08:43
@yannham yannham requested review from a team as code owners April 10, 2026 08:43
@yannham yannham requested review from ivoanjo and vpellan and removed request for a team April 10, 2026 08:43
Copy link
Copy Markdown
Member

@ivoanjo ivoanjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 As a fellow lover of clear code and good abstractions I feel the pain lol. This looks good -- might be worth having a fellow rustacean do a quick extra pass just in case I missed some subtle detail.

Copy link
Copy Markdown
Contributor

@Aaalibaba42 Aaalibaba42 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Maybe check_syscall_retval could be a macro

lgtm

@yannham
Copy link
Copy Markdown
Contributor Author

yannham commented Apr 10, 2026

nit: Maybe check_syscall_retval could be a macro

I hesitated to just wrap syscalls in it, instead of retrieving ret first, like check_syscall(libc::some_syscall())?, but it's a minor stylistic difference. Though now I'm curious, why would you use a macro here?

Ok(unsafe { OwnedFd::from_raw_fd(fd) })
}

// Whether this size depends on the page size or not in the future, Rustix's `page_size()`
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this comment mentioning rustix relevant?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not (and wasn't even before this PR), thanks for the catch!

pub const SIGNATURE: &[u8; 8] = b"OTEL_CTX";
/// The discoverable name of the memory mapping.
pub const MAPPING_NAME: &str = "OTEL_CTX";
pub const MAPPING_NAME: &CStr = c"OTEL_CTX";
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔥 didn't know this was possible

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants