Skip to content

Conversation

@mnoman09
Copy link
Contributor

@mnoman09 mnoman09 commented Jul 7, 2020

Summary

  • Added and updated missing audience evaluation logs.

Test plan

added unit tests must pass and all FSC scenarios should pass

};

Assert.True(ExperimentUtils.IsUserInExperiment(Config, experiment, userAttributes, Logger));
Assert.True(ExperimentUtils.IsUserInExperiment(Config, experiment, userAttributes, "experiment", experiment.Key, Logger));
Copy link
Contributor

Choose a reason for hiding this comment

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

IsUserInExperiment Please rename it.

}

if (ExperimentUtils.IsUserInExperiment(config, experiment, filteredAttributes, Logger))
if (ExperimentUtils.IsUserInExperiment(config, experiment, filteredAttributes, "experiment", experiment.Key, Logger))
Copy link
Contributor

Choose a reason for hiding this comment

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

rename it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Please use const experiment, don't pass string as it is.

Copy link
Contributor

@msohailhussain msohailhussain left a comment

Choose a reason for hiding this comment

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

mostly looks good. please rename method name and add AUDIENCE_FOR_EXPERIMENT and AUDIENCE_FOR_ROLLOUT as const.

@msohailhussain msohailhussain marked this pull request as ready for review July 8, 2020 16:48
@msohailhussain msohailhussain requested a review from a team as a code owner July 8, 2020 16:48
@mnoman09 mnoman09 changed the title refact(audience-logs): Added and refactored audience evaluation logs refact(audience-logs): Added and refactored audience and feature variable evaluation logs Jul 8, 2020
@msohailhussain msohailhussain changed the title refact(audience-logs): Added and refactored audience and feature variable evaluation logs fix(logs): Added and refactored audience and feature variable evaluation logs Jul 8, 2020

if (featureEnabled == true)
Logger.Log(LogLevel.INFO, $@"Feature flag ""{featureKey}"" is enabled for user ""{userId}"".");
Logger.Log(LogLevel.INFO, $@"Feature ""{featureKey}"" is enabled for user ""{userId}"".");
Copy link
Contributor

Choose a reason for hiding this comment

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

Following logs doesn't seem correct to me.

else
{
Logger.Log(LogLevel.INFO, $@"Feature ""{featureKey}"" is not enabled for user {userId}. Returning default value for variable ""{variableKey}"".");
Logger.Log(LogLevel.INFO, $@"Feature ""{featureKey}"" is not enabled for user {userId}. Returning the default variable value ""{variableValue}"".");
Copy link
Contributor

Choose a reason for hiding this comment

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

                    'Feature "%s" is not enabled for user "%s". '
                    'Returning the default variable value "%s".' % (feature_key, user_id, variable_value)
                )```

{
variableValue = featureVariableUsageInstance.Value;
Logger.Log(LogLevel.INFO, $@"Returning variable value ""{variableValue}"" for variation ""{variation.Key}"" of feature flag ""{featureKey}"".");
Logger.Log(LogLevel.INFO, $@"Feature ""{featureKey}"" is enabled for user ""{userId}"".");
Copy link
Contributor

@msohailhussain msohailhussain Jul 8, 2020

Choose a reason for hiding this comment

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

                    'Got variable value "%s" for variable "%s" of feature flag "%s".'
                    % (variable_value, variable_key, feature_key)
                )```

Copy link

@aliabbasrizvi aliabbasrizvi left a comment

Choose a reason for hiding this comment

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

Small changes needed. Looks good mostly.



[Test]
public void TestIsUserInExperimentNoAudienceUsedInExperiment()

Choose a reason for hiding this comment

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

The name of the method has changed to: DoesUserMeetAudienceConditions. Please update test names accordingly.

Comment on lines 41 to 42
public const string AUDIENCE_FOR_EXPERIMENT = "experiment";
public const string AUDIENCE_FOR_RULE = "rule";

Choose a reason for hiding this comment

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

These variable names and the docstring above it do not make sense.

Comment on lines +46 to +47
public static bool DoesUserMeetAudienceConditions(ProjectConfig config,
Experiment experiment,

Choose a reason for hiding this comment

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

Parameter descriptions above need to be updated.

public static bool DoesUserMeetAudienceConditions(ProjectConfig config,
Experiment experiment,
UserAttributes userAttributes,
string audienceFor,

Choose a reason for hiding this comment

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

audienceFor? Why not something like loggingKeyType?

Copy link

@aliabbasrizvi aliabbasrizvi left a comment

Choose a reason for hiding this comment

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

Looks good. Small change needed in docstring.

/// <param name="experiment">Experiment Entity representing the experiment</param>
/// <param name="userAttributes">Attributes of the user. Defaults to empty attributes array if not provided</param>
/// <param name="loggingKeyType">It can be either experiment or rule.</param>
/// <param name="loggingKey">In case of loggingKeyType is experiment it will be experiment key or else it will be rule number.</param>

Choose a reason for hiding this comment

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

nit. In case loggingKeyType is experiment

Copy link
Contributor

@msohailhussain msohailhussain left a comment

Choose a reason for hiding this comment

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

lgtm

@mikeproeng37 mikeproeng37 merged commit 11e7df7 into master Jul 27, 2020
@mikeproeng37 mikeproeng37 deleted the mnoman/audienceAuditLogging branch July 27, 2020 18:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants