Skip to content

[PHP] Expose FFE serial IDs in flag metadata with span enrichment - #4247

Open
hhan2024 wants to merge 2 commits into
masterfrom
ffe-serial-id-flag-metadata
Open

hhan2024 wants to merge 2 commits into
masterfrom
ffe-serial-id-flag-metadata

Conversation

@hhan2024

@hhan2024 hhan2024 commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Description

Expose the selected split's serial ID as __dd_split_serial_id in evaluation
metadata when span enrichment is enabled. Preserve zero, remove stale reserved
metadata when the selected split has no ID, and retain other metadata.

If native assignment succeeds but PHP decoding or type validation fails, retain
assignment metadata while returning the caller's default, an error, no variant,
and no exposure data. Native evaluation errors and runtime-default results keep
their existing behavior.

The native client exposes this metadata in its evaluation details. The
OpenFeature provider forwards scalar metadata when the installed OpenFeature
SDK's resolution builder supports withMetadata(); SDK versions without that
API cannot expose it. No native extension changes are required.

Companion adapter: system-tests #7857.
It remains draft and missing_feature until a release containing this SDK fix
is verified; no release version is predicted.

Validation

  • PHP 8.3.6: ResultMapper, Client, and EvaluationMetricRecorder suites passed:
    52 tests, 244 assertions.
  • The stale-key and decode-error regression tests fail before the fixes and
    pass afterward. Coverage includes positive/zero IDs, missing/null IDs,
    array/object bridge results, both gate states, native errors, and defaults.
  • New flag_metadata_serial_id.phpt: 1 passed. Exercises the native client,
    positive/zero/missing IDs, targeting, unknown flags, gate-off behavior, and
    retained exposure data. Independently forcing NativeEvaluator's mapper gate
    argument to false, true, or omitting it makes the test fail as expected.
  • composer ci-lint: passed.
  • Companion adapter ./format.sh, PHP syntax check, and all four required
    system-tests review lenses: passed with no actionable findings.

Local system-test receipt (December 4, 2026):

SDK PHP sources: 64a42d7911d1f2fc8e8a2e0fc7c188a00d9beab5 (clean tree)
System-tests: 11d50e4bd71c0a808f8f1d408b3c1e814025006e (clean tree)
Scenario: PARAMETRIC; PHP 8.3.6
Native artifact: prebuilt local ddtrace 2.0.0 extension, not rebuilt by this PR
Native artifact SHA256:
647f0e337fd953920d36164c6f367c66aaf596630d5b126b1944b3b8d8750117
Loaded PHP sources: DD_TRACE_SOURCES_PATH=/ffe-sdk/src
                    DD_AUTOLOAD_NO_COMPILE=true
Local image: ffe-php-serial-review:local
Image ID: sha256:481f92b206060c2f4917e3f359d4e950da53aaa487abb897ffe42f163d5a29b2
Test class: Test_FFE_Serial_Id_Metadata
Result: 5 passed, 0 failed, 0 skipped (26.58s)

Command from the system-tests checkout:

TEST_LIBRARY=php PYTHONPATH=/tmp:$PWD venv/bin/pytest \
  -p serial4247_image_plugin -S PARAMETRIC --skip-parametric-build -n=2 \
  -p no:warnings \
  tests/parametric/test_ffe/test_serial_id_metadata.py::Test_FFE_Serial_Id_Metadata \
  -F tests/parametric/test_ffe/test_serial_id_metadata.py::Test_FFE_Serial_Id_Metadata

The local plugin selects the isolated image and a unique container-name prefix;
it does not alter test inputs, assertions, or SDK behavior. The image contains
this PR's committed PHP sources and the companion adapter. Its existing native
await_ffe_config helper applies delivered Agent Remote Config while the CLI
server waits on I/O; no UFC fixture is injected through /ffe/start.

The full supported-platform and multi-version SDK matrix remains with CI.

Reviewer checklist

  • Added regression coverage and reran focused validation.
  • Appropriate labels assigned.

FFE reviewer selection

Reviewers: @sameerank, @greghuels

Why: Global fallback — At the evaluated head, ResultMapper::flagMetadata adds the selected split's serial_id/serialId to flag metadata as __dd_split_serial_id, but only when the span-enrichment gate… Global reviewers were selected because no project or SME pod matched.

🤖 Automated selection.

Selection details

Initiative: global / global

Why this match: At the evaluated head, ResultMapper::flagMetadata adds the selected split's serial_id/serialId to flag metadata as __dd_split_serial_id, but only when the span-enrichment gate is on. NativeEvaluator passes SpanEnrichmentRegistry::gateEnabled() through to the mapper. The change is APM span-enrichment metadata for evaluations. It does not touch EVP evaluation telemetry or consent (flag-evaluation-evp), onboarding diagnostics (guided-onboarding), migration-blocking capabilities (sdk-migration-parity), or any other registered project. No registered project clearly owns span enrichment and the catalog has no fallback rules, so this routes to global.

  • @sameerank — final owner (final-review-owners): Global pool filling a pod coverage gap. Existing review coverage preserved.
  • @greghuels — final owner (final-review-owners): Global pool filling a pod coverage gap. Existing review coverage preserved.

The PR author was excluded. Existing reviewers and teams were preserved.

Debug or fix a problem

Workflow run · Bits Code session

  • Wrong project or pod? Clarify this PR’s purpose, or correct the reviewer registry and publish the change. Sheet edits take effect after publication.
  • Need another reviewer now? Request them in GitHub. This workflow only adds requests and keeps existing reviewers.
  • Stuck beyond five minutes or failed? Inspect the run’s failed step and available Bits session. After fixing the cause, rerun the workflow with this PR URL and dry_run=false. Unchanged completed runs are skipped. If the receipt says needs_reconciliation or a write outcome is uncertain, ask the workflow owner to reconcile GitHub and the receipt before retrying; do not delete the lock blindly.
  • Report a problem: Comment on the reviewer-routing skill PR with this PR URL, the workflow run link, and the expected initiative or reviewer correction.
Evidence and run details

✅ Complete — reviewer coverage verified. The workflow checked pending requests or submitted reviews on the evaluated head.

Generated asynchronously by the FFE reviewer-routing workflow.

Changed paths: src/api/FeatureFlags/Internal/ResultMapper.php, src/api/FeatureFlags/Internal/NativeEvaluator.php, tests/api/Unit/FeatureFlags/ResultMapperTest.php

Evaluated head: 0423cacde808246e96a960cc7dc0a98e3ba12f92

Registry revision: revision:1946aa2a-530e-487a-84a7-83aff44a1089

Pinned skill source: d214cfc65ae154b97d39af5cf32caf48aaec9bf0

Instructions: workflow-injected snapshot (no plugin loaded)

Instruction snapshot SHA-256: f23b2a88c13c0da90e2dd58246a14f257af91e2195c555039bd555b52e6f3516

@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Pipelines  Tests

❌ Errors

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

🚦 3 Pipeline jobs failed

DataDog/apm-reliability/dd-trace-php | merge-gate

View more details · View in GitLab

DataDog/apm-reliability/dd-trace-php | publish docker image for system tests

View more details · View in GitLab

DataDog/apm-reliability/dd-trace-php | test_web_zend_1_21: [8.5, cli-server]

View more details · View in GitLab

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

🎯 Code Coverage (details)
• Patch Coverage: 100.00%
• Overall Coverage: 80.91% (+0.00%)

Useful? React with 👍 / 👎

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

@pr-commenter

pr-commenter Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Benchmarks [ tracer ]

Benchmark execution time: 2026-12-04 22:06:50

Comparing candidate commit 64a42d7 in PR branch ffe-serial-id-flag-metadata with baseline commit 3450356 in branch master.

📊 Benchmarking dashboard

Found 0 performance improvements and 0 performance regressions! Performance is the same for 218 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 ----------------------------------'

@hhan2024
hhan2024 force-pushed the ffe-serial-id-flag-metadata branch from e3226c4 to 0423cac Compare October 26, 2026 15:02
@hhan2024 hhan2024 changed the title Expose FFE serial IDs in flag metadata with span enrichment [PHP] Expose FFE serial IDs in flag metadata with span enrichment Oct 26, 2026
@hhan2024
hhan2024 marked this pull request as ready for review October 26, 2026 15:40
@hhan2024
hhan2024 requested review from a team as code owners October 26, 2026 15:40
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 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-10-26T15:43:44.896254Z 0423cac Draft marked ready
ℹ️ 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-datadog-prod-us1-2 datadog-datadog-prod-us1-2 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.

Bits Code Review: PASS

More details

The serial-ID mapping preserves zero, omits missing/null IDs, and retains existing metadata and exposure data behind the enrichment gate. The completed static review found no reportable defect.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit 0423cac

@greghuels
greghuels removed their request for review October 27, 2026 10:33
@leoromanovsky

leoromanovsky commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

FFE reviewer selection

Reviewers: @sameerank, @typotter

Why: openfeature architecture — The PR changes the PHP SDK's flag evaluation metadata. Reviewers come from the matched pod.

🤖 Automated selection.

Selection details

Initiative: fallback / openfeature-architecture

Why this match: The PR changes the PHP SDK's flag evaluation metadata. ResultMapper::map gains a span-enrichment flag, and a new flagMetadata() helper adds the selected split's serial_id/serialId under __dd_split_serial_id. It keeps a zero value, leaves out missing or null IDs, and keeps the existing metadata. The default-return path gets the same treatment. NativeEvaluator passes SpanEnrichmentRegistry::gateEnabled() to the mapper, and both the native client and the OpenFeature provider use that evaluator. This is a standalone change to the evaluation metadata contract. The diff has no holdout, bandit, EVP telemetry, onboarding-diagnostic or other registered-project purpose, so it falls under the OpenFeature architecture SME.

  • @sameerank — primary (openfeature-architecture): Matched pod member. Existing review coverage preserved.
  • @typotter — core (openfeature-architecture): Matched pod member. Existing review coverage preserved.

The PR author was excluded. Existing reviewers and teams were preserved.

Debug or fix a problem

Workflow run · Bits Code session

  • Wrong project or pod? Clarify this PR’s purpose, or correct the reviewer registry and publish the change. Sheet edits take effect after publication.
  • Need another reviewer now? Request them in GitHub. This workflow only adds requests and keeps existing reviewers.
  • Stuck beyond five minutes or failed? Inspect the run’s failed step and available Bits session. After fixing the cause, rerun the workflow with this PR URL and dry_run=false. Unchanged completed runs are skipped. If the receipt says needs_reconciliation or a write outcome is uncertain, ask the workflow owner to reconcile GitHub and the receipt before retrying; do not delete the lock blindly.
  • Report a problem: Comment on the reviewer-routing skill PR with this PR URL, the workflow run link, and the expected initiative or reviewer correction.
Evidence and run details

✅ Complete — reviewer coverage verified. The workflow checked pending requests or submitted reviews on the evaluated head.

Generated asynchronously by the FFE reviewer-routing workflow.

Changed paths: src/api/FeatureFlags/Internal/ResultMapper.php, src/api/FeatureFlags/Internal/NativeEvaluator.php, tests/api/Unit/FeatureFlags/ResultMapperTest.php

Evaluated head: 0423cacde808246e96a960cc7dc0a98e3ba12f92

Registry revision: revision:fe6a8bb4-aeba-4b6e-af89-db919eb47638

Pinned skill source: 7e3283c602f6b18a7e3e623eecb52d3a9c091a2e

Instructions: workflow-injected snapshot (no plugin loaded)

Instruction snapshot SHA-256: 52ed8cb68675dde1a47addaefe4a9500891c24014abf7dade6dfe38cf836c1d2

@leoromanovsky
leoromanovsky requested review from btthomas and typotter and removed request for btthomas October 29, 2026 00:15
Preserve zero and omit absent serial IDs while retaining existing flag metadata.

Environment: Datadog workspace

Co-Authored-By: Codex GPT-5 <noreply@localhost>
@hhan2024
hhan2024 force-pushed the ffe-serial-id-flag-metadata branch from 0423cac to cc489de Compare December 4, 2026 21:15

@datadog-datadog-prod-us1-2 datadog-datadog-prod-us1-2 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.

Bits Code Review: PASS

More details

The completed static review found no actionable defect in the gated serial-ID mapping, including zero preservation and missing/null handling. Human PR discussion did not change that conclusion.

Was this helpful? React 👍 or 👎

Open Bits AI session

🤖 Bits Code Review · Commit cc489de

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.

4 participants