Skip to content

feat(ffe): add runtime-backed PHP feature flag evaluation#3906

Open
leoromanovsky wants to merge 24 commits into
masterfrom
leo.romanovsky/milestone-1-runtime-evaluation
Open

feat(ffe): add runtime-backed PHP feature flag evaluation#3906
leoromanovsky wants to merge 24 commits into
masterfrom
leo.romanovsky/milestone-1-runtime-evaluation

Conversation

@leoromanovsky
Copy link
Copy Markdown

@leoromanovsky leoromanovsky commented May 22, 2026

Motivation

This PR adds real server-side PHP feature flag evaluation backed by Remote Config and the libdatadog native evaluator. PHP 7 gets a Datadog API, PHP 8 can use the optional OpenFeature bridge, and both paths use the same live runtime evaluator.

This is intentionally the evaluation layer only. Exposure delivery, exposure caching, and evaluation metrics land in the later hook, exposure, and metrics PRs.

Shared planning doc: https://docs.google.com/document/d/1NvMfTpZWLBlFmEFNjdnlMyeVpy5l7KD8qujGFco6w2w/edit?tab=t.0

Decisions

  • Production clients/providers read only from the live Remote Config-backed native runtime.
  • The root package remains PHP 7 installable; the OpenFeature SDK is used only in PHP 8 test/app environments and is not a root dependency.
  • productionRuntime=false remains a temporary guardrail while the hook, exposure delivery, and evaluation metrics layers are incomplete. The final production-ready PHP FFE stack should not ship with that warning enabled.
  • The PHP/OpenFeature bridge passes a targeting key plus flat primitive attributes (bool, int, float, string) into the native evaluator. Nested arrays, objects, and null attribute values are dropped at the boundary.
  • DDTrace\Testing\ffe_load_config exists only for local/canonical fixture tests.

Where this PR fits in the stack

This is the bottom layer of the 4-PR stack. #3909 adds the shared hook, while #3910 (EVP exposures) and #3911 (OTLP metrics) build on top of that hook.

pr3906-runtime-evaluation-stack-position

Where this PR fits in the target system

This PR contributes the in-PHP evaluation surface: UserCode -> OpenFeature Client (PHP 8) / DDTrace FeatureFlags Client (PHP 7 + 8), the DDTrace OpenFeature DataDogProvider, the NativeEvaluator FFI bridge into libdatadog, and the Remote Config client for the FFE_FLAGS product.

pr3906-runtime-evaluation-system-scope

Changes

  • Imports the libdatadog FFE evaluator path and keeps PHP user-facing APIs as thin adapters over the native runtime.
  • Wires PHP 7-safe DDTrace\FeatureFlags evaluation through live Remote Config.
  • Adds a PHP 8-only DDTrace\OpenFeature provider bridge.
  • Adds the canonical DataDog/ffe-system-test-data submodule and a native-runtime PHPT loop over ufc-config.json and evaluation-cases/*.json.

Not Included

  • Exposure writer, exposure cache, or EVP forwarding.
  • Exposure flush/dedup tests.
  • Flag-evaluation metric emission.

Validation

  • php vendor/bin/phpunit --config phpunit.xml tests/api/Unit/FeatureFlags tests/OpenFeature/DataDogProviderTest.php: 29 tests / 87 assertions.
  • make test_featureflags: 8 tests / 29 assertions.
  • MAX_TEST_PARALLELISM=1 TESTS=tests/ext/ffe/native_bridge_evaluate.phpt make test_c: 1/1 passed.
  • MAX_TEST_PARALLELISM=1 TESTS=tests/ext/ffe/system_test_data_evaluate.phpt make test_c: 1/1 passed.
  • make test_internal_api_randomized: passed.

Dogfooding Validation

See DataDog/ffe-dogfooding#68.

Ran the PHP 7 and PHP 8 servers locally; observed correct evaluations.

Screenshot 2026-05-22 at 12 57 05 PM

@datadog-datadog-prod-us1-2
Copy link
Copy Markdown

Tests

🎉 All green!

🧪 All tests passed

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 60.70% (-0.03%)

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

@datadog-datadog-prod-us1-2
Copy link
Copy Markdown

datadog-datadog-prod-us1-2 Bot commented May 22, 2026

Pipelines  Tests

Fix all issues with BitsAI

⚠️ Warnings

🚦 1 Pipeline job failed

DataDog/apm-reliability/dd-trace-php | check-big-regressions   View in Datadog   GitLab

🔧 Fix in code (Fix with Cursor). Regression Check failed. Metric 'MetricName.EXECUTION_TIME' in scenarios has regressions larger than threshold. Received exit code 5.

ℹ️ Info

No other issues found (see more)

🧪 All tests passed
❄️ No new flaky tests detected

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

Useful? React with 👍 / 👎

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

@pr-commenter
Copy link
Copy Markdown

pr-commenter Bot commented May 22, 2026

Benchmarks [ tracer ]

Benchmark execution time: 2026-05-28 02:35:37

Comparing candidate commit 4cf261d in PR branch leo.romanovsky/milestone-1-runtime-evaluation with baseline commit 6b5659e in branch master.

Found 1 performance improvements and 4 performance regressions! Performance is the same for 188 metrics, 1 unstable metrics.

scenario:BM_TeaSapiSpindown

  • 🟥 execution_time [+12.479µs; +30.485µs] or [+2.404%; +5.873%]

scenario:ContextPropagationBench/benchInject128Bit-opcache

  • 🟥 execution_time [+676.492ns; +735.508ns] or [+39.841%; +43.316%]

scenario:ContextPropagationBench/benchInject64Bit-opcache

  • 🟥 execution_time [+684.991ns; +767.009ns] or [+29.938%; +33.523%]

scenario:LogsInjectionBench/benchLogsInfoBaseline-opcache

  • 🟥 execution_time [+99.822ns; +176.178ns] or [+5.937%; +10.478%]

scenario:LogsInjectionBench/benchLogsNullBaseline-opcache

  • 🟩 execution_time [-1.271µs; -1.151µs] or [-5.806%; -5.254%]

@leoromanovsky leoromanovsky marked this pull request as ready for review May 22, 2026 18:02
@leoromanovsky leoromanovsky requested review from a team as code owners May 22, 2026 18:02
@leoromanovsky leoromanovsky requested review from tabgok and removed request for a team May 22, 2026 18:02
Copy link
Copy Markdown

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

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: e55ebb976b

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

Comment thread src/bridge/_files_openfeature.php Outdated
Comment thread components-rs/ffe.rs
@leoromanovsky leoromanovsky marked this pull request as draft May 22, 2026 18:57
@leoromanovsky leoromanovsky marked this pull request as ready for review May 22, 2026 19:04
Comment thread ext/ddtrace.stub.php Outdated
Comment thread ext/ddtrace.c Outdated
Comment thread src/api/FeatureFlags/Client.php Outdated
Comment thread src/DDTrace/OpenFeature/DataDogProvider.php Outdated
Comment thread src/api/FeatureFlags/Internal/ResultMapper.php
Comment thread src/api/FeatureFlags/Internal/NativeEvaluator.php Outdated
Comment thread src/api/FeatureFlags/Internal/NativeEvaluator.php Outdated
Comment thread src/api/FeatureFlags/Internal/UnavailableEvaluator.php Outdated
@leoromanovsky
Copy link
Copy Markdown
Author

Feedback from @bwoebi addressed; retest with local build against ffe-dogfooding server with satisfactory results.

Comment thread components-rs/ffe.rs Outdated
Comment thread ext/remote_config.c Outdated
Comment thread src/DDTrace/OpenFeature/DataDogProvider.php Outdated
Comment thread src/DDTrace/OpenFeature/DataDogProvider.php Outdated
Comment thread src/api/FeatureFlags/Client.php Outdated
Comment thread .github/dependabot.yml
Comment thread ext/ddtrace.c Outdated
Comment thread ext/ddtrace.stub.php Outdated
Comment thread src/api/FeatureFlags/Internal/ResultMapper.php Outdated
Comment thread src/api/FeatureFlags/Client.php Outdated
Comment thread src/api/FeatureFlags/EvaluationDetails.php
Comment thread ext/ddtrace.c Outdated
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