Skip to content

feat(ffe): add native evaluation bridge#3903

Closed
leoromanovsky wants to merge 1 commit into
leo.romanovsky/pr-e-exposure-metricsfrom
leo.romanovsky/pr-h-native-bridge
Closed

feat(ffe): add native evaluation bridge#3903
leoromanovsky wants to merge 1 commit into
leo.romanovsky/pr-e-exposure-metricsfrom
leo.romanovsky/pr-h-native-bridge

Conversation

@leoromanovsky
Copy link
Copy Markdown

Motivation

This is PR H in the PHP OpenFeature compatibility stack. It starts the tracer native runtime path by importing libdatadog/datadog-ffe into dd-trace-php and exposing a small bridge for the PHP feature flag client.

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

Stack context: this PR is stacked on #3902. The native bridge shape follows the DDTrace\ffe_* approach from #3630 while keeping Remote Config lifecycle and exposure delivery in later stack slices.

Changes

  • Adds datadog-ffe as a direct components-rs dependency and registers components-rs/ffe.rs.
  • Adds a Rust bridge that stores UFC config, evaluates through datadog_ffe::rules_based, and maps value/reason/error fields into a C/PHP result object.
  • Exposes internal DDTrace\ffe_evaluate, DDTrace\ffe_has_config, DDTrace\ffe_config_version, and DDTrace\ffe_load_config functions.
  • Adds DDTrace\FeatureFlags\NativeEvaluator and makes Client::create() prefer it when the extension bridge is available.
  • Keeps the transitional user warning/provider state when the native bridge exists before Remote Config and exposure delivery are complete.
  • Adds native bridge PHPT coverage and CODEOWNERS entries for the Rust bridge and extension tests.

Decisions

  • Import libdatadog/datadog-ffe; do not reimplement the evaluator locally in PHP or C.
  • Keep this PR limited to the minimal evaluation bridge. Remote Config lifecycle wiring remains PR I.
  • Keep native exposure flush/dedup/fork/ZTS integration out of this slice; that remains PR J.
  • Keep OpenFeature SDK dependencies out of the root tracer package so PHP 7 installability remains intact.

Verification

  • php -n -l src/api/FeatureFlags/NativeEvaluator.php
  • php -n -l src/api/FeatureFlags/Client.php
  • php -n -l tests/ext/ffe/native_bridge_evaluate.phpt
  • git diff --check
  • RUSTC_BOOTSTRAP=1 cargo check -p ddtrace-php
  • EXTRA_CFLAGS="-I$(brew --prefix pcre2)/include" EXTRA_LDFLAGS="-L$(brew --prefix pcre2)/lib" make -j"$(sysctl -n hw.ncpu)"
  • php -n -d extension=tmp/build_extension/modules/ddtrace.so -m | rg -i "^ddtrace$"
  • make test_c TESTS=tests/ext/ffe/native_bridge_evaluate.phpt
  • Direct client smoke with built ddtrace.so confirming fallback value, PROVIDER_NOT_READY, native transitional warning, and provider state when no FFE config is loaded.

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

datadog-datadog-prod-us1 Bot commented May 21, 2026

Pipelines  Tests

Fix all issues with BitsAI

⚠️ Warnings

🚦 14 Pipeline jobs failed

DataDog/apm-reliability/dd-trace-php | API unit tests: [7.0]   View in Datadog   GitLab

🔧 Fix in code (Fix with Cursor). 1 failed test. Assertion Error: Expected 'Datadog-backed PHP feature flag evaluation is not fully enabled yet. Returning default values until the ddtrace FFE runtime path is available.', got 'Datadog-backed PHP feature flag evaluation is using the native bridge before Remote Config and exposure delivery are fully enabled.' at /go/src/github.com/DataDog/apm-reliability/dd-trace-php/tests/api/Unit/FeatureFlags/ClientTest.php:107

DataDog/apm-reliability/dd-trace-php | API unit tests: [7.1]   View in Datadog   GitLab

🔧 Fix in code (Fix with Cursor). 1 failed test. Error: Failed asserting that two strings are identical in ClientTest.php:107.

DataDog/apm-reliability/dd-trace-php | API unit tests: [7.2]   View in Datadog   GitLab

🔧 Fix in code (Fix with Cursor). 1 failed test. Assertion Error: Expected feature flag evaluation message was not returned: expected 'Datadog-backed PHP feature flag evaluation is not fully enabled yet...' but got 'Datadog-backed PHP feature flag evaluation is using the native bridge...'.

View all 14 failed jobs.

ℹ️ 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.70% (+0.00%)

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: d712d6b | 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-22 00:19:11

Comparing candidate commit d712d6b in PR branch leo.romanovsky/pr-h-native-bridge with baseline commit 24d062a in branch leo.romanovsky/pr-e-exposure-metrics.

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

scenario:SamplingRuleMatchingBench/benchRegexMatching1

  • 🟥 execution_time [+86.835ns; +153.965ns] or [+6.070%; +10.763%]

scenario:SamplingRuleMatchingBench/benchRegexMatching2

  • 🟥 execution_time [+39.214ns; +86.386ns] or [+2.649%; +5.836%]

scenario:SamplingRuleMatchingBench/benchRegexMatching3

  • 🟥 execution_time [+45.874ns; +119.726ns] or [+3.138%; +8.189%]

scenario:TraceAnnotationsBench/benchTraceAnnotationOverhead-opcache

  • 🟥 execution_time [+3.652µs; +8.364µs] or [+2.057%; +4.710%]

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.

1 participant