gclient: Start reporting metrics.

Bug: 832386
Change-Id: I6d1167802f077bcd67bf004ccc417661d8fff3c7
Reviewed-on: https://chromium-review.googlesource.com/1135903
Reviewed-by: Aaron Gable <agable@chromium.org>
Commit-Queue: Edward Lesmes <ehmaldonado@chromium.org>
This commit is contained in:
Edward Lemur
2018-07-17 18:21:27 +00:00
committed by Commit Bot
parent 40bacee96a
commit 3298e7b592
3 changed files with 45 additions and 2 deletions

View File

@@ -108,12 +108,19 @@ class MetricsCollector(object):
self._metrics_lock = threading.Lock()
self._reported_metrics = {}
self._config = _Config()
self._collecting_metrics = False
@property
def config(self):
return self._config
@property
def collecting_metrics(self):
return self._collecting_metrics
def add(self, name, value):
if not self.collecting_metrics:
return
with self._metrics_lock:
self._reported_metrics[name] = value
@@ -187,6 +194,7 @@ class MetricsCollector(object):
@functools.wraps(func)
def _inner(*args, **kwargs):
self._collect_metrics(func, command_name, *args, **kwargs)
self._collecting_metrics = True
return _inner
return _decorator