metrics: Add function to collect repeated metrics.

Bug: 897394
Change-Id: Iece4507c7bf92d7a8aad045d31b4f06e54b3af15
Reviewed-on: https://chromium-review.googlesource.com/c/1292243
Reviewed-by: Andrii Shyshkalov <tandrii@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
This commit is contained in:
Edward Lemur
2018-10-22 19:15:13 +00:00
committed by Commit Bot
parent 98f1e59b41
commit 149834e67d
2 changed files with 22 additions and 0 deletions

View File

@@ -161,6 +161,11 @@ class MetricsCollector(object):
with self._metrics_lock:
self._reported_metrics[name] = value
def add_repeated(self, name, value):
if self._collect_custom_metrics:
with self._metrics_lock:
self._reported_metrics.setdefault(name, []).append(value)
@contextlib.contextmanager
def pause_metrics_collection(self):
collect_custom_metrics = self._collect_custom_metrics