Skip to content

Commit 5711884

Browse files
committed
feat(metrics): add 1M designTime bucket and drain all crossed buckets
Adding 1M means a single 5-minute tick can cross more than one bucket (0 → 5 min crosses both 1M and 5M). Loop the bucket-emit check so every crossed bucket fires on the same tick rather than lagging one bucket behind per tick.
1 parent 6195ed4 commit 5711884

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

src/view/CentralControlBar.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ define(function (require, exports, module) {
230230
// first time the total crosses each of these minute buckets. A
231231
// 5-minute ticker rolls the in-progress stretch into the aggregate;
232232
// an exit also flushes so a partial stretch isn't dropped.
233-
const DESIGN_TIME_BUCKETS_MIN = [5, 10, 15, 20, 30, 45, 60];
233+
const DESIGN_TIME_BUCKETS_MIN = [1, 5, 10, 15, 20, 30, 45, 60];
234234
const MS_PER_MIN = 60 * 1000;
235235
const DESIGN_TIME_TICK_MS = 5 * MS_PER_MIN;
236236
let _designModeTimeFrom = null;
@@ -239,12 +239,16 @@ define(function (require, exports, module) {
239239

240240
function _emitCrossedDesignBuckets() {
241241
const minutes = Math.floor(_aggregateDesignMs / MS_PER_MIN);
242-
const checkIndex = _lastDesignBucketEmittedIdx + 1;
243-
if (checkIndex < DESIGN_TIME_BUCKETS_MIN.length &&
242+
// A single tick can cross more than one bucket (e.g. 0 → 5 min
243+
// crosses both 1M and 5M), so drain every bucket the aggregate
244+
// has now passed.
245+
let checkIndex = _lastDesignBucketEmittedIdx + 1;
246+
while (checkIndex < DESIGN_TIME_BUCKETS_MIN.length &&
244247
minutes >= DESIGN_TIME_BUCKETS_MIN[checkIndex]) {
245248
_lastDesignBucketEmittedIdx = checkIndex;
246249
Metrics.countEvent(Metrics.EVENT_TYPE.UI, "designTime",
247250
DESIGN_TIME_BUCKETS_MIN[checkIndex] + "M");
251+
checkIndex++;
248252
}
249253
}
250254

0 commit comments

Comments
 (0)