This allows users to add feature flags to Bugsnag whenever they interact with their feature flag service, e.g.
flag = get_flag_from_service('new-login-page')
if flag.enabled?
Bugsnag.add_feature_flag('new-login-page')
# render new login page
else
Bugsnag.clear_feature_flag('new-login-page')
# render old login page
end
Before this PR, the above snippet would affect all web requests/queued jobs because Bugsnag.add_feature_flag would write to a global set of flags (similar to Bugsnag.add_metadata vs event.add_metadata)
With this PR, feature flags are stored in a thread local (just like breadcrumbs), meaning each web request or queued job will have a separate set of flags
This is important because feature flags will usually be user-specific, e.g. to allow rolling out features to small groups of users at a time. With the previous implementation this was still possible but meant relying on adding all flags for the user at once in an on_error callback, whereas the new implementation allows for adding flags individually when they are used
Changeset
Store the Configuration's FeatureFlagDelegate in a thread local
Moved feature flag API into a FeatureDataStore module to allow all 3 places that implement the API to share the same code & docs (Bugsnag, Configuration & Event/Report)
Updated Maze Runner tests to reflect the new changes — these previously relied on some flags being global
Goal
This allows users to add feature flags to Bugsnag whenever they interact with their feature flag service, e.g.
Before this PR, the above snippet would affect all web requests/queued jobs because
Bugsnag.add_feature_flag
would write to a global set of flags (similar toBugsnag.add_metadata
vsevent.add_metadata
)With this PR, feature flags are stored in a thread local (just like breadcrumbs), meaning each web request or queued job will have a separate set of flags
This is important because feature flags will usually be user-specific, e.g. to allow rolling out features to small groups of users at a time. With the previous implementation this was still possible but meant relying on adding all flags for the user at once in an
on_error
callback, whereas the new implementation allows for adding flags individually when they are usedChangeset
Configuration
'sFeatureFlagDelegate
in a thread localFeatureDataStore
module to allow all 3 places that implement the API to share the same code & docs (Bugsnag
,Configuration
&Event
/Report
)