Пример #1
0
def translate_distribution(distribution_update, metric_update_proto):
    """Translate metrics DistributionUpdate to dataflow distribution update."""
    dist_update_proto = dataflow.DistributionUpdate()
    dist_update_proto.min = to_split_int(distribution_update.min)
    dist_update_proto.max = to_split_int(distribution_update.max)
    dist_update_proto.count = to_split_int(distribution_update.count)
    dist_update_proto.sum = to_split_int(distribution_update.sum)
    metric_update_proto.distribution = dist_update_proto
Пример #2
0
def translate_distribution(distribution_update, metric_update_proto):
    """Translate metrics DistributionUpdate to dataflow distribution update.

  Args:
    distribution_update: Instance of DistributionData or
    DataflowDistributionCounter.
    metric_update_proto: Used for report metrics.
  """
    dist_update_proto = dataflow.DistributionUpdate()
    dist_update_proto.min = to_split_int(distribution_update.min)
    dist_update_proto.max = to_split_int(distribution_update.max)
    dist_update_proto.count = to_split_int(distribution_update.count)
    dist_update_proto.sum = to_split_int(distribution_update.sum)
    # DatadflowDistributionCounter needs to translate histogram
    if isinstance(distribution_update, DataflowDistributionCounter):
        dist_update_proto.histogram = dataflow.Histogram()
        distribution_update.translate_to_histogram(dist_update_proto.histogram)
    metric_update_proto.distribution = dist_update_proto