Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions components/nimbus/src/enrollment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub enum NotEnrolledReason {
/// The experiment enrollment is paused.
EnrollmentsPaused,
/// The experiment used a feature that was already under experiment.
FeatureConflict,
FeatureConflict { conflict_slug: Option<String> },
/// The evaluator bucketing did not choose us.
NotSelected,
/// We are not being targeted for this experiment.
Expand All @@ -73,7 +73,7 @@ impl Display for NotEnrolledReason {
NotEnrolledReason::DifferentAppName => "DifferentAppName",
NotEnrolledReason::DifferentChannel => "DifferentChannel",
NotEnrolledReason::EnrollmentsPaused => "EnrollmentsPaused",
NotEnrolledReason::FeatureConflict => "FeatureConflict",
NotEnrolledReason::FeatureConflict { .. } => "FeatureConflict",
NotEnrolledReason::NotSelected => "NotSelected",
NotEnrolledReason::NotTargeted => "NotTargeted",
NotEnrolledReason::OptOut => "OptOut",
Expand Down Expand Up @@ -905,7 +905,7 @@ impl<'a> EnrollmentsEvolver<'a> {
if matches!(
prev_enrollment.status,
EnrollmentStatus::NotEnrolled {
reason: NotEnrolledReason::FeatureConflict
reason: NotEnrolledReason::FeatureConflict { .. },
}
) {
continue;
Expand Down Expand Up @@ -985,7 +985,9 @@ impl<'a> EnrollmentsEvolver<'a> {
next_enrollments.push(ExperimentEnrollment {
slug: slug.clone(),
status: EnrollmentStatus::NotEnrolled {
reason: NotEnrolledReason::FeatureConflict,
reason: NotEnrolledReason::FeatureConflict {
conflict_slug: Some(needed_features_in_use[0].slug.clone()),
},
},
});

Expand Down Expand Up @@ -1014,7 +1016,7 @@ impl<'a> EnrollmentsEvolver<'a> {
|| matches!(
prev_enrollment.unwrap().status,
EnrollmentStatus::NotEnrolled {
reason: NotEnrolledReason::FeatureConflict
reason: NotEnrolledReason::FeatureConflict { .. }
}
)
{
Expand Down
9 changes: 8 additions & 1 deletion components/nimbus/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ impl From<ExperimentEnrollment> for EnrollmentStatusExtraDef {
let mut branch_value: Option<String> = None;
let mut reason_value: Option<String> = None;
let mut error_value: Option<String> = None;
let mut conflict_slug_value: Option<String> = None;
match &enrollment.status {
EnrollmentStatus::Enrolled { reason, branch, .. } => {
branch_value = Some(branch.to_owned());
Expand All @@ -41,6 +42,12 @@ impl From<ExperimentEnrollment> for EnrollmentStatusExtraDef {
}
EnrollmentStatus::NotEnrolled { reason } => {
reason_value = Some(reason.to_string());
conflict_slug_value = match reason {
crate::enrollment::NotEnrolledReason::FeatureConflict { conflict_slug } => {
conflict_slug.to_owned()
}
_ => None,
};
}
EnrollmentStatus::WasEnrolled { branch, .. } => branch_value = Some(branch.to_owned()),
EnrollmentStatus::Error { reason } => {
Expand All @@ -49,7 +56,7 @@ impl From<ExperimentEnrollment> for EnrollmentStatusExtraDef {
}
EnrollmentStatusExtraDef {
branch: branch_value,
conflict_slug: None,
conflict_slug: conflict_slug_value,
error_string: error_value,
reason: reason_value,
slug: Some(enrollment.slug),
Expand Down
2 changes: 1 addition & 1 deletion components/nimbus/src/tests/test_enrollment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1468,7 +1468,7 @@ fn test_evolver_experiment_not_enrolled_feature_conflict() -> Result<()> {
matches!(
e.status,
EnrollmentStatus::NotEnrolled {
reason: NotEnrolledReason::FeatureConflict
reason: NotEnrolledReason::FeatureConflict { .. }
}
)
})
Expand Down
4 changes: 2 additions & 2 deletions components/nimbus/src/tests/test_enrollment_bw_compat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@ fn test_not_enrolled_reason_schema_with_feature_conflict() {
let non_enrollment: ExperimentEnrollment = serde_json::from_value(json!({
"slug": "secure-gold",
"status": {"NotEnrolled": {
"reason": "FeatureConflict",
"reason": { "FeatureConflict": { "conflict_slug": Some("conflicting-feature") } },
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There is a line above this that says:

// ⚠️ Warning : Do not change the JSON data used by this test. ⚠️

This test as written is not very useful. It should instead be re-written (with the original JSON) to

  • write the original JSON to the database
  • set the database version to v3
  • load the database
  • read the enrollment for "secure-gold"
  • validate that it parses with conflict_slug == None

}}
}))
.unwrap();
assert!(
matches!(non_enrollment.status, EnrollmentStatus::NotEnrolled{ ref reason, ..} if reason == &NotEnrolledReason::FeatureConflict)
matches!(non_enrollment.status, EnrollmentStatus::NotEnrolled{ ref reason, ..} if reason == &NotEnrolledReason::FeatureConflict { conflict_slug: Some("conflicting-feature".to_string()) })
);
}

Expand Down