Skip to content

Commit f1addde

Browse files
mrm9084maud-lvzhiyuanliang-ms
authored
Apply suggestions from code review
Co-authored-by: Maud <[email protected]> Co-authored-by: Zhiyuan Liang <[email protected]>
1 parent 201555b commit f1addde

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

articles/azure-app-configuration/feature-management-python-reference.md

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ zone_pivot_groups: feature-management
1414
#Customer intent: I want to control feature availability in my app by using the Feature Management library.
1515
---
1616

17-
# Python Feature Management
17+
# Python feature management
1818

1919
:::zone target="docs" pivot="stable-version"
2020

@@ -34,31 +34,31 @@ Feature flags provide a way for Python applications to turn features on or off d
3434
Here are some of the benefits of using Python feature management library:
3535

3636
* A common convention for feature management
37-
* Low barrier-to-entry
37+
* Low barrier to entry
3838
* Supports JSON feature flag setup
39-
* Feature Flag lifetime management
39+
* Feature flag lifetime management
4040
* Configuration values can change in real-time; feature flags can be consistent across the entire request
41-
* Simple to Complex Scenarios Covered
41+
* Simple to complex scenarios covered
4242
* Toggle on/off features through declarative configuration file
4343
* Dynamically evaluate state of feature based on call to server
4444

4545
The Python feature management library is open source. For more information, visit the [GitHub repo](https://github.com/microsoft/FeatureManagement-Python).
4646

47-
## Feature Flags
47+
## Feature flags
4848
Feature flags are composed of two parts, a name and a list of feature-filters that are used to turn on the feature.
4949

50-
### Feature Filters
51-
Feature filters define a scenario for when a feature should be enabled. When a feature is evaluated for whether it is on or off, its list of feature filters is traversed until one of the filters decides the feature should be enabled. At this point, the feature is considered enabled and traversal through the feature filters stops. If no feature filter indicates that the feature should be enabled, it considered disabled.
50+
### Feature filters
51+
Feature filters define a scenario for when a feature should be enabled. When a feature is evaluated for whether it is on or off, its list of feature filters is traversed until one of the filters decides the feature should be enabled. At this point, the feature is considered enabled and traversal through the feature filters stops. If no feature filter indicates that the feature should be enabled, it's considered disabled.
5252

5353
As an example, a Microsoft Edge browser feature filter could be designed. This feature filter would activate any features attached to it, as long as an HTTP request is coming from Microsoft Edge.
5454

55-
### Feature Flag Configuration
55+
### Feature flag configuration
5656

57-
A Python dictionary is used to define feature flags. The dictionary is composed of feature names as keys and feature flag objects as values. The feature flag object is a dictionary that contains an `EnabledFor` key. The `EnabledFor` key is a list of feature filters that are used to determine if the feature should be enabled
57+
A Python dictionary is used to define feature flags. The dictionary is composed of feature names as keys and feature flag objects as values. The feature flag object is a dictionary that contains an `EnabledFor` key. The `EnabledFor` key is a list of feature filters that are used to determine if the feature should be enabled.
5858

59-
### Feature Flag Declaration
59+
### Feature flag declaration
6060

61-
The feature management library supports json as a feature flag source. Below we have an example of the format used to set up feature flags in a json file.
61+
The feature management library supports json as a feature flag source. Below we have an example of the format used to set up feature flags in a JSON file.
6262

6363
```json
6464
{
@@ -98,7 +98,7 @@ The detailed schema of the `feature_management` section can be found [here](http
9898

9999
**Advanced:** The usage of colon ':' is forbidden in feature flag names.
100100

101-
#### On/Off Declaration
101+
#### On/off declaration
102102

103103
The following snippet demonstrates an alternative way to define a feature that can be used for on/off features.
104104
``` json
@@ -118,7 +118,7 @@ The following snippet demonstrates an alternative way to define a feature that c
118118
}
119119
```
120120

121-
#### RequirementType
121+
#### Requirement_type
122122

123123
The `requirement_type` property of a feature flag is used to determine if the filters should use `Any` or `All` logic when evaluating the state of a feature. If `requirement_type` isn't specified, the default value is `Any`.
124124

@@ -174,7 +174,7 @@ if feature_manager.is_enabled("FeatureX"):
174174

175175
The `feature_flags` provided to `FeatureManager` can either be the `AzureAppConfigurationProvider` or a dictionary of feature flags.
176176

177-
## Implementing a Feature Filter
177+
## Implementing a feature filter
178178

179179
Creating a feature filter provides a way to enable features based on criteria that you define. To implement a feature filter, the `FeatureFilter` interface must be implemented. `FeatureFilter` has a single method named `evaluate`. When a feature specifies that it can be enabled for a feature filter, the `evaluate` method is called. If `evaluate` returns `true`, it means the feature should be enabled.
180180

@@ -186,17 +186,17 @@ feature_manager = FeatureManager(feature_flags, feature_filters=[MyCustomFilter(
186186

187187
Feature filters are registered by providing when creating `FeatureManager` with `feature_filters`. If a custom feature filter needs any context, they can be passed in when calling `is_enabled` using `kwargs`.
188188

189-
### Filter Alias Attribute
189+
### Filter alias attribute
190190

191191
When a feature filter is registered for a feature flag, the name of the filter is used as the alias by default.
192192

193193
The identifier for the feature filter can be overridden by using the `@FeatureFilter.alias("MyFilter")`. A feature filter can be decorated with this attribute to declare the name that should be used in configuration to reference this feature filter within a feature flag.
194194

195-
### Missing Feature Filters
195+
### Missing feature filters
196196

197-
If a feature, configured to be enabled, for a specific feature filter and that feature filter isn't registered, an `ValueError` exception is raised when the feature is evaluated.
197+
If a feature is configured to be enabled for a specific feature filter and that feature filter isn't registered, a `ValueError` exception is raised when the feature is evaluated.
198198

199-
## Built-In Feature Filters
199+
## Built-in feature filters
200200

201201
There are a two feature filters that come with the `FeatureManagement` package: `TimeWindowFilter`, and `TargetingFilter`.
202202

@@ -256,7 +256,6 @@ This filter provides the capability to enable a feature for a target audience. A
256256
}
257257
}
258258
]
259-
260259
```
261260

262261
## Targeting
@@ -286,9 +285,9 @@ feature_manager = FeatureManager(feature_flags, "test_user")
286285
feature_manager = FeatureManager(feature_flags, TargetingContext(user_id="test_user", groups=["Ring1"]))
287286
```
288287

289-
### Targeting Exclusion
288+
### Targeting exclusion
290289

291-
When defining an Audience, users and groups can be excluded from the audience. Exclusions are useful for when a feature is being rolled out to a group of users, but a few users or groups need to be excluded from the rollout. Exclusion is defined by adding a list of users and groups to the `Exclusion` property of the audience.
290+
When defining an audience, users and groups can be excluded from the audience. Exclusions are useful for when a feature is being rolled out to a group of users, but a few users or groups need to be excluded from the rollout. Exclusion is defined by adding a list of users and groups to the `Exclusion` property of the audience.
292291

293292
```json
294293
"Audience": {
@@ -319,7 +318,7 @@ In the above example, the feature is enabled for users named `Jeff` and `Alicia`
319318

320319
When new features are added to an application, there may come a time when a feature has multiple different proposed design options. A common solution for deciding on a design is some form of A/B testing. A/B testing involves providing a different version of the feature to different segments of the user base and choosing a version based on user interaction. In this library, this functionality is enabled by representing different configurations of a feature with variants.
321320

322-
Variants enable a feature flag to become more than a simple on/off flag. A variant represents a value of a feature flag that can be a string, a number, a boolean, or even a configuration object. A feature flag that declares variants should define under what circumstances each variant should be used, which is covered in greater detail in the [Allocating Variants](#allocating-variants) section.
321+
Variants enable a feature flag to become more than a simple on/off flag. A variant represents a value of a feature flag that can be a string, a number, a boolean, or even a configuration object. A feature flag that declares variants should define under what circumstances each variant should be used, which is covered in greater detail in the [Allocating variants](#allocating-variants) section.
323322

324323
```python
325324
class Variant:
@@ -344,7 +343,7 @@ class Variant:
344343
return self._configuration
345344
```
346345

347-
### Getting Variants
346+
### Getting variants
348347

349348
For each feature, a variant can be retrieved using the `FeatureManager`'s `get_variant` method.
350349

@@ -359,9 +358,9 @@ variantConfiguration = variant.configuration;
359358

360359
The variant returned is dependent on the user currently being evaluated, and that information is obtained from an instance of `TargetingContext`.
361360

362-
### Variant Feature Flag Declaration
361+
### Variant feature flag declaration
363362

364-
Compared to normal feature flags, variant feature flags have two more properties: `variants` and `allocation`. The `variants` property is an array that contains the variants defined for this feature. The `allocation` property defines how these variants should be allocated for the feature. Just like declaring normal feature flags, you can set up variant feature flags in a json file. Here's an example of a variant feature flag.
363+
Compared to normal feature flags, variant feature flags have two more properties: `variants` and `allocation`. The `variants` property is an array that contains the variants defined for this feature. The `allocation` property defines how these variants should be allocated for the feature. Just like declaring normal feature flags, you can set up variant feature flags in a JSON file. Here's an example of a variant feature flag.
365364

366365
```json
367366
{
@@ -395,7 +394,7 @@ Compared to normal feature flags, variant feature flags have two more properties
395394
}
396395
```
397396

398-
#### Defining Variants
397+
#### Defining variants
399398

400399
Each variant has two properties: a name and a configuration. The name is used to refer to a specific variant, and the configuration is the value of that variant. The configuration can be set using `configuration_value` property. `configuration_value` is an inline configuration that can be a string, number, boolean, or configuration object. If `configuration_value` isn't specified, the returned variant's `Configuration` property is `None`.
401400

@@ -427,7 +426,7 @@ A list of all possible variants is defined for each feature under the `variants`
427426
}
428427
```
429428

430-
#### Allocating Variants
429+
#### Allocating variants
431430

432431
The process of allocating a feature's variants is determined by the `allocation` property of the feature.
433432

@@ -490,9 +489,9 @@ If the feature is enabled, the feature manager checks the `user`, `group`, and `
490489
Allocation logic is similar to the [Microsoft.Targeting](#microsofttargeting) feature filter, but there are some parameters that are present in targeting that aren't in allocation, and vice versa. The outcomes of targeting and allocation aren't related.
491490

492491

493-
### Overriding Enabled State with a Variant
492+
### Overriding enabled state with a variant
494493

495-
You can use variants to override the enabled state of a feature flag. Overriding gives variants an opportunity to extend the evaluation of a feature flag. When calling `is_enabled` on a flag with variants, the Feature Manager will check if the variant assigned to the current user is configured to override the result. Overriding is done using the optional variant property `status_override`. By default, this property is set to `None`, which means the variant doesn't affect whether the flag is considered enabled or disabled. Setting `status_override` to `Enabled` allows the variant, when chosen, to override a flag to be enabled. Setting `status_override` to `Disabled` provides the opposite functionality, therefore disabling the flag when the variant is chosen. A feature with an `enabled` state of `false` can't be overridden.
494+
You can use variants to override the enabled state of a feature flag. Overriding gives variants an opportunity to extend the evaluation of a feature flag. When calling `is_enabled` on a flag with variants, the feature manager will check if the variant assigned to the current user is configured to override the result. Overriding is done using the optional variant property `status_override`. By default, this property is set to `None`, which means the variant doesn't affect whether the flag is considered enabled or disabled. Setting `status_override` to `Enabled` allows the variant, when chosen, to override a flag to be enabled. Setting `status_override` to `Disabled` provides the opposite functionality, therefore disabling the flag when the variant is chosen. A feature with an `enabled` state of `false` can't be overridden.
496495

497496
If you're using a feature flag with binary variants, the `status_override` property can be helpful. It allows you to continue using APIs like `is_enabled` in your application, all while benefiting from the new features that come with variants, such as percentile allocation and seed.
498497

@@ -536,7 +535,7 @@ When a feature flag change is deployed, it's often important to analyze its effe
536535

537536
These types of questions can be answered through the emission and analysis of feature flag evaluation events. This library optionally enables `AzureMonitor` produce tracing telemetry during feature flag evaluation via `OpenTelemetry`.
538537

539-
### Enabling Telemetry
538+
### Enabling telemetry
540539

541540
By default, feature flags don't have telemetry emitted. To publish telemetry for a given feature flag, the flag _MUST_ declare that it's enabled for telemetry emission.
542541

@@ -573,11 +572,12 @@ In addition, when creating `FeatureManager`, a callback must be registered to ha
573572
feature_manager = FeatureManager(feature_flags, on_feature_evaluated=publish_telemetry)
574573
```
575574

576-
### Application Insights Telemetry
575+
### Application Insights telemetry
577576

578-
The feature management library provides a built-in telemetry publisher that sends feature flag evaluation data to [Application Insights](/azure/azure-monitor/app/app-insights-overview). To enable Application Insights, the feature management library can be installed with Azure Monitor, `pip install FeatureManagement[AzureMonitor]`. Which installs the package `azure-monitor-events-extension` package, which is used to style telemetry to Application Insights using OpenTelemetry.
577+
The feature management library provides a built-in telemetry publisher that sends feature flag evaluation data to [Application Insights](/azure/azure-monitor/app/app-insights-overview). To enable Application Insights, the feature management library can be installed with Azure Monitor via `pip install FeatureManagement[AzureMonitor]`. This command installs the `azure-monitor-events-extension` package, which is used to style telemetry to Application Insights using OpenTelemetry.
579578

580-
NOTE: The extra only adds the telemetry to the Open Telemetry pipeline. Registering Application Insights is still required.
579+
> [!NOTE]
580+
> The `azure-monitor-events-extension` package only adds the telemetry to the Open Telemetry pipeline. Registering Application Insights is still required.
581581

582582
```python
583583
from azure.monitor.opentelemetry import configure_azure_monitor
@@ -587,7 +587,7 @@ configure_azure_monitor(
587587
)
588588
```
589589

590-
### Custom Telemetry Publishing
590+
### Custom telemetry publishing
591591

592592
Because the telemetry callback is a function, it can be customized to publish telemetry to any desired destination. For example, telemetry could be published to a logging service, a database, or a custom telemetry service.
593593

0 commit comments

Comments
 (0)