def _SerializeAggregateMetrics(obj):
 if isinstance(obj, metric.AggregatedMetric):
  return {'start_time': obj.start_time, 'end_time': obj.end_time, 'group_key': obj.group_key, 'machines': list(obj.machines), 'data': obj.counter_data}
 elif isinstance(obj, metric.AggregatedMetric.AggregatedCounter):
  logging.info(('description: %r' % obj.description))
  return {'description': obj.description, 'is_average': obj.is_average, 'machine_data': obj.machine_data, 'cluster_total': obj.cluster_total, 'cluster_avg': obj.cluster_avg}
 else:
  raise web.HTTPError(400, ('Expected instance of AggregatedMetric or AggregatedCounter, got %r' % obj))

def _SerializeAggregateMetrics ( obj ) : if isinstance ( obj , metric . AggregatedMetric ) : return { 'start_time' : obj . start_time , 'end_time' : obj . end_time , 'group_key' : obj . group_key , 'machines' : list ( obj . machines ) , 'data' : obj . counter_data } elif isinstance ( obj , metric . AggregatedMetric . AggregatedCounter ) : logging . info ( ( 'description: %r' % obj . description ) ) return { 'description' : obj . description , 'is_average' : obj . is_average , 'machine_data' : obj . machine_data , 'cluster_total' : obj . cluster_total , 'cluster_avg' : obj . cluster_avg } else : raise web . HTTPError ( 400 , ( 'Expected instance of AggregatedMetric or AggregatedCounter, got %r' % obj ) )
utility method to serialize aggregatemetric and aggregatedcounter objects to json .