OLD | NEW |
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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 description (string): help string for the metric. Should be enough to | 56 description (string): help string for the metric. Should be enough to |
57 know what the metric is about. | 57 know what the metric is about. |
58 """ | 58 """ |
59 self._name = name.lstrip('/') | 59 self._name = name.lstrip('/') |
60 self._start_time = None | 60 self._start_time = None |
61 fields = fields or {} | 61 fields = fields or {} |
62 if len(fields) > 7: | 62 if len(fields) > 7: |
63 raise errors.MonitoringTooManyFieldsError(self._name, fields) | 63 raise errors.MonitoringTooManyFieldsError(self._name, fields) |
64 self._fields = fields | 64 self._fields = fields |
65 self._normalized_fields = self._normalize_fields(self._fields) | 65 self._normalized_fields = self._normalize_fields(self._fields) |
66 # pgervais: Yes, description is unused. Waiting for the rest of the pipeline | |
67 # to support it. | |
68 self._description = description | 66 self._description = description |
69 | 67 |
70 interface.register(self) | 68 interface.register(self) |
71 | 69 |
72 @property | 70 @property |
73 def name(self): | 71 def name(self): |
74 return self._name | 72 return self._name |
75 | 73 |
76 @property | 74 @property |
77 def start_time(self): | 75 def start_time(self): |
(...skipping 16 matching lines...) Expand all Loading... |
94 Args: | 92 Args: |
95 collection_pb (metrics_pb2.MetricsCollection): protocol buffer into which | 93 collection_pb (metrics_pb2.MetricsCollection): protocol buffer into which |
96 to add the current metric values. | 94 to add the current metric values. |
97 start_time (int): timestamp in microseconds since UNIX epoch. | 95 start_time (int): timestamp in microseconds since UNIX epoch. |
98 target (Target): a Target to use. | 96 target (Target): a Target to use. |
99 """ | 97 """ |
100 | 98 |
101 metric_pb = collection_pb.data.add() | 99 metric_pb = collection_pb.data.add() |
102 metric_pb.metric_name_prefix = '/chrome/infra/' | 100 metric_pb.metric_name_prefix = '/chrome/infra/' |
103 metric_pb.name = self._name | 101 metric_pb.name = self._name |
| 102 if self._description is not None: |
| 103 metric_pb.description = self._description |
104 | 104 |
105 self._populate_value(metric_pb, value, start_time) | 105 self._populate_value(metric_pb, value, start_time) |
106 self._populate_fields(metric_pb, fields) | 106 self._populate_fields(metric_pb, fields) |
107 | 107 |
108 target._populate_target_pb(metric_pb) | 108 target._populate_target_pb(metric_pb) |
109 | 109 |
110 def _populate_fields(self, metric, fields): | 110 def _populate_fields(self, metric, fields): |
111 """Fill in the fields attribute of a metric protocol buffer. | 111 """Fill in the fields attribute of a metric protocol buffer. |
112 | 112 |
113 Args: | 113 Args: |
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
453 description=None): | 453 description=None): |
454 super(NonCumulativeDistributionMetric, self).__init__( | 454 super(NonCumulativeDistributionMetric, self).__init__( |
455 name, | 455 name, |
456 is_cumulative=False, | 456 is_cumulative=False, |
457 bucketer=bucketer, | 457 bucketer=bucketer, |
458 fields=fields, | 458 fields=fields, |
459 description=description) | 459 description=description) |
460 | 460 |
461 def is_cumulative(self): | 461 def is_cumulative(self): |
462 return False | 462 return False |
OLD | NEW |