feat: Populate OpenFeature flag metadata from the evaluation reason - #56
Draft
kinyoklion wants to merge 2 commits into
Draft
feat: Populate OpenFeature flag metadata from the evaluation reason#56kinyoklion wants to merge 2 commits into
kinyoklion wants to merge 2 commits into
Conversation
Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
Contributor
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
kinyoklion
commented
Aug 19, 2026
| private static ImmutableMetadata FlagMetadata(EvaluationReason reason, boolean isDefault, int variationIndex) { | ||
| var builder = ImmutableMetadata.builder(); | ||
| if (!isDefault) { | ||
| builder.addInteger("variationIndex", variationIndex); |
Member
Author
There was a problem hiding this comment.
We should move these names to defined constants instead of being inline.
Contributor
There was a problem hiding this comment.
Done in c93fd2c — the keys are now private static final constants on EvaluationDetailConverter. I'll mirror the same constant treatment in the other providers, and Ryan asked for an sdk-specs spec defining these names, so the spec will be the source of truth for them.
Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
This was referenced Aug 19, 2026
kinyoklion
added a commit
to launchdarkly/openfeature-ruby-server
that referenced
this pull request
Aug 21, 2026
) Populates OpenFeature flag metadata with the LaunchDarkly specific parts of the evaluation result, so hooks (including the OpenTelemetry hook) can read them. - Keys mirror the evaluation reason fields: `variationIndex`, `inExperiment`, `ruleIndex`, `ruleId`, `prerequisiteKey`, `bigSegmentsStatus`. - Each key is omitted rather than default-valued when it does not apply, so a consumer can distinguish "not in an experiment" from "no information". - Matches [openfeature-java-server#56](launchdarkly/openfeature-java-server#56), [openfeature-dotnet-server#61](launchdarkly/openfeature-dotnet-server#61) and [openfeature-python-server#53](launchdarkly/openfeature-python-server#53); the naming is being defined in an [sdk-specs spec](launchdarkly/sdk-specs#253). No screenshots or staging preview apply - this is a server-side library change with no UI. <details> <summary>Implementation details</summary> **Requirements** - [x] I have added test coverage for new or changed functionality - [x] I have followed the repository's pull request submission guidelines - [x] I have validated my changes against all supported platform versions **Describe the solution you've provided** `ResolutionDetailsConverter#to_resolution_details` now passes `flag_metadata`: ```ruby flag_metadata: flag_metadata(reason, is_default ? nil : variation_index) ``` Each entry is gated on the corresponding reason field being present rather than on the reason kind, so no key is written from a sentinel value. `big_segments_status` is a symbol in the Ruby SDK, so it is stringified to keep the metadata value types consistent with the other providers. The README gains a "Flag Metadata" section documenting the keys. **Describe alternatives you've considered** Exposing the reason object itself as one metadata entry would be closer to the LaunchDarkly shape, but OpenFeature flag metadata values are scalars, so the flat keys are the only available shape. **Additional context** ``` docker run --rm -v "$PWD":/app -w /app ruby:3.4 bash -c "bundle install && bundle exec rake" ``` 61 examples, 0 failures; RuboCop clean. 7 new examples cover each key and the omissions. </details> @cursor review Link to Devin session: https://app.devin.ai/sessions/0c452d209ec54b068ba120b4c92b8f6c Requested by: @kinyoklion <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Overview** > OpenFeature evaluations now include LaunchDarkly-only details on `flag_metadata`, so hooks (including OpenTelemetry) can read them. > > `ResolutionDetailsConverter` maps `variationIndex`, `inExperiment`, `ruleIndex`, `ruleId`, `prerequisiteKey`, and `bigSegmentsStatus` from the evaluation reason. Keys are omitted when they do not apply (including `inExperiment` when false, and `variationIndex` for default values). `bigSegmentsStatus` is stringified. > > The README documents the keys and a usage example. Specs cover each field and the omission cases. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit deaf178. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The provider discarded everything in the LaunchDarkly evaluation reason that did not fit into the OpenFeature reason string, so OpenFeature users could not tell that an evaluation was part of an experiment; the reason detail is now exposed as OpenFeature flag metadata.
ProviderEvaluation.flagMetadatanow carriesvariationIndex,inExperiment,ruleIndex,ruleId,prerequisiteKey, andbigSegmentsStatusinExperimentin particular is absent rather thanfalsefor non-experiment evaluations@cursor review
Implementation details
Requirements
Related issues
None; this is one of several gaps found while auditing the LaunchDarkly OpenFeature providers against the OpenFeature specification.
Describe the solution you've provided
EvaluationDetailConverter.getProviderEvaluationbuilds anImmutableMetadatafrom theEvaluationReason. Both entry points (typed values andLDValueresults) go through it, so object and array evaluations get metadata too.variationIndexduplicates the information invariant, but as an integer rather than a stringified index, which is what consumers reading metadata for telemetry want. It is omitted along withvariantwhen the SDK returned the default value.The OpenFeature telemetry conventions only reserve
contextId,flagSetId, andversion; none of the three map to a LaunchDarkly concept available on the evaluation detail (contextIdwould need the canonical context key rather than the reason, and could be added separately). Everything here is therefore LaunchDarkly-specific, named after the reason fields so it lines up withEvaluationReasonand with thefeature_flag.result.*attributes the LaunchDarkly OTel hook emits.Describe alternatives you've considered
reasonstructure:ImmutableMetadataonly holds scalars, and flat keys are what telemetry hooks read.inExperiment: false: cheap for consumers, but it makes the metadata claim knowledge about evaluations where the reason carries none.Additional context
./gradlew test javadocpasses, including new cases per metadata entry and one covering object results. Nothing outside the converter changes. No visual preview applies — this is a server-side provider change.Link to Devin session: https://app.devin.ai/sessions/0c452d209ec54b068ba120b4c92b8f6c
Requested by: @kinyoklion