Skip to content

Conversation

@mnoman09
Copy link
Contributor

@mnoman09 mnoman09 commented Jul 1, 2020

Summary

  • Added and updated missing audience evaluation logs.

Test plan

added unit tests must pass and all FSC scenarios should pass

@coveralls
Copy link

coveralls commented Jul 6, 2020

Pull Request Test Coverage Report for Build 1467

  • 23 of 25 (92.0%) changed or added relevant lines in 8 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.07%) to 89.419%

Changes Missing Coverage Covered Lines Changed/Added Lines %
core-api/src/main/java/com/optimizely/ab/internal/LoggingConstants.java 0 2 0.0%
Files with Coverage Reduction New Missed Lines %
core-api/src/main/java/com/optimizely/ab/config/audience/Audience.java 1 90.0%
Totals Coverage Status
Change from base Build 1459: -0.07%
Covered Lines: 3955
Relevant Lines: 4423

💛 - Coveralls
@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
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));
Copy link
Contributor

Choose a reason for hiding this comment

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

was it additional?

Copy link
Contributor Author

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.

@Nonnull String loggingKey) {
if (experiment.getAudienceConditions() != null) {
Boolean resolveReturn = evaluateAudienceConditions(projectConfig, experiment, attributes);
Boolean resolveReturn = evaluateAudienceConditions(projectConfig, experiment, attributes, audienceFor, loggingKey);
Copy link
Contributor

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.

OrCondition implicitOr = new OrCondition(conditions);

logger.debug("Evaluating audiences for experiment \"{}\": \"{}\"", experiment.getKey(), conditions);
logger.debug("Evaluating audiences for {} \"{}\": {}.", audienceFor, loggingKey, conditions);
Copy link
Contributor

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...

Copy link
Contributor Author

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);
Copy link
Contributor

Choose a reason for hiding this comment

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

Please move it.

@mnoman09 mnoman09 requested a review from msohailhussain July 10, 2020 14:11
@mnoman09 mnoman09 removed their assignment Jul 10, 2020
@mnoman09 mnoman09 marked this pull request as ready for review July 14, 2020 10:09
@mnoman09 mnoman09 requested a review from a team as a code owner July 14, 2020 10:09
Copy link
Contributor

@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.

Minor changes suggested. Mostly looks good.

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());
Copy link
Contributor

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.

Copy link
Contributor Author

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\"."
Copy link
Contributor

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>

* @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.
Copy link
Contributor

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?

assertEquals(expectedVariation, featureDecision.variation);
assertEquals(FeatureDecision.DecisionSource.ROLLOUT, featureDecision.decisionSource);

logbackVerifier.expectMessage(Level.DEBUG, "There is no Audience associated with experiment 828245624");
Copy link
Contributor

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?

logger.info("Got variable value \"{}\" for variable \"{}\" of feature flag \"{}\".", variableValue, variableKey, featureKey);
} else {
variableValue = variable.getDefaultValue();
logger.info("Variable \"{}\" value is not defined. Returning default value \"{}\".", variableKey, variableValue);
Copy link
Contributor

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 "{}"

Copy link
Contributor

@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.

Just 1 small change needed before merging.

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

7 participants