-
Notifications
You must be signed in to change notification settings - Fork 117
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
Bug 1804711 - Add schedules_pings property to pings so that pings can be scheduled to be sent alongside other pings. #2791
Conversation
So at least some of these failures are due to the fact that the CI isn't using the glean_parser patch in mozilla/glean_parser#682. I'm not sure what to do about that. |
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.
time 'til someone creates a ping cycle: ....
kidding, but it technically is a risk.
We should definitely come up with some documentation around this.
(oh and one note: argh, so many little changes necessary for a new parameter. not your fault though!)
glean-core/src/metrics/ping.rs
Outdated
@@ -130,6 +138,10 @@ impl PingType { | |||
self.0.include_info_sections | |||
} | |||
|
|||
pub(crate) fn schedules_pings(&self) -> &Vec<String> { |
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.
pub(crate) fn schedules_pings(&self) -> &Vec<String> { | |
pub(crate) fn schedules_pings(&self) -> &[String] { |
it's unusual to return a reference to a vec.
ping.schedules_pings | ||
); | ||
for scheduled_ping_name in &ping.schedules_pings { | ||
glean.submit_ping_by_name(scheduled_ping_name, reason); |
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.
Hm, that means we also use the same reason. The reason for the actual submitted ping might not be specified for the linked ping.
We should at the very least document that related pings should use the same reasons (this might be done in a followup).
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.
That makes sense, if a custom ping is sharing an internal ping schedule, then the reason
it was sent should match. I agree, we should document this behavior and probably might go a step further and either add a glean_parser lint or outright forbid pings that make use of internal ping schedules from declaring their own reasons.
That's fine, we can review the code and once we're happy we do the glean_parser release and pull that into this PR as well (it's an unfortunate shortcoming of the repo split) |
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 all looks fine to me, I'm looking at glean_parser changes next but provided we add the documentation requested and a changelog entry, I think this should be fine. I'm headed to take a look at the glean_parser changes next.
ping.schedules_pings | ||
); | ||
for scheduled_ping_name in &ping.schedules_pings { | ||
glean.submit_ping_by_name(scheduled_ping_name, reason); |
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.
That makes sense, if a custom ping is sharing an internal ping schedule, then the reason
it was sent should match. I agree, we should document this behavior and probably might go a step further and either add a glean_parser lint or outright forbid pings that make use of internal ping schedules from declaring their own reasons.
229ec8f
to
6c68c12
Compare
I ended up hitting a "too-many-arguments" clippy failure in metrics/ping.rs, but I figured it was a bit out of scope to change Glean's constructor signature for PingType to avoid this, so I added an allow.
…chedules_pings. While glean_parser will try to prevent the base-case of pings trying to schedule _themselves_ when being sent, nothing in this stack takes care of the problem of recursive cycles of pings. So if we have PingA scheduled to be sent when PingB is sent, and PingB is scheduled to be sent when PingC is sent, and PingC is scheduled to be sent when PingA is sent... things get messy indeed, and I think we might get stuck in a ping-sending loop.
6c68c12
to
452e315
Compare
Since this requires a little interaction in order to merge with the changes I was working on, and include an update to glean_parser, let's not land this PR directly. Instead, I've merged it into my PR #2792 and will include a commit in that stack that will update glean_parser in glean-core. I won't squash my PR to preserve the commit history post merge. Any objections or problems that anyone sees with that approach, please let me know. |
Merged as part of #2792 |
This is for https://bugzilla.mozilla.org/show_bug.cgi?id=1804711.
This relies on mozilla/glean_parser#682.
What this does it make it possible for a Glean ping to declare that it wants to be sent when another ping is sent. Supposing some product wanted to sent a ping as frequently as the baseline ping, then that ping could use the
ping_schedule
metadata property and listbaseline
.This pull request is the part that takes the reverse-mapping that glean_parser creates, and actually does the lookup for other scheduled pings when a ping is sent.
I note this in one of the commit messages, but I think it's worth calling out here too:
While glean_parser will try to prevent the base-case of pings trying to schedule themselves when being sent, nothing in this stack takes care of the problem of recursive cycles of pings.
So if we have PingA scheduled to be sent when PingB is sent, and PingB is scheduled to be sent when PingC is sent, and PingC is scheduled to be sent when PingA is sent... things get messy indeed, and I think we might get stuck in a ping-sending loop.