feat: Emit provider events from LaunchDarkly client status - #29
Open
kinyoklion wants to merge 1 commit into
Open
feat: Emit provider events from LaunchDarkly client status#29kinyoklion wants to merge 1 commit into
kinyoklion wants to merge 1 commit 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
| ) | ||
| when ::LaunchDarkly::Interfaces::DataSource::Status::OFF | ||
| @provider.emit_event( | ||
| ::OpenFeature::SDK::ProviderEvent::PROVIDER_ERROR, |
Member
Author
There was a problem hiding this comment.
aside: We don't say fatal, because then OF short-circuits evaluations.
kinyoklion
marked this pull request as ready for review
August 19, 2026 16:56
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.
Forwards LaunchDarkly client status and flag change notifications to the OpenFeature SDK as provider events.
OpenFeature::SDK::Provider::EventEmitterand registers listeners on the LaunchDarkly data source status provider and flag tracker.VALIDemitsPROVIDER_READY,INTERRUPTEDemitsPROVIDER_STALE, andOFFemitsPROVIDER_ERRORwith theGENERALerror code and the last error in the message.OFFdeliberately does not usePROVIDER_FATAL: the LaunchDarkly client can still evaluate its last known flag data, and a fatal state would make the OpenFeature SDK return call-site defaults instead.PROVIDER_CONFIGURATION_CHANGEDwith the changed flag key.Implementation details
Requirements
Related issues
Part of an audit of the LaunchDarkly OpenFeature providers against the current OpenFeature specification. Provider events (spec section 5) were not implemented here, so applications had no way to react to LaunchDarkly connection loss, recovery, or flag configuration changes through the OpenFeature API.
Describe the solution you've provided
Two small listener classes in
Impltranslate LaunchDarkly notifications into OpenFeature events, and the provider registers them when the client is constructed.EventEmitter#emit_eventis a no-op until the OpenFeature SDK attaches its configuration to the provider, so events raised before the provider is set are safely dropped.Describe alternatives you've considered
Mapping
OFFtoPROVIDER_FATAL— rejected for the reason above; this matches the Java provider and the corresponding fix being made in the Python provider. Emitting one event per changed flag with no payload — rejected in favor of includingflags_changedso handlers can filter.Testing
bundle exec rake(RSpec + RuboCop) on Ruby 3.4: 59 examples, 0 failures; 15 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 OpenFeature provider events (spec section 5) so apps can react to LaunchDarkly connection state and flag updates through the OpenFeature API.
The Provider now includes
OpenFeature::SDK::Provider::EventEmitterand registers two listeners when the LD client is constructed: ondata_source_status_providerandflag_tracker.Data source status maps to events:
VALID→PROVIDER_READY,INTERRUPTED→PROVIDER_STALE(with message),OFF→PROVIDER_ERRORwithGENERALand last error details in the message—notPROVIDER_FATAL, so evaluation can still use last-known flags.INITIALIZINGemits nothing.Flag changes emit
PROVIDER_CONFIGURATION_CHANGEDwithflags_changedcontaining the changed key.New
Impl::DataSourceStatusListenerandImpl::FlagChangeListenertranslate LD notifications intoemit_eventcalls; specs cover each mapping.Reviewed by Cursor Bugbot for commit dc2ae67. Bugbot is set up for automated code reviews on this repo. Configure here.