def extract_metric_result_map_value(monitoring_info_proto): """Returns the relevant GaugeResult, DistributionResult or int value. These are the proper format for use in the MetricResult.query() result. """ # Returns a metric result (AKA the legacy format). # from the MonitoringInfo if is_counter(monitoring_info_proto): return extract_counter_value(monitoring_info_proto) if is_distribution(monitoring_info_proto): (count, sum, min, max) = extract_distribution(monitoring_info_proto) return DistributionResult(DistributionData(sum, count, min, max)) if is_gauge(monitoring_info_proto): (timestamp, value) = extract_gauge_value(monitoring_info_proto) return GaugeResult(GaugeData(value, timestamp))
def extract_metric_result_map_value(monitoring_info_proto): """Returns the relevant GaugeResult, DistributionResult or int value. These are the proper format for use in the MetricResult.query() result. """ # Returns a metric result (AKA the legacy format). # from the MonitoringInfo if is_counter(monitoring_info_proto): return extract_counter_value(monitoring_info_proto) if is_distribution(monitoring_info_proto): distribution_data = extract_distribution(monitoring_info_proto) return DistributionResult( DistributionData(distribution_data.sum, distribution_data.count, distribution_data.min, distribution_data.max)) if is_gauge(monitoring_info_proto): timestamp_secs = to_timestamp_secs(monitoring_info_proto.timestamp) return GaugeResult(GaugeData( extract_counter_value(monitoring_info_proto), timestamp_secs))