Repository navigation
Conversation
The OpenFeature SDK builds a list entry, a hook context and hook data for every registered hook on every evaluation, then calls each hook at every stage. All of the provider's hooks act only at the finally stage, so they now run behind one CompositeProviderHook: in registration order, skipped for unsupported flag types, and with a failing hook logged without stopping the rest, as the SDK does. The evaluation telemetry opt-out is decided once per evaluation, replacing one EvaluationTelemetryOptOutHook wrapper per telemetry hook. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
🟢 Java Benchmark SLOs — All performance SLOs passed
PR vs. master results
Commit: Load and DaCapo benchmarks can be triggered manually in the GitLab pipeline. Results will appear in the Benchmarking Platform UI after completion. |
Codex Review Summary: ✅ CompletedThis 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. |
There was a problem hiding this comment.
More details
The static reviewer identified no reportable defect in hook consolidation or telemetry opt-out handling. Exact equivalence with OpenFeature SDK hook ordering remains unverified because dependency sources and binaries were unavailable locally.
🤖 Bits Code Review · Commit 3d32e3e
| * | ||
| * <p>On every evaluation, the OpenFeature SDK builds a list entry, a hook context and hook data for | ||
| * each registered hook, then calls each hook at every stage. All of the provider's hooks only act | ||
| * at the finally stage, so running them behind one hook pays that setup once, whatever the number |
There was a problem hiding this comment.
nit:
| * at the finally stage, so running them behind one hook pays that setup once, whatever the number | |
| * at the final stage, so running them behind one hook pays that setup once, whatever the number |
| final HookContext<Object> context, | ||
| final FlagEvaluationDetails<Object> details, | ||
| final Map<String, Object> hints) { | ||
| final boolean optedOut = |
There was a problem hiding this comment.
from Codex that seems valid to me-
Keep exposure and debug hooks running if the telemetry opt-out lookup throws. The lookup now happens before the per-hook try block in finallyAfter(). If an application-supplied EvaluationContext throws on that lookup, OpenFeature catches the exception from the composite after it has already skipped exposure and debug logging. Previously, each telemetry wrapper failed independently. Catch and log the lookup failure, skip telemetry, and continue the ungated hooks. Add a regression test that throws during the final lookup and asserts the exposure hook still runs.
There was a problem hiding this comment.
Agreed, that was a real regression. Fixed in 11d0adb: finallyAfter now logs a failing opt-out lookup and skips only the telemetry hooks, so exposures and debug logging still run, as they did when each telemetry hook was gated separately. aThrowingOptOutLookupSkipsTelemetryButNotTheOtherHooks uses a context whose lookups throw; it fails on the previous code and passes now. before and error keep the old behavior: with the per-hook wrappers, a throwing lookup there failed in the same way.
| } | ||
| hooks.addTelemetry(spanEnrichmentHook); | ||
| } | ||
| hooks.optOutEnabled(options.isEvaluationTelemetryOptOutParameterEnabled(this.settings)); |
There was a problem hiding this comment.
we can gate this check on evaluationTelemetryEnabled as well? if evaluationTelemetryEnabled=false then can skip this opt-out check
There was a problem hiding this comment.
Done in 11d0adb, one level down: the builder turns the opt-out off when no telemetry hook is registered. All three telemetry hooks (metrics, EVP logging, span enrichment) are only created with evaluationTelemetryEnabled, so that covers your case, plus the one where metrics are unavailable without the OTel API. withoutTelemetryHooksTheOptOutParameterIsNotRead checks that the parameter isn't read.
| } | ||
| } | ||
|
|
||
| private static final class MapHookData implements HookData { |
There was a problem hiding this comment.
suggestion (from Codex): replace MapHookData with OpenFeature's public DefaultHookData which is already used by the OpenFeature Java SDK: https://github.com/open-feature/java-sdk/blob/v1.23.0/src/main/java/dev/openfeature/sdk/HookSupport.java#L69-L72
There was a problem hiding this comment.
Done in 11d0adb: the test uses the SDK's public DefaultHookData (we build against 1.23.0, where it's public with a public constructor), and MapHookData is gone.
The composite reads the telemetry opt-out once, ahead of every hook, so a context that threw on that lookup skipped exposures and debug logging too. The failure is now logged and only telemetry is skipped, as when each telemetry hook was gated separately. With no telemetry hooks registered, the parameter isn't read at all. The test uses the SDK's DefaultHookData instead of its own. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Return the hooks through one unmodifiable view, make isOptedOut private, rejoin two comments the formatter split mid-sentence, and drop a redundant line from the hook-name test. No behavior change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Document that only finallyAfter runs for the hooks behind the composite, and guard it with a test that fails if any provider hook overrides the before, after or error stage. Warn once when the opt-out lookup throws, then log at debug, as the sibling hooks do. Static-import the Collections helpers, reword a comment the formatter kept splitting, and rename a stale test. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
PR Blocked - Invalid Label The pull request introduced unexpected labels:
This PR is blocked until:
Note: Simply removing labels from the pull request is not enough - a maintainer must delete this comment then remove the label to remove the block. |
leoromanovsky
left a comment
There was a problem hiding this comment.
Approving. I'm also investigating an upstream improvement to per-hook overhead in the OpenFeature Java SDK. It would complement this change rather than replace it, since the provider has to keep supporting SDK versions that don't have it.
What Does This Do
The Datadog OpenFeature provider now registers its hooks with OpenFeature as one hook,
CompositeProviderHook, instead of up to five. Evaluation results, telemetry, exposures, span enrichment and debug logging are unchanged.Motivation
On every evaluation, the OpenFeature Java SDK (1.23.0, the version dd-openfeature builds against) does setup work for each registered hook: it merges and filters the hook lists into a new list of
Pairs, creates aHookContextand aDefaultHookDatafor each hook, and then calls every hook at every stage. The provider registers two to five hooks (flag evaluation metrics, flag evaluation logging, span enrichment, debug logging and exposures). With the telemetry opt-out on, each telemetry hook is also wrapped in its ownEvaluationTelemetryOptOutHook.All of those hooks act only at the finally stage, so one hook can run them all. The SDK then does its per-hook setup once.
Measured with #13529's
ClientEvaluationBenchmarkon a roll-up of the open FFE optimization PRs, with and without this change (same jar build, JDK 17, G1 with a 2 GB heap,-t 4, 3 forks per side,-prof gc):flags, unpacedflags, paced at 10ksplits, paced at 4kvariations, paced at 20kThe benchmark host had high CPU steal (median 23%), so deltas under about 5–7% are unconfirmed. The
flagstime gap is well outside that.For scale: on the same client and benchmark, a provider that returns a constant and registers no hooks costs 107 ns and 136 B per evaluation. That's the SDK's floor for any provider.
Additional Notes
dd_evaluation_telemetry_opt_outdecision is made once per evaluation in the composite'sbeforestage, with the same fallback to theerrorstage when an application before hook fails. It replaces oneEvaluationTelemetryOptOutHookper telemetry hook, which is deleted. Exposures and debug logging still aren't gated. The existing opt-out tests pass unchanged.HookContext, including its hook data. Only the opt-out used hook data, so nothing collides today. The class Javadoc notes that hook data keys must be distinct.HookSupport) would reduce it for everyone. This change only reduces how many hooks we ask the SDK to set up.🤖 Generated with Claude Code