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

Side by Side Diff: infra_libs/ts_mon/common/metrics.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, 5 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 unified diff | Download patch
OLDNEW
1 # Copyright 2015 The Chromium Authors. All rights reserved. 1 # Copyright 2015 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Classes representing individual metrics that can be sent.""" 5 """Classes representing individual metrics that can be sent."""
6 6
7 import copy 7 import copy
8 8
9 from infra_libs.ts_mon.protos import metrics_pb2 9 from infra_libs.ts_mon.protos import metrics_pb2
10 10
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 178
179 def get(self, fields=None, target_fields=None): 179 def get(self, fields=None, target_fields=None):
180 """Returns the current value for this metric. 180 """Returns the current value for this metric.
181 181
182 Subclasses should never use this to get a value, modify it and set it again. 182 Subclasses should never use this to get a value, modify it and set it again.
183 Instead use _incr with a modify_fn. 183 Instead use _incr with a modify_fn.
184 """ 184 """
185 return interface.state.store.get( 185 return interface.state.store.get(
186 self.name, self._normalize_fields(fields), target_fields) 186 self.name, self._normalize_fields(fields), target_fields)
187 187
188 def get_all(self):
189 return interface.state.store.iter_field_values(self.name)
190
188 def reset(self): 191 def reset(self):
189 """Clears the values of this metric. Useful in unit tests. 192 """Clears the values of this metric. Useful in unit tests.
190 193
191 It might be easier to call ts_mon.reset_for_unittest() in your setUp() 194 It might be easier to call ts_mon.reset_for_unittest() in your setUp()
192 method instead of resetting every individual metric. 195 method instead of resetting every individual metric.
193 """ 196 """
194 197
195 interface.state.store.reset_for_unittest(self.name) 198 interface.state.store.reset_for_unittest(self.name)
196 199
197 def _set(self, fields, target_fields, value, enforce_ge=False): 200 def _set(self, fields, target_fields, value, enforce_ge=False):
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 description=None): 454 description=None):
452 super(NonCumulativeDistributionMetric, self).__init__( 455 super(NonCumulativeDistributionMetric, self).__init__(
453 name, 456 name,
454 is_cumulative=False, 457 is_cumulative=False,
455 bucketer=bucketer, 458 bucketer=bucketer,
456 fields=fields, 459 fields=fields,
457 description=description) 460 description=description)
458 461
459 def is_cumulative(self): 462 def is_cumulative(self):
460 return False 463 return False
OLDNEW
« no previous file with comments | « infra_libs/ts_mon/common/metric_store.py ('k') | infra_libs/ts_mon/common/test/metric_store_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698