Repository navigation
feat(ffe): add Feature Flags debug logging - #4327
Conversation
|
Benchmarks [ tracer ]Benchmark execution time: 2026-10-23 19:42:38 Comparing candidate commit 5c61f9d in PR branch Found 1 performance improvements and 4 performance regressions! Performance is the same for 187 metrics, 2 unstable metrics.
|
|
DD_TRACE_DEBUG in dd-trace-php (non-sidecar) is deliberately relatively sparse (mostly to avoid a firehose of logging whenever anyone turns this on on a prod webserver). A lot of the details added here belong on the |
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Another round soon, please! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
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". |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 53b4cc1d7f
ℹ️ 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".
There was a problem hiding this comment.
More details
The scalar-JSON object check returns TYPE_MISMATCH before metrics and exposures are recorded, keeping native evaluation results consistent with the PHP SDK. The completed static review produced no reportable findings.
🤖 Bits Code Review · Commit 53b4cc1
1ea36c1 to
2d45605
Compare
|
As noted here: #4288 (comment) - please split this accordingly. |
Port the dd-trace-js Feature Flags debug logging (DataDog/dd-trace-js#10468) to PHP. When debug logging is enabled, log provider setup, the Remote Config subscription state at startup, configuration received/applied/removed, per-evaluation details, and the exposure lifecycle. Logs carry identifiers, counts and settings only, never flag values, targeting keys or attributes. The "flagging provider is disabled" hint is logged on first evaluation rather than at startup, so applications that never use feature flags get no FFE debug output. Environment: Datadog workspace Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
DD_TRACE_DEBUG is deliberately sparse, so per-evaluation and per-exposure
details move to DD_TRACE_LOG_LEVEL=trace (or debug,ddtrace=trace):
- DDTrace\ffe_evaluate logs one "evaluated {...}" line at trace level. It
replaces the userland DebugLogger, so gating and destination follow the
native logger like the rest of the tracer.
- Exposure loss stays visible at debug: buffer overflows are reported once
per flush ("dropped N exposure(s)"), as are flushes without a sidecar.
- Successful flushes log one trace line; datadog_ffi_try already reports
failures.
ddog_ffe_evaluate now rejects scalar JSON values for object flags with
TYPE_MISMATCH, as the PHP SDK already did. The native log line, evaluation
metric and exposure recording now match the SDK result, and such values
are no longer exposed.
Environment: Datadog workspace
Co-authored-by: ethan.romero <ethan.romero@datadoghq.com>
This PR adds Feature Flags logs at three layers with different switches and destinations, but nothing told customers how to collect them. The PHP SDK layer writes through error_log, while the extension and sidecar write to DD_TRACE_LOG_FILE, and the sidecar writes nowhere else. The usual DD_TRACE_DEBUG plus DD_TRACE_LOG_FILE setup therefore misses every SDK evaluation line. Document the switches, startup order, what each layer logs and where, and how to filter. Every destination, format, and level was checked against a fresh app built from this branch. Environment: Datadog workspace Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: Claude Code Claude Opus 5.5 <noreply@anthropic.com>
bde3395 to
5c61f9d
Compare
Addressed: moved sdk_debug_logging.phpt into tests/api/Unit/FeatureFlags, using the existing PHPUnit bootstrap. Split object_type_mismatch.phpt: SDK returned-value/default assertions now live in NativeClientTest.php; the extension test calls DDTrace\ffe_evaluate() directly and checks native results and logging. The other tests remain in tests/ext/ffe because they exercise extension configuration, evaluation, exposure handling, and logging behavior through native APIs. They no longer load SDK source files. I verified the extension suite runs without the repository’s src/ tree available. |
bwoebi
left a comment
There was a problem hiding this comment.
Looks good to me now, thanks!
Description
Make PHP Feature Flags diagnostics available under
DD_TRACE_DEBUG=1, including the raw inputs, values, defaults, and errors needed to explain a flag result. Previously, evaluation logs were metadata-only at TRACE, whichDD_TRACE_DEBUGsuppressed by forcing DEBUG.Follows the SDK Debug Logging Checklist.
Enable
DD_TRACE_DEBUG=1before PHP starts. Native tracer logs useDD_TRACE_LOG_FILEor PHP's error log; the default PHP SDK logger writes to PHP's error log. Collect both destinations if configured separately. A custom SDK logger must allow DEBUG. WithDD_TRACE_DEBUG=0and no separate debug-level override, evaluation diagnostics are suppressed.Diagnostics deferred to keep this PHP-only
The libdatadog submodule and pin, Cargo dependencies, and general Rust logger are unchanged; this PR adds no logging bridge. We opted not to add the following shared-library diagnostics because completing them requires changes inside libdatadog:
Existing tracer and sidecar logs remain available, but the deferred diagnostics above are not completed by this PR.
Validation
Shutdown-log gate: the three reported regressions (
die_in_sandbox,startup_logging_json_config,span_on_close) now pass with multiple observers enabled. Combined with the FFE PHPTs: 18 passed, 2 environment-dependent skips. Dogfooding debug-on/off checks also passed and confirmed the shutdown log is retained when flagging/debug are enabled. These local checks used a non-ASAN build; ASAN CI remains to be verified.Rebuilt the modified extension against the unchanged pinned libdatadog.
Focused PHP suites: 39 Feature Flags tests / 110 assertions and 47 OpenFeature tests / 104 assertions, including throwing loggers, formatting failures, hook errors, and debug-off formatting guards.
Latest native FFE PHPT run: 15 passed, 2 environment-dependent tests skipped. Coverage includes raw evaluation data, DEBUG gating, rejected configurations, object mismatches, exposure overflow/handoff, the raw-data warning, and a failing
/dev/fulllog sink. Agent/RC lifecycle and environment-mismatch scenarios passed separately in the earlier focused run; the Unix-Agent metrics fixture was not exercised.10 focused Rust tests passed: five PHP configuration/evaluation tests and five logger tests.
Ran the
ffe-dogfoodingPHP/OpenFeature app on PHP 8.3.33 with OpenFeature SDK 2.3.0 and local Agent/Remote Config test fixtures. Seven cases passed with debug enabled and again with debug disabled: boolean, integer, float, string, nested object, missing flag, and wrong type. Debug-on logs retained a complete 4 KB value and targeting context; debug-off produced zero debug lines with the expected evaluation results. An evaluation before configuration arrived returned its expected default.Validation is focused, not a full SDK/platform or managed-backend certification. The app runs did not inject
malloc/vsnprintffailures, measure debug-off allocations, or certify downstream sidecar delivery. PHP 7 was not rerun for these latest changes.Reviewer checklist
FFE reviewer selection
Reviewers: @btthomas, @typotter
Why: Guided and observable onboarding — This PR adds local Feature Flags debug logging to the PHP SDK, shown when DD_TRACE_DEBUG=1 is set. Reviewers come from the matched pod.
🤖 Automated selection.
Selection details
Initiative: project / guided-onboarding
Why this match: This PR adds local Feature Flags debug logging to the PHP SDK, shown when DD_TRACE_DEBUG=1 is set. The logs cover evaluation inputs and results, configuration receipt, application, removal and rejection, provider readiness (ready, unavailable, recovered), OpenFeature resolution diagnostics, exposure handoff and shutdown state. The point is to let customers check their SDK setup and see why a flag returned the value it did. That is SDK lifecycle and local debug-logging work under guided-onboarding. It is a concrete diagnostic capability, so it goes to that feature project rather than customer-onboarding-support. The catalog has no fallback entries with supplemental_review enabled, so no additional review areas apply.
The PR author was excluded. Existing reviewers and teams were preserved.
Debug or fix a problem
Workflow run · Bits Code session
dry_run=false. Unchanged completed runs are skipped. If the receipt saysneeds_reconciliationor a write outcome is uncertain, ask the workflow owner to reconcile GitHub and the receipt before retrying; do not delete the lock blindly.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:
components-rs/ffe.rs,components-rs/remote_config.rs,tracer/ffe.c,tracer/functions.c,src/api/FeatureFlags/Internal/EvaluationLog.php,src/api/FeatureFlags/Client.php,src/DDTrace/OpenFeature/DataDogProvider.php,src/api/FeatureFlags/README.mdEvaluated head:
5c61f9d5ddc30b2fe13d11df0872f882e43b8798Registry revision:
revision:1946aa2a-530e-487a-84a7-83aff44a1089Pinned skill source:
d214cfc65ae154b97d39af5cf32caf48aaec9bf0Instructions: workflow-injected snapshot (no plugin loaded)
Instruction snapshot SHA-256:
f23b2a88c13c0da90e2dd58246a14f257af91e2195c555039bd555b52e6f3516