OpenFeature is an open specification that provides a vendor-agnostic, community-driven API for feature flagging that works with your favorite feature flag management tool or in-house solution.
| Status | Features | Description |
|---|---|---|
| ❌ | Providers | Integrate with a commercial, open source, or in-house feature management tool. |
| ❌ | Targeting | Contextually-aware flag evaluation using evaluation context. |
| ❌ | Hooks | Add functionality to various stages of the flag evaluation life-cycle. |
| ❌ | Logging | Integrate with popular logging packages. |
| ❌ | Domains | Logically bind clients with providers. |
| ❌ | Multi-Provider | Use multiple feature flag providers simultaneously with configurable evaluation strategies. |
| ❌ | Eventing | React to state changes in the provider or flag management system. |
| ❌ | Tracking | Associate user-actions with flag evaluations for the purposes of experimentation. |
| ❌ | Transaction Context Propagation | Set a specific evaluation context for a transaction (e.g. an HTTP request or a thread) |
| ❌ | Shutdown | Gracefully clean up a provider during application shutdown. |
| ❌ | Extending | Extend OpenFeature with custom providers and hooks. |
Implemented: ✅ | In-progress:
Providers are an abstraction between a flag management system and the OpenFeature SDK. Look [here](https://openfeature.dev/ecosystem?instant_search%5BrefinementList%5D%5Btype%5D%5B0%5D=Provider&instant_search%5BrefinementList%5D%5Btechnology%5D%5B0%5D=) for a complete list of available providers. If the provider you're looking for hasn't been created yet, see the develop a provider section to learn how to build it yourself.
Once you've added a provider as a dependency, it can be registered with OpenFeature like this:
In some situations, it may be beneficial to register multiple providers in the same application. This is possible using domains, which is covered in more detail below.
Sometimes, the value of a flag must consider some dynamic criteria about the application or user, such as the user's location, IP, email address, or the server's location. In OpenFeature, we refer to this as targeting. If the flag management system you're using supports targeting, you can provide the input data using the evaluation context.
Hooks allow for custom logic to be added at well-defined points of the flag evaluation life-cycle. Look [here](https://openfeature.dev/ecosystem/?instant_search%5BrefinementList%5D%5Btype%5D%5B0%5D=Hook&instant_search%5BrefinementList%5D%5Btechnology%5D%5B0%5D=) for a complete list of available hooks. If the hook you're looking for hasn't been created yet, see the develop a hook section to learn how to build it yourself.
Once you've added a hook as a dependency, it can be registered at the global, client, or flag invocation level.
Clients can be assigned to a domain. A domain is a logical identifier which can be used to associate clients with a particular provider. If a domain has no associated provider, the default provider is used.
The Multi-Provider enables the use of multiple underlying feature flag providers simultaneously, allowing different providers to be used for different flag keys or based on specific evaluation strategies.
The Multi-Provider supports different evaluation strategies that determine how multiple providers are used:
Evaluates providers sequentially and returns the first result that is not "flag not found". If any provider returns an error, that error is returned immediately.
Evaluates providers sequentially and returns the first successful result, ignoring errors. Only if all providers fail will errors be returned.
Evaluates all providers in parallel and compares results. If values agree, returns the agreed value. If they disagree, returns the fallback provider's value (or first provider if no fallback is specified) and optionally calls a mismatch callback.
The Multi-Provider supports two evaluation modes:
- Sequential: Providers are evaluated one after another (used by
FirstMatchStrategyandFirstSuccessfulStrategy) - Parallel: All providers are evaluated simultaneously (used by
ComparisonStrategy)
Events allow you to react to state changes in the provider or underlying flag management system, such as flag definition changes, provider readiness, or error conditions.
Initialization events (PROVIDER_READY on success, PROVIDER_ERROR on failure) are dispatched for every provider.
Some providers support additional events, such as PROVIDER_CONFIGURATION_CHANGED.
Please refer to the documentation of the provider you're using to see what events are supported.
The tracking API allows you to use OpenFeature abstractions and objects to associate user actions with feature flag evaluations.
This is essential for robust experimentation powered by feature flags.
For example, a flag enhancing the appearance of a UI component might drive user engagement to a new feature; to test this hypothesis, telemetry collected by a hook or provider can be associated with telemetry reported in the client's track function.
Note that some providers may not support tracking; check the documentation for your provider for more information.
Transaction context is a container for transaction-specific evaluation context (e.g. user id, user agent, IP). Transaction context can be set where specific data is available (e.g. an auth service or request handler) and by using the transaction context propagator it will automatically be applied to all flag evaluations within a transaction (e.g. a request or thread).
The OpenFeature API provides a close function to perform a cleanup of all registered providers. This should only be called when your application is in the process of shutting down.
To develop a provider, you need to create a new project and include the OpenFeature SDK as a dependency.
This can be a new repository or included in [the existing contrib repository](https://github.com/open-feature/-sdk-contrib) available under the OpenFeature organization.
You’ll then need to write the provider by implementing the FeatureProvider interface exported by the OpenFeature SDK.
Built a new provider? Let us know so we can add it to the docs!
To develop a hook, you need to create a new project and include the OpenFeature SDK as a dependency.
This can be a new repository or included in [the existing contrib repository](https://github.com/open-feature/-sdk-contrib) available under the OpenFeature organization.
Implement your own hook by conforming to the Hook interface.
To satisfy the interface, all methods (Before/After/Finally/Error) need to be defined.
To avoid defining empty functions, make use of the UnimplementedHook struct (which already implements all the empty functions).
Built a new hook? Let us know so we can add it to the docs!
- Give this repo a ⭐️!
- Follow us on social media:
- Twitter: @openfeature
- LinkedIn: OpenFeature
- Join us on Slack
- For more, check out our community page
Interested in contributing? Great, we'd love your help! To get started, take a look at the CONTRIBUTING guide.
Made with contrib.rocks.