Skip to content

Publish process context during MINIT - #4213

Merged
cataphract merged 2 commits into
masterfrom
glopes/publish-otel-proc-ctx-minit
Sep 21, 2026
Merged

cataphract merged 2 commits into
masterfrom
glopes/publish-otel-proc-ctx-minit

Conversation

@cataphract

Copy link
Copy Markdown
Contributor

Publish in the parent so the agent can reuse inferred TLS offsets in worker forks. See https://github.com/DataDog/datadog-agent/blob/main/pkg/security/ebpf/c/include/helpers/span.h#L57-L64

Description

Reviewer checklist

  • Test coverage seems ok.
  • Appropriate labels assigned.

Publish in the parent so the agent can reuse inferred TLS offsets in
worker forks. Preserve first-request and post-fork republication.

If the MINIT process also serves requests, the first request updates the
existing header mapping and replaces its payload, adding process tags
when enabled. The publication timestamp advances while the runtime ID
stays unchanged. Later requests do not repeat this initialization.

Add a regression test that checks an idle PHP server before its first
request.
@cataphract
cataphract requested review from a team as code owners September 17, 2026 22:28
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 17, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-17T22:32:04.979605Z 0479b71 PR opened
🔒 Security Review Completed 2026-09-17T22:34:05.252427Z 0479b71 PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@datadog-prod-us1-5

datadog-prod-us1-5 Bot commented Sep 17, 2026

Copy link
Copy Markdown

Pipelines  Tests

Unblock PR with BitsAI

❌ Errors

Your PR has failed checks. Please review the issues below and take necessary action before merging.

🚦 21 Pipeline jobs failed

DataDog/apm-reliability/dd-trace-php | ASAN test_c with multiple observers: [8.3] — 🔧 Needs a code fix, caused by this PR

View more details · View in GitLab

DataDog/apm-reliability/dd-trace-php | check libxml2 version — 🔧 Needs a code fix, caused by this PR

View more details · View in GitLab

DataDog/apm-reliability/dd-trace-php | check-big-regressions — 🔧 Needs a code fix, caused by this PR

View more details · View in GitLab

View all 21 failed jobs.

⚠️ Warnings

❄️ 1 New flaky test detected

tmp/build_extension/tests/ext/otel_process_context_minit.phpt (Linux OTel Process Context is published during MINIT) from PHP.tmp.build_extension.tests.ext
001+ Server failed to start: Invalid address: 127.0.0.1:0
001- One Process Context mapping before any request: bool(true)

View in Flaky Test Management

ℹ️ Info

No other issues found (see more)

🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 67.46% (-0.09%)

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 55972a0 | Docs | View more details | Give us feedback!

@morrisonlevi morrisonlevi left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Looks fine to me, but I don't understand the full implications. Could you explain a bit more?

And obviously we need to get the tests working:

========DIFF========
001+ Server failed to start: Invalid address: 127.0.0.1:0
001- One Process Context mapping before any request: bool(true)
========DONE========
FAIL Linux OTel Process Context is published during MINIT [tmp/build_extension/tests/ext/otel_process_context_minit.phpt] 

@cataphract

Copy link
Copy Markdown
Contributor Author

Looks fine to me, but I don't understand the full implications. Could you explain a bit more?

@morrisonlevi
The agent has an optimization where forked processes (that have not execed) can have the otel tls layout parameters copied from the parent: https://github.com/DataDog/datadog-agent/blob/1d8c717e05c12eef13a1e91b97c1f32357182e38/pkg/security/ebpf/c/include/helpers/span_otel.h#L91-L103 and its calller https://github.com/DataDog/datadog-agent/blob/main/pkg/security/ebpf/c/include/helpers/span.h#L57-L64

For this to work, the parent needs to already have published the process context. So I'm doing that on MINIT, which is what is run pre-fork on fpm.

It also has the advantage that it reduces the window where we're already processing requests but the agent has not yet resolved the offsets. This is currently a problem in the system-tests, where we ahave to introduce a delay in the beginning of the request to give time to the user-space part of the resolution to take place.

@pr-commenter

pr-commenter Bot commented Sep 17, 2026

Copy link
Copy Markdown

Benchmarks [ tracer ]

Benchmark execution time: 2026-09-18 12:09:06

Comparing candidate commit 55972a0 in PR branch glopes/publish-otel-proc-ctx-minit with baseline commit 995edd6 in branch master.

Found 2 performance improvements and 4 performance regressions! Performance is the same for 187 metrics, 1 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:MessagePackSerializationBench/benchMessagePackSerialization

  • 🟩 execution_time [-5.912µs; -3.548µs] or [-5.078%; -3.047%]

scenario:MessagePackSerializationBench/benchMessagePackSerialization-opcache

  • 🟩 execution_time [-6.879µs; -4.481µs] or [-5.816%; -3.789%]

scenario:SamplingRuleMatchingBench/benchRegexMatching3

  • 🟥 execution_time [+55.873ns; +148.327ns] or [+3.742%; +9.933%]

scenario:SamplingRuleMatchingBench/benchRegexMatching4

  • 🟥 execution_time [+54.444ns; +126.756ns] or [+3.632%; +8.457%]

scenario:TraceFlushBench/benchFlushTrace-opcache

  • 🟥 execution_time [+50.995µs; +63.105µs] or [+13.413%; +16.598%]

scenario:TraceSerializationBench/benchSerializeTrace-opcache

  • 🟥 execution_time [+45.348µs; +55.652µs] or [+11.734%; +14.401%]

@cataphract
cataphract merged commit d354beb into master Sep 21, 2026
2174 of 2195 checks passed
@cataphract
cataphract deleted the glopes/publish-otel-proc-ctx-minit branch September 21, 2026 18:37
@github-actions github-actions Bot added this to the 1.26.0 milestone Sep 21, 2026
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.

2 participants