-
Notifications
You must be signed in to change notification settings - Fork 132
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
1588452: Don't crash TimingDistribution.start() prior to Glean.init #400
1588452: Don't crash TimingDistribution.start() prior to Glean.init #400
Conversation
70f13de
to
3419085
Compare
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 take it this was very similar to the fix for the dynamic labels...
Codecov Report
@@ Coverage Diff @@
## master #400 +/- ##
============================================
+ Coverage 76.25% 76.28% +0.02%
Complexity 308 308
============================================
Files 95 95
Lines 5374 5371 -3
Branches 632 631 -1
============================================
- Hits 4098 4097 -1
+ Misses 807 806 -1
+ Partials 469 468 -1
Continue to review full report at Codecov.
|
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 has slight semantic changes though:
Right now if upload is disabled and you try to use a timing distribution, no timer is started. When you enable upload and then stop, no value is recorded (as nothing was started).
With this change, when upload is disabled and you start, a timer is started.
When Glean upload is enabled and then stop is called, you get the whole timespan from before Glean upload was enabled up until the stop.
Indeed, there are semantic changes, but I think for the better. I think upload enabled should control only the uploading, not the (admittedly needless) handling of timers, otherwise the semantics lead to non-error errors. Before this change:
With this change:
And in the scenario you suggest:
This seems correct to me. Whatever was being timed is correct. Before this change, it would record an error. I guess you're thinking that times that start in the opt-out window but end in the opt-in window shouldn't be recorded? I would have thought only timings that start and end in the opt-out window shouldn't be recorded, which is true both before and after this change. |
And I guess this is the point which I'm unsure about, but I also have no opinion in either way. I'm calling in a @chutten |
Y'see, this is another one of those situations where separating Though if we split them we'd run into problems where, until init happens, To the case in question, I think mdboom's approach is the better one for developer ergonomics. Some component with a timing distribution doesn't know if the app has set |
That's ... not the entire truth. We defer actual recording (and the isUploadEnabled check) to after the init, we do store the value of time-related functionality before the init (e.g. in timespan or timing distribution), in memory only though. |
Fair enough, we should just make sure we properly document this in at least the changelog I assume? |
I've updated the timing distribution docs on the exact semantics wrt upload enabled. Hopefully that clears up the confusion... |
38433ef
to
1ab9c16
Compare
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.
Now nothing is holding back my r+ anymore.
I suggest a slight rewording in the docs though.
And now that we have a release (and future releases!) we should get into the habit of documenting important stuff in the CHANGELOG.md
@@ -7,6 +7,10 @@ To measure the distribution of single timespans, see [Timespans](timespan.md). T | |||
Timing distributions are recorded in a histogram where the buckets have an exponential distribution, specifically with 8 buckets for every power of 2. | |||
This makes them suitable for measuring timings on a number of time scales without any configuration. | |||
|
|||
The effect of Glean's "upload enabled" flag occurs when a timing is stopped. |
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 would simplify that a bit. Calling it "flag" and such seems too wordy.
What about:
Timings always span the full length between `start` and `stopAndAccumulate`.
If the Glean upload is disabled when calling `start`, the timer is still started.
If the Glean upload is disabled at the time `stopAndAccumulate` is called, nothing is recorded.
Maybe the sentence about start
could even be left out.
I missed this as part of mozilla#400. It is now fully covered by the tests added there. Also \o/ last `@Ignore`d test!
* CLEANUP: Remove test for preinit timing distribution recording I missed this as part of #400. It is now fully covered by the tests added there. Also \o/ last `@Ignore`d test! * Remove unused imports
TimingDistributionMetricType.start()
doesn't really need a Glean object, since it doesn't matter whether upload is enabled or not to start the timer. It only matters later when we stop and record the sample, so we can just to that there only.