Skip to content

Adding support for Feature Toggles

Dickson A edited this page Aug 4, 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 it's 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 tag needs to have the unique identifier of one or a list of users separated by a delimiter, the toggle can have a specific endpoint or not (separated by :):

Key Label Value
FeatureName:reportsEndPonit UUID-USER1;UUID-USER2 true/false
FeatureName:profileEndPonit UUID-USER1 true/false
FeatureName UUID-USER1;UUID-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 key. 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 create a huge amount of toggles to list many users following the above-mentioned convention. For this case, we will create one toggle using the following syntax:

Key Label Value
FeatureName:specificEndPoint GroupName true/false
FeatureName:specificEndPoint GroupName1;GroupName1 true/false
FeatureName 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