-
Notifications
You must be signed in to change notification settings - Fork 32
refact(audience-logs): Added and refactored audience and feature variable evaluation logs #380
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
Conversation
Pull Request Test Coverage Report for Build 1467
💛 - Coveralls |
@@ -221,25 +223,24 @@ FeatureDecision getVariationForFeatureInRollout(@Nonnull FeatureFlag featureFlag | |||
Variation variation; | |||
for (int i = 0; i < rolloutRulesLength - 1; i++) { | |||
Experiment rolloutRule = rollout.getExperiments().get(i); | |||
Audience audience = projectConfig.getAudienceIdMapping().get(rolloutRule.getAudienceIds().get(0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
was it additional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes as we removed the audience name this became redundant.
if (experiment.getAudienceConditions() != null) { | ||
Boolean resolveReturn = evaluateAudienceConditions(projectConfig, experiment, attributes); | ||
Boolean resolveReturn = evaluateAudienceConditions(projectConfig, experiment, attributes, audienceFor, loggingKey); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
evaluation log should be here. Not in the method.
@@ -93,26 +99,28 @@ public static Boolean evaluateAudience(@Nonnull ProjectConfig projectConfig, | |||
|
|||
OrCondition implicitOr = new OrCondition(conditions); | |||
|
|||
logger.debug("Evaluating audiences for experiment \"{}\": \"{}\"", experiment.getKey(), conditions); | |||
logger.debug("Evaluating audiences for {} \"{}\": {}.", audienceFor, loggingKey, conditions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be in doesUser...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we should not move it to doesUserMeetCondition method because list of conditions object is created here. To move this log we would have to move the loop too.
|
||
Condition conditions = experiment.getAudienceConditions(); | ||
if (conditions == null) return null; | ||
logger.debug("Evaluating audiences for experiment \"{}\": \"{}\"", experiment.getKey(), conditions.toString()); | ||
logger.debug("Evaluating audiences for {} \"{}\": {}.", audienceFor, loggingKey, conditions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please move it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor changes suggested. Mostly looks good.
@@ -74,9 +74,9 @@ public Boolean evaluate(ProjectConfig config, Map<String, ?> attributes) { | |||
logger.error("Audience {} could not be found.", audienceId); | |||
return null; | |||
} | |||
logger.debug("Starting to evaluate audience {} with conditions: \"{}\"", audience.getName(), audience.getConditions()); | |||
logger.debug("Starting to evaluate audience \"{}\" with conditions: {}.", audience.getId(), audience.getConditions()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's get rid of this log message. I don't see this in other places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually this log is getting logged in all other sdks, including python (which we followed).
|
||
logbackVerifier.expectMessage( | ||
Level.INFO, | ||
"Variable \"integer_variable\" is not used in variation \"589640735\", returning default value \"7\"." |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This log message denotes that the code needs to be updated. Please see recommendations to what this message should be. I think it is Variable <variable name> 's value is not defined. Returning default value <value>
@@ -59,24 +59,31 @@ public static boolean isExperimentActive(@Nonnull Experiment experiment) { | |||
* @param projectConfig the current projectConfig | |||
* @param experiment the experiment we are evaluating audiences for | |||
* @param attributes the attributes of the user | |||
* @param audienceFor It can be either experiment or rule. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May be call this loggingEntityType
or entityType
?
@@ -664,6 +672,9 @@ public void getVariationForFeatureInRolloutReturnsVariationWhenUserFailsTrafficI | |||
assertEquals(expectedVariation, featureDecision.variation); | |||
assertEquals(FeatureDecision.DecisionSource.ROLLOUT, featureDecision.decisionSource); | |||
|
|||
logbackVerifier.expectMessage(Level.DEBUG, "There is no Audience associated with experiment 828245624"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should get rid of this log message in code I feel. Where is this exactly?
} else { | ||
variableValue = variable.getDefaultValue(); | ||
logger.info("Variable \"{}\" value is not defined. Returning default value \"{}\".", variableKey, variableValue); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Slight correction needed in the first sentence. It will be awkward to put apostrophe. May be say Value is not defined for variable "{}"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just 1 small change needed before merging.
Summary
Test plan
added unit tests must pass and all FSC scenarios should pass