Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(287)

Unified Diff: infra_libs/ts_mon/common/metric_store.py

Issue 2109393002: Make test_net_info a bit more robust. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Add tests Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « infra/services/sysmon/test/system_metrics_test.py ('k') | infra_libs/ts_mon/common/metrics.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: infra_libs/ts_mon/common/metric_store.py
diff --git a/infra_libs/ts_mon/common/metric_store.py b/infra_libs/ts_mon/common/metric_store.py
index a555e3cb9a8bf9923d05d14c301e539a2d390b13..4d21feeabd964d1a1a1354f0f77bbab14eb355d9 100644
--- a/infra_libs/ts_mon/common/metric_store.py
+++ b/infra_libs/ts_mon/common/metric_store.py
@@ -4,6 +4,7 @@
import collections
import copy
+import itertools
import threading
import time
@@ -204,7 +205,8 @@ class TargetFieldsValues(object):
values = copy.copy(self._values)
for target_fields, fields_values in values.iteritems():
target = copy.copy(self._store._state.target)
- target.update({k: v for k, v in target_fields})
+ if target_fields:
+ target.update({k: v for k, v in target_fields})
yield target, fields_values
@@ -246,6 +248,10 @@ class InProcessMetricStore(MetricStore):
def get(self, name, fields, target_fields, default=None):
return self._entry(name).get_value(fields, target_fields, default)
+ def iter_field_values(self, name):
+ return itertools.chain.from_iterable(
+ x.iteritems() for _, x in self._entry(name).values.iter_targets())
+
def get_all(self):
# Make a copy of the metric values in case another thread (or this
# generator's consumer) modifies them while we're iterating.
« no previous file with comments | « infra/services/sysmon/test/system_metrics_test.py ('k') | infra_libs/ts_mon/common/metrics.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698