@handler.authenticated()
  @handler.asynchronous(datastore=True)
  @admin.require_permission(level='root')
  def get(self):
    """Responds to a single request for performance counter data.  Each request has two required
    parameters in the query string, 'start' and 'end', which specify the beginning and end of the
    time range to be queried.  The times should be expressed as the number of seconds since the
    unix epoch.
    """
    def _OnAggregation(aggregator):
      self.set_header('Content-Type', 'application/json; charset=UTF-8')
      self.write(json.dumps(aggregator, default=_SerializeAggregateMetrics))
      self.finish()

    start_time = float(self.get_argument('start'))
    end_time = float(self.get_argument('end'))

    # Select an appropriate interval resolution based on the requested time span.
    intervals = metric.METRIC_INTERVALS
    min_resolution = (end_time - start_time) / self.MAX_TICK_COUNT
    selected_interval = next((i for i in intervals if i.length > min_resolution), intervals[-1])
    group_key = metric.Metric.EncodeGroupKey(metric.DEFAULT_CLUSTER_NAME, selected_interval)
    logging.info('Query performance counters, range: %s - %s, resolution: %s'
                  % (time.ctime(start_time), time.ctime(end_time), selected_interval.name))

    metric.AggregatedMetric.CreateAggregateForTimespan(self._client, group_key, start_time, end_time,
                                                       counters.counters, _OnAggregation)
dataset/ETHPy150Open viewfinderco/viewfinder/backend/www/admin/counters.py/CountersDataHandler.get/original