Buildbucket Monitor is a micro-service that periodically computes and reports aggregate views of Build stats. For example:
A cron request is triggered periodically. The cron handler computes and reports aggregate views of Build events, using a manual flush().
It's to avoid unnecessary resets on the in-memory metric storage. Once metric data is set, tsmon reports the last-seen data repeatedly on every single flush.
If multiple Appengine instances handles a task of computing aggregated views, the following problem would occur:
(hh:mm)
In the above scenario, there is no way to determine which stream tells the most fresh data. To avoid this issue, this module manually flushes the data with proper cleanup beforehand.