File tree Expand file tree Collapse file tree
lib/flipper/adapters/sync
spec/flipper/adapters/sync Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -38,7 +38,7 @@ def sync
3838
3939 # Sync all the gate values.
4040 remote_get_all . each do |feature_key , remote_gates_hash |
41- feature = Feature . new ( feature_key , @local )
41+ feature = Feature . new ( feature_key , @local , instrumenter : @instrumenter )
4242 # Check if feature_key is in hash before accessing to prevent unintended hash modification
4343 local_gates_hash = local_get_all . key? ( feature_key ) ? local_get_all [ feature_key ] : @local . default_config
4444 local_gate_values = GateValues . new ( local_gates_hash )
@@ -48,11 +48,11 @@ def sync
4848
4949 # Add features that are missing in local and present in remote.
5050 features_to_add = remote_get_all . keys - local_get_all . keys
51- features_to_add . each { |key | Feature . new ( key , @local ) . add }
51+ features_to_add . each { |key | Feature . new ( key , @local , instrumenter : @instrumenter ) . add }
5252
5353 # Remove features that are present in local and missing in remote.
5454 features_to_remove = local_get_all . keys - remote_get_all . keys
55- features_to_remove . each { |key | Feature . new ( key , @local ) . remove }
55+ features_to_remove . each { |key | Feature . new ( key , @local , instrumenter : @instrumenter ) . remove }
5656
5757 nil
5858 rescue => exception
Original file line number Diff line number Diff line change 8484
8585 expect ( local_flipper . features . map ( &:key ) ) . to eq ( [ ] )
8686 end
87+
88+ it 'emits feature_operation.flipper events when syncing' do
89+ remote_flipper . enable ( :search )
90+
91+ subject . call
92+
93+ events = instrumenter . events_by_name ( "feature_operation.flipper" )
94+ expect ( events ) . not_to be_empty
95+
96+ feature_names = events . map { |e | e . payload [ :feature_name ] . to_s }
97+ expect ( feature_names ) . to include ( "search" )
98+ end
99+
100+ it 'emits feature_operation.flipper events when adding features' do
101+ remote_flipper . add ( :new_feature )
102+
103+ subject . call
104+
105+ events = instrumenter . events_by_name ( "feature_operation.flipper" )
106+ add_events = events . select { |e | e . payload [ :operation ] == :add }
107+ expect ( add_events ) . not_to be_empty
108+
109+ feature_names = add_events . map { |e | e . payload [ :feature_name ] . to_s }
110+ expect ( feature_names ) . to include ( "new_feature" )
111+ end
112+
113+ it 'emits feature_operation.flipper events when removing features' do
114+ local_flipper . add ( :old_feature )
115+
116+ subject . call
117+
118+ events = instrumenter . events_by_name ( "feature_operation.flipper" )
119+ remove_events = events . select { |e | e . payload [ :operation ] == :remove }
120+ expect ( remove_events ) . not_to be_empty
121+
122+ feature_names = remove_events . map { |e | e . payload [ :feature_name ] . to_s }
123+ expect ( feature_names ) . to include ( "old_feature" )
124+ end
87125 end
88126end
You can’t perform that action at this time.
0 commit comments