[glean] Timespans should gracefully handle nesting of start/stop calls
Categories
(Toolkit :: Telemetry, enhancement, P3)
Tracking
()
People
(Reporter: mdroettboom, Assigned: mdroettboom)
Details
(Whiteboard: [telemetry:mobilesdk:m7])
Given the following nested calls to start/stop (which would probably be inside different nested functions where that case would be less obvious):
1 timespan.start()
2 timespan.start()
3 timespan.stopAndSum()
4 timespan.stopAndSum()
In the current implementation, line (2) will record an error, but not replace the start value. Line (3) will record the timing between (3) and (1). Line (4) will be a no-op.
It would be probably saner to detect the level of nesting in a counter and record the timing between (4) and (1). It could be argued that given that behavior, the recorded error should be demoted to a warning.
Updated•7 years ago
|
| Assignee | ||
Updated•7 years ago
|
Comment 1•7 years ago
|
||
(In reply to Michael Droettboom [:mdroettboom] from comment #0)
Given the following nested calls to
start/stop(which would probably be inside different nested functions where that case would be less obvious):1 timespan.start() 2 timespan.start() 3 timespan.stopAndSum() 4 timespan.stopAndSum()In the current implementation, line (2) will record an error, but not replace the start value. Line (3) will record the timing between (3) and (1). Line (4) will be a no-op.
It would be probably saner to detect the level of nesting in a counter and record the timing between (4) and (1). It could be argued that given that behavior, the recorded error should be demoted to a warning.
I'm not entirely sure we want to have such a complex behaviour. It might be more consistent with the other APIs (especially the TimespanMetricType) to just have (4) record an error rather than only no-op.
I think this needs to be discussed alongside with bug 1541493.
Updated•7 years ago
|
| Assignee | ||
Comment 2•7 years ago
|
||
This seems like an easy fix to avoid an easy-to-find footgun.
But, I agree, using a utility class so that multiple timers could be used overlapping at the same time as suggested in 1541493 would be even better, and we could handle them in a similar manner.
| Assignee | ||
Updated•7 years ago
|
| Assignee | ||
Comment 3•7 years ago
|
||
Closing in favor of 1541493.
Description
•