-
Notifications
You must be signed in to change notification settings - Fork 34
Bug 1723090 - Delete trailing glean.restarted events #1452
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 1723090 - Delete trailing glean.restarted events #1452
Conversation
When we send a ping, we want to avoid passing unnecessary trailing restarted events. Before we return the payload, we can step backwards through our events array and pop each restarted event until we hit an event that is a non-restarted event. At this point we return the array since all trailing events have been removed. In the case that the array does not have a trailing restarted event, we avoid invoking the new functionality completely.
We generate an array of events, in a somewhat unorthodox manner to ensure that our original array contains multiple trailing restarted events. We then put a few restarted events between non-restarted events to verify that we stop removing items once we hit a non-restarted event.
We no longer keep `glean.restarted` events at the end of the events array, so the tests needed to be updated to reflect that. The tests check everything the same way, they just no longer check that the final item is a `glean.restarted` event.
6d4ea73 to
77e8cdd
Compare
|
I want to get a second opinion on what should be updated in the docs. If you look under We now strip the first restarted event from the events array as well as all trailing events. I may lack enough context to know for sure, but I would think that there is a possibility now where that event doesn't get passed at all. I am going to do some testing with the sample projects to try and confirm as well. |
Found a more straightforward way to trigger a restart without forcing an error.
- Additional clarifying comments - More descriptive variable names for mock events array values.
54fbc1e to
9772c2e
Compare
|
Just noticed that I wrote some comments, but didn't submit them -_- |
badboy
left a comment
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.
Code looks good, but PR is still in draft mode. If you're ready turn it into a full PR please.
I think that wording is still correct, though is leaving out a bit of context. |
Was just waiting on some feedback for the docs part since I knew that was going to still need updating before publishing for real. I will update the docs with that additional context, look at triggering restarts without an error, then publish this. @badboy thanks for the multiple reviews! |
yeah, I'm not sure how to concisely add that for the single metric. |
@badboy |
- generate barrel file to better manage `testing/core` exports - create testing util that restarts glean by creating a new instance of the `EventsDatabase` - update existing and new tests to use new restart helper
1bb3d33 to
b5fe0a1
Compare
| await testInitializeGlean(applicationId, uploadEnabled, config); | ||
| } | ||
|
|
||
| export * from "./utils.js"; |
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.
Clarification for this
A more common pattern in JS/TS is to bubble all of your folder/module exports up to an index.ts file, "barrel file", and export everything from there.
That way when you are accessing different functions/variables/constants you only have to drill down to the top level of the folder when importing. So instead of pulling 3 things from index, 4 things from utils, etc, you re-export everything you need from the index then you can just import it all via import {} from '../core/testing.
This also helps to keep things more organized and modular. You start to see very quickly what may be tightly coupled to a module that doesn't need to be.
|
PR is now ready for review. I've made all PR changes as well as create a documentation update PR for the Glean Book. |
Description
Add functionality to delete all trailing
glean.restartedevents. Now before returning the formatted events for the ping, we pop items from the array until we hit one that isn't arestartedevent. If the last item is not aglean.restartedevent, then it will not do anything.Glean Book Documentation PR - mozilla/glean#2172
Pull Request checklist
glean/folder, run:npm run testRuns all testsnpm run lintRuns all lintersCHANGELOG.mdor an explanation of why it does not need onemozilla/gleanrepository