feat: Populate OpenFeature flag metadata from the evaluation reason - #61
Merged
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
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>
kinyoklion
marked this pull request as ready for review
August 24, 2026 20:52
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit e7d2771. Configure here.
Co-Authored-By: rlamb@launchdarkly.com <4955475+kinyoklion@users.noreply.github.com>
keelerm84
approved these changes
Aug 25, 2026
kinyoklion
added a commit
to launchdarkly/openfeature-python-server
that referenced
this pull request
Aug 25, 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) and [openfeature-dotnet-server#61](launchdarkly/openfeature-dotnet-server#61); 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` now builds `flag_metadata` from the LaunchDarkly reason dictionary: ```python flag_metadata=self.__to_flag_metadata(reason, variation_index if not is_default else None) ``` Each reason field is read defensively with an `isinstance` check, since the reason is a plain dictionary, so a malformed reason cannot put an unexpected type into the metadata. `variationIndex` uses the same default-value check that already gates `variant`. The README gains a "Flag Metadata" section documenting the keys. **Describe alternatives you've considered** Passing the whole reason dictionary through as a single `reason` metadata entry would be closer to the LaunchDarkly shape, but `FlagMetadata` values are scalars, so the flat keys are the only available shape. **Additional context** ``` poetry run pytest poetry run mypy ld_openfeature tests ``` All tests pass, including 7 new cases covering each key and the omissions. `make test`/`make lint` currently fail on `poetry install` on `main` as well, because `poetry.lock` is out of date relative to `pyproject.toml` - unrelated to this change. </details> @cursor review Link to Devin session: https://app.devin.ai/sessions/0c452d209ec54b068ba120b4c92b8f6c Requested by: @kinyoklion <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Overview** > OpenFeature evaluation details now include LaunchDarkly-specific fields on `flag_metadata`, so hooks (including OpenTelemetry) can read experiment, rule, and related evaluation info that has no OpenFeature equivalent. > > `ResolutionDetailsConverter` maps `variationIndex`, `inExperiment`, `ruleIndex`, `ruleId`, `prerequisiteKey`, and `bigSegmentsStatus` from the LD reason. Keys are omitted when they do not apply (including `inExperiment` when false, and `variationIndex` for default values). README documents the keys. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit a43597d. 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>
kinyoklion
pushed a commit
that referenced
this pull request
Aug 25, 2026
🤖 I have created a release *beep* *boop* --- ## [2.3.0](2.2.0...2.3.0) (2026-08-25) ### Features * Populate OpenFeature flag metadata from the evaluation reason ([#61](#61)) ([1081b79](1081b79)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Overview** > **Release Please** bumps the package from **2.2.0** to **2.3.0** in `.release-please-manifest.json` and `LaunchDarkly.OpenFeature.ServerProvider.csproj`, and adds the **2.3.0** section to `CHANGELOG.md`. > > That changelog entry documents the shipped feature from [#61](#61): OpenFeature **flag metadata** is populated from LaunchDarkly **evaluation reason** (and related detail). This PR does not change provider source code—only version and release notes. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 447b253. 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: github-actions[bot] <41898282+github-actions[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.

Populates OpenFeature flag metadata with the LaunchDarkly specific parts of the evaluation result, so hooks (including the OpenTelemetry hook) can read them.
variationIndex,inExperiment,ruleIndex,ruleId,prerequisiteKey,bigSegmentsStatus.No screenshots or staging preview apply — this is a server-side library change with no UI.
Implementation details
Requirements
Describe the solution you've provided
EvaluationDetailExtensionsgains aToFlagMetadataextension onEvaluationReason, and both the success and error paths ofToResolutionDetailspass its result asflagMetadata:ruleIndexandruleIdare gated on the reason actually carrying them rather than on the reason kind, so no key is written from a sentinel value.The README gains a "Flag Metadata" section documenting the keys.
Describe alternatives you've considered
A single nested
reasonstructure would be closer to the LaunchDarkly evaluation reason, butImmutableMetadataonly holds scalar values, so the flat keys are the only shape available.Testing
All tests pass, including 8 new cases covering each key, the omissions, and structure evaluations.
Additional context
net471could not be exercised locally because Mono is not installed on the build machine; CI covers it.@cursor review
Link to Devin session: https://app.devin.ai/sessions/0c452d209ec54b068ba120b4c92b8f6c
Requested by: @kinyoklion
Note
Overview
OpenFeature evaluation results now carry LaunchDarkly-specific metadata on
ResolutionDetails.FlagMetadata, so hooks (e.g. OpenTelemetry) can read experiment, rule, and segment context without parsing the reason string alone.EvaluationDetailExtensionsmapsEvaluationReasonand variation index into flat keys—variationIndex,inExperiment,ruleIndex,ruleId,prerequisiteKey, andbigSegmentsStatus(as JSON-style status strings)—and passes that metadata on both successful and error conversions inToResolutionDetails. Keys are omitted when they do not apply, not set to defaults.The README adds a Flag Metadata section (key table and
GetBooleanDetailsAsyncexample). Tests cover each key, omission behavior, and structure/Valueevaluation paths.Reviewed by Cursor Bugbot for commit 1a6b4cd. Bugbot is set up for automated code reviews on this repo. Configure here.