Skip to content

feat: added environment capability [APMSP-3780] - #2239

Merged
gh-worker-dd-mergequeue-cf854d[bot] merged 5 commits into
mainfrom
jwiriath/env-caps
Jul 16, 2026
Merged

feat: added environment capability [APMSP-3780]#2239
gh-worker-dd-mergequeue-cf854d[bot] merged 5 commits into
mainfrom
jwiriath/env-caps

Conversation

@Aaalibaba42

Copy link
Copy Markdown
Contributor

What does this PR do?

Added capability to read and write environment variables

Motivation

dd-trace-js needing to add info from the env in their requests, it's better to have libdatadog drive the call

Additional Notes

Nop

How to test the change?

check, tests, check for wasm32

@Aaalibaba42
Aaalibaba42 requested review from a team as code owners July 15, 2026 09:57
@datadog-official

datadog-official Bot commented Jul 15, 2026

Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
Patch Coverage: 50.00%
Overall Coverage: 74.61% (-0.14%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 5fedbee | Docs | Datadog PR Page | Give us feedback!

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a1dfa1a88f

ℹ️ 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".

Comment thread libdd-capabilities-impl/src/env.rs Outdated
Comment thread libdd-capabilities/Cargo.toml Outdated
@Aaalibaba42
Aaalibaba42 force-pushed the jwiriath/env-caps branch 2 times, most recently from 9534a81 to d3d3c25 Compare July 15, 2026 10:06
@dd-octo-sts

dd-octo-sts Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Artifact Size Benchmark Report

aarch64-alpine-linux-musl
Artifact Baseline Commit Change
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.a 86.33 MB 86.33 MB -0% (-832 B) 👌
/aarch64-alpine-linux-musl/lib/libdatadog_profiling.so 7.88 MB 7.88 MB 0% (0 B) 👌
aarch64-unknown-linux-gnu
Artifact Baseline Commit Change
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.so 10.62 MB 10.62 MB -0% (-136 B) 👌
/aarch64-unknown-linux-gnu/lib/libdatadog_profiling.a 97.54 MB 97.54 MB -0% (-5.82 KB) 👌
libdatadog-x64-windows
Artifact Baseline Commit Change
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.dll 25.58 MB 25.58 MB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.lib 89.18 KB 89.18 KB 0% (0 B) 👌
/libdatadog-x64-windows/debug/dynamic/datadog_profiling_ffi.pdb 185.48 MB 185.53 MB +.02% (+56.00 KB) 🔍
/libdatadog-x64-windows/debug/static/datadog_profiling_ffi.lib 958.37 MB 958.59 MB +.02% (+223.41 KB) 🔍
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.dll 8.37 MB 8.37 MB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.lib 89.18 KB 89.18 KB 0% (0 B) 👌
/libdatadog-x64-windows/release/dynamic/datadog_profiling_ffi.pdb 24.76 MB 24.76 MB --.03% (-8.00 KB) 💪
/libdatadog-x64-windows/release/static/datadog_profiling_ffi.lib 49.28 MB 49.28 MB -0% (-1.04 KB) 👌
libdatadog-x86-windows
Artifact Baseline Commit Change
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.dll 22.23 MB 22.23 MB +0% (+512 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.lib 90.58 KB 90.58 KB 0% (0 B) 👌
/libdatadog-x86-windows/debug/dynamic/datadog_profiling_ffi.pdb 189.95 MB 190.00 MB +.02% (+48.00 KB) 🔍
/libdatadog-x86-windows/debug/static/datadog_profiling_ffi.lib 946.26 MB 946.53 MB +.02% (+277.21 KB) 🔍
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.dll 6.47 MB 6.47 MB --.01% (-1.00 KB) 💪
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.lib 90.58 KB 90.58 KB 0% (0 B) 👌
/libdatadog-x86-windows/release/dynamic/datadog_profiling_ffi.pdb 26.59 MB 26.58 MB --.02% (-8.00 KB) 💪
/libdatadog-x86-windows/release/static/datadog_profiling_ffi.lib 46.90 MB 46.89 MB --.02% (-10.39 KB) 💪
x86_64-alpine-linux-musl
Artifact Baseline Commit Change
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.a 77.08 MB 77.08 MB +0% (+2.24 KB) 👌
/x86_64-alpine-linux-musl/lib/libdatadog_profiling.so 8.83 MB 8.83 MB 0% (0 B) 👌
x86_64-unknown-linux-gnu
Artifact Baseline Commit Change
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.a 92.50 MB 92.50 MB -0% (-2.63 KB) 👌
/x86_64-unknown-linux-gnu/lib/libdatadog_profiling.so 10.74 MB 10.74 MB -0% (-168 B) 👌

@pr-commenter

pr-commenter Bot commented Jul 15, 2026

Copy link
Copy Markdown

Benchmarks

Comparison

Benchmark execution time: 2026-07-16 16:39:34

Comparing candidate commit 5fedbee in PR branch jwiriath/env-caps with baseline commit 4a914bb in branch main.

Found 7 performance improvements and 14 performance regressions! Performance is the same for 121 metrics, 0 unstable metrics.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

scenario:msgpack_decoder::v05/low_sharing/10000

  • 🟩 execution_time [-1.038ms; -0.989ms] or [-5.617%; -5.354%]
  • 🟩 throughput [+30746.129op/s; +32003.010op/s] or [+5.679%; +5.912%]

scenario:otlp/e2e_json/1x1000

  • 🟥 execution_time [+401.876µs; +412.250µs] or [+9.840%; +10.094%]

scenario:otlp/encode_json/1x1000

  • 🟥 execution_time [+420.010µs; +420.552µs] or [+23.810%; +23.841%]

scenario:otlp/encode_protobuf/1x1000

  • 🟩 execution_time [-59.665µs; -58.766µs] or [-5.330%; -5.249%]

scenario:profiles_dictionary/profile_string_inserts/threads/1

  • 🟥 execution_time [+15.249µs; +17.467µs] or [+4.977%; +5.701%]
  • 🟥 throughput [-180508.596op/s; -158223.709op/s] or [-5.400%; -4.734%]

scenario:vec_map/get_hit/128

  • 🟥 execution_time [+943.536ns; +951.197ns] or [+7.524%; +7.585%]
  • 🟥 throughput [-719786.911op/s; -714153.232op/s] or [-7.052%; -6.996%]

scenario:vec_map/get_hit/16

  • 🟩 execution_time [-12.525ns; -12.287ns] or [-5.871%; -5.759%]
  • 🟩 throughput [+4586506.473op/s; +4671447.990op/s] or [+6.116%; +6.229%]

scenario:vec_map/get_hit/64

  • 🟥 execution_time [+240.762ns; +243.893ns] or [+7.038%; +7.129%]
  • 🟥 throughput [-1245072.553op/s; -1229635.785op/s] or [-6.656%; -6.573%]

scenario:vec_map/get_hit/8

  • 🟩 execution_time [-7.846ns; -7.689ns] or [-12.709%; -12.456%]
  • 🟩 throughput [+18476983.580op/s; +18812574.513op/s] or [+14.257%; +14.516%]

scenario:vec_map/get_mut/128

  • 🟥 execution_time [+2.397µs; +2.503µs] or [+17.478%; +18.251%]
  • 🟥 throughput [-1444988.920op/s; -1382418.623op/s] or [-15.476%; -14.806%]

scenario:vec_map/get_mut/16

  • 🟥 execution_time [+28.786ns; +38.602ns] or [+10.742%; +14.406%]
  • 🟥 throughput [-7889452.435op/s; -5791080.412op/s] or [-13.092%; -9.610%]

scenario:vec_map/get_mut/64

  • 🟥 execution_time [+537.574ns; +575.132ns] or [+14.156%; +15.145%]
  • 🟥 throughput [-2236502.585op/s; -2083164.625op/s] or [-13.260%; -12.351%]

Benchmark execution time: 2026-07-16 16:55:13

Comparing candidate commit 5fedbee in PR branch jwiriath/env-caps with baseline commit 4a914bb in branch main.

Found 4 performance improvements and 24 performance regressions! Performance is the same for 149 metrics, 10 unstable metrics.

Explanation

This is an A/B test comparing a candidate commit's performance against that of a baseline commit. Performance changes are noted in the tables below as:

  • 🟩 = significantly better candidate vs. baseline
  • 🟥 = significantly worse candidate vs. baseline

We compute a confidence interval (CI) over the relative difference of means between metrics from the candidate and baseline commits, considering the baseline as the reference.

If the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD), the change is considered significant.

Feel free to reach out to #apm-benchmarking-platform on Slack if you have any questions.

More details about the CI and significant changes

You can imagine this CI as a range of values that is likely to contain the true difference of means between the candidate and baseline commits.

CIs of the difference of means are often centered around 0%, because often changes are not that big:

---------------------------------(------|---^--------)-------------------------------->
                              -0.6%    0%  0.3%     +1.2%
                                 |          |        |
         lower bound of the CI --'          |        |
sample mean (center of the CI) -------------'        |
         upper bound of the CI ----------------------'

As described above, a change is considered significant if the CI is entirely outside the configured SIGNIFICANT_IMPACT_THRESHOLD (or the deprecated UNCONFIDENCE_THRESHOLD).

For instance, for an execution time metric, this confidence interval indicates a significantly worse performance:

----------------------------------------|---------|---(---------^---------)---------->
                                       0%        1%  1.3%      2.2%      3.1%
                                                  |   |         |         |
       significant impact threshold --------------'   |         |         |
                      lower bound of CI --------------'         |         |
       sample mean (center of the CI) --------------------------'         |
                      upper bound of CI ----------------------------------'

scenario:alloc_free/sampled_system_fast_path/4096

  • 🟩 execution_time [-10.987ns; -10.866ns] or [-10.795%; -10.676%]

scenario:alloc_free/system/4096

  • 🟩 execution_time [-12.060ns; -11.890ns] or [-11.254%; -11.095%]

scenario:credit_card/is_card_number/ 3782-8224-6310-005

  • 🟥 execution_time [+5.561µs; +5.734µs] or [+7.403%; +7.634%]
  • 🟥 throughput [-946635.763op/s; -916665.085op/s] or [-7.110%; -6.885%]

scenario:credit_card/is_card_number/ 378282246310005

  • 🟥 execution_time [+5.878µs; +5.961µs] or [+8.672%; +8.795%]
  • 🟥 throughput [-1192586.414op/s; -1177089.173op/s] or [-8.083%; -7.978%]

scenario:credit_card/is_card_number/378282246310005

  • 🟥 execution_time [+6.158µs; +6.236µs] or [+9.538%; +9.659%]
  • 🟥 throughput [-1364287.384op/s; -1348486.299op/s] or [-8.808%; -8.706%]

scenario:credit_card/is_card_number/37828224631000521389798

  • 🟥 execution_time [+7.920µs; +7.970µs] or [+17.500%; +17.611%]
  • 🟥 throughput [-3312107.642op/s; -3288028.384op/s] or [-14.989%; -14.880%]

scenario:credit_card/is_card_number/x371413321323331

  • 🟥 execution_time [+405.142ns; +408.656ns] or [+6.704%; +6.762%]
  • 🟥 throughput [-10484379.218op/s; -10392941.857op/s] or [-6.336%; -6.281%]

scenario:credit_card/is_card_number_no_luhn/ 378282246310005

  • 🟥 execution_time [+5.371µs; +5.409µs] or [+10.120%; +10.191%]
  • 🟥 throughput [-1742433.785op/s; -1731028.681op/s] or [-9.249%; -9.188%]

scenario:credit_card/is_card_number_no_luhn/378282246310005

  • 🟥 execution_time [+5.703µs; +5.752µs] or [+11.436%; +11.536%]
  • 🟥 throughput [-2074083.819op/s; -2057724.127op/s] or [-10.343%; -10.261%]

scenario:credit_card/is_card_number_no_luhn/37828224631000521389798

  • 🟥 execution_time [+7.844µs; +7.902µs] or [+17.332%; +17.460%]
  • 🟥 throughput [-3287163.891op/s; -3261518.109op/s] or [-14.877%; -14.761%]

scenario:credit_card/is_card_number_no_luhn/x371413321323331

  • 🟥 execution_time [+404.721ns; +407.985ns] or [+6.697%; +6.751%]
  • 🟥 throughput [-10468488.756op/s; -10384658.252op/s] or [-6.326%; -6.275%]

scenario:glob_matcher/ascii_case_insensitive_match/wall_time

  • 🟥 execution_time [+1.990ns; +2.017ns] or [+7.285%; +7.384%]

scenario:glob_matcher/ascii_exact_miss/wall_time

  • 🟥 execution_time [+1.172ns; +1.211ns] or [+9.400%; +9.713%]

scenario:glob_matcher/ascii_wildcard_backtrack_match/wall_time

  • 🟥 execution_time [+3.273ns; +3.289ns] or [+8.868%; +8.911%]

scenario:glob_matcher/ascii_wildcard_question_match/wall_time

  • 🟥 execution_time [+1.914ns; +1.935ns] or [+5.196%; +5.250%]

scenario:trace_buffer/4_senders/no_delay

  • 🟥 execution_time [+159.827µs; +193.603µs] or [+6.960%; +8.431%]
  • 🟥 throughput [-123694.606op/s; -101635.464op/s] or [-7.878%; -6.473%]

scenario:trace_buffer/8_senders/no_delay

  • 🟩 execution_time [-371.957µs; -315.307µs] or [-5.631%; -4.774%]
  • 🟩 throughput [+55344.417op/s; +65903.252op/s] or [+5.076%; +6.045%]

Candidate

Omitted due to size.

Baseline

Omitted due to size.

@Aaalibaba42

Copy link
Copy Markdown
Contributor Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bed4965e07

ℹ️ 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".

Comment thread libdd-capabilities-impl/src/env.rs
Comment thread libdd-capabilities-impl/src/env.rs
@Aaalibaba42 Aaalibaba42 changed the title feat: added environment capability feat: added environment capability [APMSP-3780] Jul 15, 2026

@yannham yannham left a comment

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.

Besides the original motivation, I'm all for env capability: I think it's a step in the right direction to get rid of the get/set race conditions that have popped up in the past. Once everything uses the capability, we can silently switch to a different implementation - one that snapshots the environment at the beginning for example - which is much less prone to races.

However, I would remove set and unset from the API if they are not needed, or even would make them a compile time error. As mentioned in the Rust documentation and discussed extensively elsewhere, they're just impossible to get right in a multi-threaded environment, even within a pure Rust program, and I think we should just not use it. It's worse in libdatadog context, where we might interact with C and multiple other runtimes.

Comment thread libdd-capabilities/src/env.rs Outdated
Comment thread libdd-capabilities/src/env.rs Outdated
Comment thread libdd-capabilities-impl/src/env.rs
Comment thread libdd-capabilities-impl/src/env.rs
@Aaalibaba42

Aaalibaba42 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor Author

Agreed after discussion that adding them to the full API like that is at least prematured, especially since we don't need it in JS either for now. Fundamentally I think it could be okay to have these methods solely in the JS side since the process should be single threaded etc, but the shape and way that ought to be done should not be part of this PR and should require discussions. The idea of having the capability for the environment snapshotting the starting environment and simulating the rest and being the single source of truth for it to work even in multithreaded things is interesting o/

@Aaalibaba42
Aaalibaba42 requested a review from yannham July 16, 2026 15:12

@yannham yannham left a comment

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.

Should we mention why we don't include set_var in the trait's documentation?

@Aaalibaba42

Copy link
Copy Markdown
Contributor Author

/merge

@gh-worker-devflow-routing-ef8351

gh-worker-devflow-routing-ef8351 Bot commented Jul 16, 2026

Copy link
Copy Markdown

View all feedbacks in Devflow UI.

2026-07-16 16:06:50 UTC ℹ️ Start processing command /merge


2026-07-16 16:06:56 UTC ℹ️ MergeQueue: waiting for PR to be ready

This pull request is not mergeable according to GitHub. Common reasons include pending required checks, missing approvals, or merge conflicts — but it could also be blocked by other repository rules or settings.
It will be added to the queue as soon as checks pass and/or get approvals. View in MergeQueue UI.
Note: if you pushed new commits since the last approval, you may need additional approval.
You can remove it from the waiting list with /remove command.


2026-07-16 17:02:11 UTC ℹ️ MergeQueue: merge request added to the queue

The expected merge time in main is approximately 1h (p90).


2026-07-16 17:43:10 UTC ℹ️ MergeQueue: This merge request was merged

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants