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

Unified Diff: client/third_party/infra_libs/ts_mon/common/interface.py

Issue 2708113002: Revert of Add field_specs to all metrics in luci-py (Closed)
Patch Set: Created 3 years, 10 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
Index: client/third_party/infra_libs/ts_mon/common/interface.py
diff --git a/client/third_party/infra_libs/ts_mon/common/interface.py b/client/third_party/infra_libs/ts_mon/common/interface.py
index 8091490fc7ed161910e41a890c2fc37d151e6b89..6f10c408deeb1bb0a93f9000fb5af16b68deb431 100644
--- a/client/third_party/infra_libs/ts_mon/common/interface.py
+++ b/client/third_party/infra_libs/ts_mon/common/interface.py
@@ -123,6 +123,7 @@
data_sets = {}
count = 0
+ error_count = 0
for (target, metric, start_time, end_time, fields_values
) in state.store.get_all():
for fields, value in fields_values.iteritems():
@@ -140,12 +141,17 @@
key = (target, metric.name)
new_data_set = None
- if key not in data_sets:
- new_data_set = new_metrics_pb2.MetricsDataSet()
- metric._populate_data_set(new_data_set)
-
- data = new_metrics_pb2.MetricsData()
- metric._populate_data(data, start_time, end_time, fields, value)
+ try:
+ if key not in data_sets:
+ new_data_set = new_metrics_pb2.MetricsDataSet()
+ metric._populate_data_set(new_data_set, fields)
+
+ data = new_metrics_pb2.MetricsData()
+ metric._populate_data(data, start_time, end_time, fields, value)
+ except errors.MonitoringError:
+ logging.exception('Failed to serialize a metric.')
+ error_count += 1
+ continue
# All required data protos have been successfully populated. Now we can
# insert them in serialized proto and bookeeping data structures.
@@ -158,24 +164,36 @@
if count > 0:
yield proto
+ if error_count:
+ raise errors.MonitoringFailedToFlushAllMetricsError(error_count)
+
def _generate_proto():
"""Generate MetricsCollection for global_monitor.send()."""
proto = metrics_pb2.MetricsCollection()
+ error_count = 0
for target, metric, start_time, _, fields_values in state.store.get_all():
for fields, value in fields_values.iteritems():
if len(proto.data) >= METRICS_DATA_LENGTH_LIMIT:
yield proto
proto = metrics_pb2.MetricsCollection()
- metrics_pb = metrics_pb2.MetricsData()
- metric.serialize_to(metrics_pb, start_time, fields, value, target)
+ try:
+ metrics_pb = metrics_pb2.MetricsData()
+ metric.serialize_to(metrics_pb, start_time, fields, value, target)
+ except errors.MonitoringError:
+ error_count += 1
+ logging.exception('Failed to serialize a metric.')
+ continue
proto.data.add().CopyFrom(metrics_pb)
if len(proto.data) > 0:
yield proto
+
+ if error_count:
+ raise errors.MonitoringFailedToFlushAllMetricsError(error_count)
def register(metric):
« no previous file with comments | « client/third_party/infra_libs/ts_mon/common/http_metrics.py ('k') | client/third_party/infra_libs/ts_mon/common/metrics.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698