Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add variants for feature flags #250

Merged
merged 85 commits into from
Sep 13, 2023
Merged

Conversation

amerjusupovic
Copy link
Contributor

No description provided.

…ces to keep existing usage possible. (#133)" (#138)"

This reverts commit 8f9a7e4.

string rawFeatureStatus = configurationSection[ConfigurationFields.FeatureStatus];

string parseEnumErrorString = "Invalid {0} with value '{1}' for feature '{2}'.";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

const string

{
throw new FeatureManagementException(
FeatureManagementError.InvalidConfigurationSetting,
string.Format(parseEnumErrorString, nameof(FeatureStatus), rawFeatureStatus, configurationSection.Key));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
string.Format(parseEnumErrorString, nameof(FeatureStatus), rawFeatureStatus, configurationSection.Key));
string.Format(parseEnumErrorString, ConfigurationFields.FeatureStatus, rawFeatureStatus, configurationSection.Key));

Name = section[ConfigurationFields.NameKeyword],
ConfigurationValue = section.GetSection(ConfigurationFields.VariantDefinitionConfigurationValue),
ConfigurationReference = section[ConfigurationFields.VariantDefinitionConfigurationReference],
StatusOverride = section.GetValue<StatusOverride>(ConfigurationFields.VariantDefinitionStatusOverride)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why isn't this enum handled like others?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad, this should definitely be checked like the previous enums. I'll add a test for invalid StatusOverride value.

@jimmyca15
Copy link
Member

Wondering if we should have a preview branch that we merge this into.

@rossgrambo
Copy link
Contributor

I think a preview branch is a good idea. We'll want to merge telemetry and variants somewhere outside of main.

@amerjusupovic amerjusupovic changed the base branch from main to preview September 7, 2023 22:34
@amerjusupovic
Copy link
Contributor Author

Created a new preview branch from main.

private readonly IConfiguration _configuration;
private readonly ConcurrentDictionary<string, FeatureDefinition> _definitions;
private IDisposable _changeSubscription;
private int _stale = 0;

const string ParseValueErrorString = "Invalid {0} with value '{1}' for feature '{2}'.";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How come {0} isn't in single quotes ? And shouldn't it be "Invalid settting '{0}' with value..."

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just based the format string off of the old error message, but since we're using a variable now I understand adding the single quotes.


if (from > to)
{
throw new ArgumentException($"Double {nameof(from)} cannot be larger than double {nameof(to)}.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Both usage of "double" should be replaced with "value of"

{
if (string.IsNullOrEmpty(percentile.Variant))
{
_logger.LogWarning($"Missing variant name for {nameof(featureDefinition.Allocation.Percentile)} allocation in feature {featureDefinition.Name}");
Copy link
Member

@jimmyca15 jimmyca15 Sep 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The way this is used it seems like it should just be hardcoded literal "percentile"

percentile.From,
percentile.To,
_assignerOptions.IgnoreCase,
featureDefinition.Allocation.Seed))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If seed is null, we should use feature name.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would ensure that flags have different seeds by default. This ensures whoever gets mapped to 1% isn't thrown into every experiment always.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Although, there is an argument that Allocation might not want to default to the same % mapping that targeting uses. Because a targeting filter of 50% with an allocation of 50% means 100% of the 50% would be allocated.

So perhaps we should default to feature name, but add "allocation" at the end or something. @jimmyca15 what do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rossgrambo makes sense. Although I would put any addition before the flag name since it's unchanging and acts like prefix in my eyes.

Co-authored-by: Jimmy Campbell <jimmyca@microsoft.com>
@amerjusupovic amerjusupovic merged commit b1b1562 into preview Sep 13, 2023
2 checks passed
if (string.Equals(featureFilterConfiguration.Name, "AlwaysOn", StringComparison.OrdinalIgnoreCase))
// Handle AlwaysOn and On filters
if (string.Equals(featureFilterConfiguration.Name, "AlwaysOn", StringComparison.OrdinalIgnoreCase) ||
string.Equals(featureFilterConfiguration.Name, "On", StringComparison.OrdinalIgnoreCase))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we mention that the filter name "On" is also occupied and it is a built-in filter in the document.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants