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

Side by Side Diff: infra_libs/ts_mon/common/metrics.py

Issue 1531573003: Handle multiple modifications to distribution metrics correctly. (Closed) Base URL: https://chromium.googlesource.com/infra/infra.git@master
Patch Set: Add a missing test for coverage Created 5 years 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 import operator 8 import operator
9 import threading 9 import threading
10 import time 10 import time
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 It might be easier to call ts_mon.reset_for_unittest() in your setUp() 186 It might be easier to call ts_mon.reset_for_unittest() in your setUp()
187 method instead of resetting every individual metric. 187 method instead of resetting every individual metric.
188 """ 188 """
189 189
190 interface.state.store.reset_for_unittest(self.name) 190 interface.state.store.reset_for_unittest(self.name)
191 191
192 def _set(self, fields, value, enforce_ge=False): 192 def _set(self, fields, value, enforce_ge=False):
193 interface.state.store.set(self.name, self._normalize_fields(fields), value, 193 interface.state.store.set(self.name, self._normalize_fields(fields), value,
194 enforce_ge=enforce_ge) 194 enforce_ge=enforce_ge)
195 195
196 def _incr(self, fields, delta, modify_fn=operator.add): 196 def _incr(self, fields, delta, modify_fn=None):
197 interface.state.store.incr(self.name, self._normalize_fields(fields), delta, 197 interface.state.store.incr(self.name, self._normalize_fields(fields), delta,
198 modify_fn=modify_fn) 198 modify_fn=modify_fn)
199 199
200 200
201 class StringMetric(Metric): 201 class StringMetric(Metric):
202 """A metric whose value type is a string.""" 202 """A metric whose value type is a string."""
203 203
204 def _populate_value(self, metric, value, start_time): 204 def _populate_value(self, metric, value, start_time):
205 metric.string_value = value 205 metric.string_value = value
206 206
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
418 """A DistributionMetric with is_cumulative set to False.""" 418 """A DistributionMetric with is_cumulative set to False."""
419 419
420 def __init__(self, name, bucketer=None, fields=None, 420 def __init__(self, name, bucketer=None, fields=None,
421 description=None): 421 description=None):
422 super(NonCumulativeDistributionMetric, self).__init__( 422 super(NonCumulativeDistributionMetric, self).__init__(
423 name, 423 name,
424 is_cumulative=False, 424 is_cumulative=False,
425 bucketer=bucketer, 425 bucketer=bucketer,
426 fields=fields, 426 fields=fields,
427 description=description) 427 description=description)
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