feat: Support OpenFeature tracking - #27
Open
kinyoklion wants to merge 1 commit into
Open
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:
|
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.
Implements the OpenFeature tracking API in the Ruby provider so experimentation metric events reach LaunchDarkly.
Provider#track, mappingTrackingEventDetails#fieldsto the LD custom eventdataand#valuetometric_value.trackcall without an evaluation context logs a warning and sends nothing, since LaunchDarkly requires a context to associate the event with.openfeature-sdkfloor to>= 0.6.1(< 0.7.0);TrackingEventDetailsandClient#trackdo not exist in 0.6.0.Implementation details
Requirements
Related issues
Part of an audit of the LaunchDarkly OpenFeature providers against the current OpenFeature specification. Tracking (spec section 6) was unimplemented here, and per spec 6.1.4 the OpenFeature SDK silently no-ops when a provider lacks
track, so events were being dropped without any error.Describe the solution you've provided
OpenFeature::SDK::Client#trackforwards toprovider.track(name, evaluation_context:, tracking_event_details:). The provider converts the evaluation context with the existingEvaluationContextConverterand callsLDClient#track(event_name, context, data, metric_value). Emptyfieldsare normalized tonilso no empty hash is attached to the event.Describe alternatives you've considered
Sending the event with an anonymous/placeholder context when no evaluation context is supplied — rejected, because it would attribute metric events to a context the application never used. Warning and dropping matches the behavior of the Python provider.
Testing
bundle exec rake(RSpec + RuboCop) on Ruby 3.4: 57 examples, 0 failures; 12 files inspected, no offenses. Ruby 3.4 was used because the gemspec requires>= 3.4.@cursor review
Link to Devin session: https://app.devin.ai/sessions/0c452d209ec54b068ba120b4c92b8f6c
Requested by: @kinyoklion
Note
Overview
Implements the OpenFeature tracking API on
LaunchDarkly::OpenFeature::Providerso experimentation metric events are forwarded to LaunchDarkly instead of being silently dropped when the provider lackedtrack.Provider#trackconverts the evaluation context via the existing converter and callsLDClient#track, mappingTrackingEventDetails#fieldsto custom eventdataand#valueto the metric value; emptyfieldsare passed asnil. Calls without an evaluation context log a warning and do not send an event.The gemspec bumps the
openfeature-sdkfloor to>= 0.6.1(< 0.7.0) becauseTrackingEventDetailsand client tracking support are not in 0.6.0. Specs cover basic tracking, event details, and the no-context path.Reviewed by Cursor Bugbot for commit d142051. Bugbot is set up for automated code reviews on this repo. Configure here.