-
Notifications
You must be signed in to change notification settings - Fork 229
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
Nimbus: add enrollment_status metric #5857
Nimbus: add enrollment_status metric #5857
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5857 +/- ##
==========================================
- Coverage 36.81% 36.73% -0.09%
==========================================
Files 347 348 +1
Lines 33447 33522 +75
==========================================
Hits 12313 12313
- Misses 21134 21209 +75 ☔ View full report in Codecov by Sentry. |
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.
Pre-reviewing myself to share some thoughts I have already
components/nimbus/android/src/main/java/org/mozilla/experiments/nimbus/Nimbus.kt
Outdated
Show resolved
Hide resolved
impl EnrollmentStatus { | ||
pub fn name(&self) -> String { | ||
match self { | ||
EnrollmentStatus::Enrolled { .. } => "Enrolled", | ||
EnrollmentStatus::NotEnrolled { .. } => "NotEnrolled", | ||
EnrollmentStatus::Disqualified { .. } => "Disqualified", | ||
EnrollmentStatus::WasEnrolled { .. } => "WasEnrolled", | ||
EnrollmentStatus::Error { .. } => "Error", | ||
} | ||
.into() | ||
} | ||
} |
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.
So I couldn't use the fmt::Debug
thing here because it ends up including the values associated with each enum and that
- makes testing difficult at best
- shouldn't be sent to Glean according to the metric spec
If there's a better way I could've done this please let me know!
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.
You might be better keeping this as an implementation of fmt::Display
to keep it consistent with the other enums— notwithstanding my previous comment about using Display to serialize.
The associated values can still be displayed with Debug
.
components/nimbus/src/metrics.rs
Outdated
} | ||
|
||
#[derive(Serialize, Deserialize, Clone)] | ||
#[serde(remote = "EnrollmentStatusExtra")] |
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 is nice because even though we have to manually re-define the struct here, the serde-remote
piece does at least verify that they have the same members.
let mut reason_value: Option<String> = None; | ||
let mut error_value: Option<String> = None; | ||
match &enrollment.status { | ||
EnrollmentStatus::Enrolled { reason, branch, .. } => { |
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.
So idk if there's a way I could cast reason
to a string from its enum type right here but it'd be nice because I could fold two of these branches up into one.
Request for data collection review form
* ref. telemetry proposal document, linked in the ticket linked on this PR.
data-review?@eliserichards |
Data Review Form (to be filled by Data Stewards)
Resultdata-review+ |
@jeddai does this also includes cirrus? |
@yashikakhurana Nope! Cirrus will be implemented in two separate PRs as it'll be a breaking change. The PRs will be as follows:
|
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.
A few nits, a couple of questions, but otherwise looking good!
Of the larger issues, I'm least sure about: the Glean dependency, and exposing testing methods to the FFI.
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
fmt::Debug::fmt(self, f) | ||
} | ||
} |
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.
I'm not sure I like this (forwarding straight to Debug
) but I don't see any merit in changing it.
FTR: Display
feels like the wrong tool here; since we're using it to Serialize
to go over the FFI.
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.
I ended up replacing Display
with From<EnumType> for String
and manually noting the variant names in a match.
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.
impl From<_> for String
also feels weird. I like the explicit match
rather than the forwarding to Debug
, but Display
feels like it's doing the job of Into<String> for &T
.
impl EnrollmentStatus { | ||
pub fn name(&self) -> String { | ||
match self { | ||
EnrollmentStatus::Enrolled { .. } => "Enrolled", | ||
EnrollmentStatus::NotEnrolled { .. } => "NotEnrolled", | ||
EnrollmentStatus::Disqualified { .. } => "Disqualified", | ||
EnrollmentStatus::WasEnrolled { .. } => "WasEnrolled", | ||
EnrollmentStatus::Error { .. } => "Error", | ||
} | ||
.into() | ||
} | ||
} |
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.
You might be better keeping this as an implementation of fmt::Display
to keep it consistent with the other enums— notwithstanding my previous comment about using Display to serialize.
The associated values can still be displayed with Debug
.
components/nimbus/android/src/main/java/org/mozilla/experiments/nimbus/Nimbus.kt
Show resolved
Hide resolved
Fantastic @jeddai 🎉 🎉 🎉 🎉 |
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.
A few more nits and some questions; but nothing that needs another review cycle. Well done, that was a mammoth review/PR cycle.
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
fmt::Debug::fmt(self, f) | ||
} | ||
} |
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.
impl From<_> for String
also feels weird. I like the explicit match
rather than the forwarding to Debug
, but Display
feels like it's doing the job of Into<String> for &T
.
d99b9e5
to
9761397
Compare
update changelog
Thanks! To be fair it's a pretty big change to our existing patterns so I feel like it was fair that it was a longer review |
9761397
to
0a1300c
Compare
https://mozilla-hub.atlassian.net/browse/EXP-3827
This PR does a number of things, collectively a part of the above ticket.
Pull Request checklist
[ci full]
to the PR title.Branch builds: add
[firefox-android: branch-name]
to the PR title.