Skip to content

Adding support for Feature Toggles

Juan Gabriel Guzmán edited this page Sep 18, 2020 · 4 revisions

Feature Toggles

Feature Toggles (often also referred to as Feature Flags) are a powerful technique, allowing teams to modify system behavior without changing code. (Taken from https://www.martinfowler.com/articles/feature-toggles.html)

We are going to add support for Feature Toggles in the application to allow releasing certain functionality to a determined group of users so we can support "testing in production". The solution that we are going to use is going to be provided by this azure product.

We are going to have different scenarios to support Feature Toggles as follows:

  1. Release a feature for a small group of users
  2. Release a feature for a medium/large group of users

Release a feature for a small group of users

We are going to use this approach when we need to release a certain feature to a few users of our application. Following the Azure guidelines, the toggle label needs to have the unique identifier of one or many of users separated by a : delimiter as follows:

Key Label Value
FeatureName:reportsEndpoint user1;user2 true/false
FeatureName:profileEndpoint user1;user2 true/false
FeatureName:anotherEndpoint user1;user2 true/false

Using this approach, the code that is going to be executed will need to figure out if the user is contained as part of the toggle label. If yes, depending on the feature toggle value the code will execute one or other instruction as needed.

Release a feature for a medium/large group of users

The above-mentioned solution does not work well when we have to consider many users. The solution can still work, but it is not ideal to have a really large label. In this case, we will create one toggle using the following syntax:

Key Label Value
FeatureName:endpoint1 GroupName true/false
FeatureName:endpoint2 GroupName1;GroupName1 true/false
FeatureName:endpoint3 GroupName1;GroupName2 true/false

In this case, we are going to create a custom attribute feature_role. This attribute is going to be assigned to the users we want to be part of this testing group. Let's say we want to release one feature to the users: User1, User2, User3, User4..., UserN

We will create the above-mentioned custom attribute with the value GroupName. All of the above-mentioned users will have this attribute. In this way, just one toggle will exist and the check will be performed taking into account this value. If we want to add another feature using this approach, the attribute will have more than one value separated by a comma as follows:

feature_role: GroupName1, GroupName2...

Important considerations

  • Don't forget to include Yaneida on each toggle added so she can test the functionalities released
  • If we face issues in production just turn-off the toggle and everything will come to normal. Then, fix the issue and turn-on the toggle again
  • As soon as we have positive feedback, remove the code associated with the toggle and make the feature available for all the users
Clone this wiki locally