code: def view_data_to_metric(view_data, timestamp):
      
      if not view_data.tag_value_aggregation_data_map:
          return None
  
      md = view_data.view.get_metric_descriptor()
  
      # TODO: implement gauges
      if is_gauge(md.type):
          ts_start = None  # pragma: NO COVER
      else:
          ts_start = view_data.start_time
  
      ts_list = []
      for tag_vals, agg_data in view_data.tag_value_aggregation_data_map.items():
          label_values = get_label_values(tag_vals)
          point = agg_data.to_point(timestamp)
          ts_list.append(time_series.TimeSeries(label_values, [point], ts_start))
      return metric.Metric(md, ts_list)
docs: Convert a ViewData to a Metric at time `timestamp`.
  
      :type view_data: :class: `opencensus.stats.view_data.ViewData`
      :param view_data: The ViewData to convert.
  
      :type timestamp: :class: `datetime.datetime`
      :param timestamp: The time to set on the metric's point's aggregation,
      usually the current time.
  
      :rtype: :class: `opencensus.metrics.export.metric.Metric`
      :return: A converted Metric.