Feature Flags
Overview
Feature flags are a core concept of Unleash. They allow you to release, test, and manage features and functionality across your application without changing the source code.
Feature flags exist within a project and have distinct configurations and activation strategies for each of the project's active environments. Activation strategies determine whether a feature flag is enabled in a specific environment.
Feature flags have the following properties:
- Name: A URL-friendly string between 1 and 100 characters; must be unique per instance.
- Type: The feature flag's type; defaults to
Release
. - Project: The project that contains the feature flag.
- Description: An optional description of the feature flag's purpose.
- Impression data: Indicates whether impression data is enabled for the flag; disabled by default.
Environments and activation strategies
Feature flags have different activation strategies for each environment, allowing you to manage feature rollouts per environment.
To activate a feature within an environment, assign at least one activation strategy to it. If you don't specify a strategy, the default is a gradual rollout to 100%.
Activation strategies determine whether a feature flag activates for a specific Unleash context, such as a particular user or segment. When multiple strategies are in place, the flag activates if any one of the strategies evaluates to true.
Strategy variants
You can enhance your feature flags with strategy variants. Feature flags let you define who gets access to a feature. With variants, you can also determine which version of the feature they see. For example, you might use variants to run an A/B testing experiment.
Variants are defined by a name and weight, which determines the likelihood of each variant being shown. Stickiness ensures that users consistently see the same variant based on predefined parameters. Variants can also include payloads such as JSON, CSV, or strings to provide users with additional context.
Feature flag types
Version: 3.5+
Feature flags have a type to indicate their use case and help you manage and sort your flags. A feature flag's type determines its expected lifetime and its visual appearance in the Admin UI.
The following is a list of feature flag types, their purpose, and expected lifetime:
Feature flag type | Used to | Expected lifetime |
---|---|---|
Release | Manage the deployment of new or incomplete features. | 40 days |
Experiment | Perform multivariate or A/B testing. | 40 days |
Operational | Transition between technical implementations with minimal risk. | 7 days |
Kill switch | Gracefully degrade system functionality. | Permanent |
Permission | Control feature access based on user roles or entitlements. | Permanent |
To learn more, visit Types of feature flags.
Feature flag state
A feature flag can have one of the following states: active, potentially stale, or stale. Unleash marks all flags as potentially stale automatically once they pass their expected lifetime.
State gives you an indication of when to clean up a feature flag in code.
You can also manually change the state on a feature flag's page by going to Overview and clicking Toggle stale state.
Marking a flag as stale helps you deprecate a feature flag without removing the active configuration for connected applications.
You can use this to signal to your team to stop using the feature in your applications. Stale flags will show as stale in the project status dashboard.
Marking a flag as stale generates the feature-stale-on
event. You can use an integration to trigger automated workflows, such as posting notifications in a Slack channel, breaking project builds if the code contains stale flags, or automatically opening pull requests to remove stale flags from the code.
Configure expected lifetime
Each feature flag type has a default expected lifetime. With Admin access, you can configure these values. In the Admin UI, go to Configure > Feature flag types and edit the flag type you'd like to change.
Feature flag lifecycle
Version: 6.2+
Based on usage metrics and interactions with Unleash, feature flags can go through five distinct lifecycle stages: initial, pre-live, live, completed, and archived. These stages mirror the typical software development process and allow you to identify bottlenecks at any stage of the lifecycle. These insights can help you improve the efficiency of your software development process.