Exemplo n.º 1
0
  def get(self):
    recording.dont_record()


    time_key = self.request.get('time')
    key = str(self.request.get('key'))
    timestamp = None
    record = None
    if time_key:
      try:
        timestamp = int(time_key) * 0.001
      except Exception:
        pass
    if timestamp:
      record = recording.load_full_proto(recording.make_key(timestamp))
    elif key:
        record = recording.load_full_proto(key)

    if record is None:
      self.response.set_status(404)

      self.response.out.write(render('details.html', {}))
      return


    rpcstats_map = {}
    for rpc_stat in record.individual_stats_list():
      key = rpc_stat.service_call_name()
      count, real, api = rpcstats_map.get(key, (0, 0, 0))
      count += 1
      real += rpc_stat.duration_milliseconds()
      api += rpc_stat.api_mcycles()
      rpcstats_map[key] = (count, real, api)
    rpcstats_by_count = [
        (name, count, real, recording.mcycles_to_msecs(api))
        for name, (count, real, api) in rpcstats_map.iteritems()]
    rpcstats_by_count.sort(key=lambda x: -x[1])


    real_total = 0
    api_total_mcycles = 0
    for i, rpc_stat in enumerate(record.individual_stats_list()):
      real_total += rpc_stat.duration_milliseconds()
      api_total_mcycles += rpc_stat.api_mcycles()

    api_total = recording.mcycles_to_msecs(api_total_mcycles)
    charged_total = recording.mcycles_to_msecs(record.processor_mcycles() +
                                               api_total_mcycles)

    data = {'sys': sys,
            'record': record,
            'rpcstats_by_count': rpcstats_by_count,
            'real_total': real_total,
            'api_total': api_total,
            'charged_total': charged_total,
            'file_url': './file',
            'deadlines': [(0,'#77ff77'), (300,'#ECF000'), (1000,'#DB4900')]
            }
    self.response.out.write(render('details.html', data))
Exemplo n.º 2
0
  def get(self):
    recording.dont_record()


    time_key = self.request.get('time')
    timestamp = None
    record = None
    if time_key:
      try:
        timestamp = int(time_key) * 0.001
      except Exception:
        pass
    if timestamp:
      record = recording.load_full_proto(timestamp)


    if record is None:
      self.response.set_status(404)

      self.response.out.write(render('details.html', {}))
      return


    rpcstats_map = {}
    for rpc_stat in record.individual_stats_list():
      key = rpc_stat.service_call_name()
      count, real, api = rpcstats_map.get(key, (0, 0, 0))
      count += 1
      real += rpc_stat.duration_milliseconds()
      api += rpc_stat.api_mcycles()
      rpcstats_map[key] = (count, real, api)
    rpcstats_by_count = [
        (name, count, real, recording.mcycles_to_msecs(api))
        for name, (count, real, api) in rpcstats_map.iteritems()]
    rpcstats_by_count.sort(key=lambda x: -x[1])


    real_total = 0
    api_total_mcycles = 0
    for i, rpc_stat in enumerate(record.individual_stats_list()):
      real_total += rpc_stat.duration_milliseconds()
      api_total_mcycles += rpc_stat.api_mcycles()

    api_total = recording.mcycles_to_msecs(api_total_mcycles)
    charged_total = recording.mcycles_to_msecs(record.processor_mcycles() +
                                               api_total_mcycles)

    data = {'sys': sys,
            'record': record,
            'rpcstats_by_count': rpcstats_by_count,
            'real_total': real_total,
            'api_total': api_total,
            'charged_total': charged_total,
            'file_url': './file',
            }
    self.response.out.write(render('details.html', data))
Exemplo n.º 3
0
    def get(self):
        recording.dont_record()

        time_key = self.request.get('time')
        timestamp = None
        record = None
        if time_key:
            try:
                timestamp = int(time_key) * 0.001
            except Exception:
                pass
        if timestamp:
            record = recording.load_full_proto(timestamp)
        render_record(self.response, record, './file')
Exemplo n.º 4
0
  def get(self):
    recording.dont_record()


    time_key = self.request.get('time')
    timestamp = None
    record = None
    if time_key:
      try:
        timestamp = int(time_key) * 0.001
      except Exception:
        pass
    if timestamp:
      record = recording.load_full_proto(timestamp)
    render_record(self.response, record, './file')
Exemplo n.º 5
0
def FromMemcache(filter_timestamp=0, java_application=False):
  """Reads appstats data from memcache.

  Get all appstats full records from memcache which
  correspond to requests with a greater timestamp
  than filter_timestamp

  Args:
    filter_timestamp: only retrieve records with timestamp
      (in milliseconds) higher than this value. If 0, all
      records are retrieved.
    java_application: Boolean. If true, this function is being
      called by the download_appstats tool for a Java
      application.

  Returns:
    List of RequestStatProto protobufs.
  """
  records = []
  logging.info('Loading appstats summaries...')
  summaries = recording.load_summary_protos(java_application)
  logging.info('Loaded %d summaries. Loading full records...',
               len(summaries))
  start_time = time.time()
  missing_full_records = 0
  failed_requests = 0
  for count, summary in enumerate(summaries):
    time_key = summary.start_timestamp_milliseconds()
    if time_key <= filter_timestamp:




      logging.info('Only %d records with newer timestamp.'
                   ' Skipping rest.', count)
      break
    timestamp = int(time_key) * 0.001
    record = recording.load_full_proto(timestamp, java_application)
    if not record:
      missing_full_records += 1
      continue
    httpstatus = int(record.http_status())
    if httpstatus >= 400:
      failed_requests += 1
      continue
    records.append(record)
    if len(records) % 10 == 0:
      logging.info('Download in progress..completed %d..', len(records))
  if not records:
    logging.info('No full records present in memcache for succesful requests.')
  else:
    end_time = time.time()
    elapsed = max(end_time - start_time, 0)
    time_per_record = elapsed/len(records)
    logging.info('Done. %d full records downloaded in %.2f secs '
                 '[%.2f secs per full record]',
                 len(records), elapsed, time_per_record)
    if missing_full_records:
      logging.info('Skipped %d summaries with missing full records',
                   missing_full_records)
    if failed_requests:
      logging.info('Skipped %d summaries corresponding to failed requests',
                   failed_requests)
  return records
Exemplo n.º 6
0
def load_full_proto_from_timestamp(timestamp):
  """Fetch a full detail AppStats from a summary proto timestamp."""
  timestamp = int(timestamp) * 0.001
  return recording.load_full_proto(timestamp)
Exemplo n.º 7
0
def FromMemcache(filter_timestamp=0, java_application=False):
    """Reads appstats data from memcache.

  Get all appstats full records from memcache which
  correspond to requests with a greater timestamp
  than filter_timestamp

  Args:
    filter_timestamp: only retrieve records with timestamp
      (in milliseconds) higher than this value. If 0, all
      records are retrieved.
    java_application: Boolean. If true, this function is being
      called by the download_appstats tool for a Java
      application.

  Returns:
    List of RequestStatProto protobufs.
  """
    records = []
    logging.info('Loading appstats summaries...')
    summaries = recording.load_summary_protos(java_application)
    logging.info('Loaded %d summaries. Loading full records...',
                 len(summaries))
    start_time = time.time()
    missing_full_records = 0
    failed_requests = 0
    for count, summary in enumerate(summaries):
        time_key = summary.start_timestamp_milliseconds()
        if time_key <= filter_timestamp:

            logging.info(
                'Only %d records with newer timestamp.'
                ' Skipping rest.', count)
            break
        timestamp = int(time_key) * 0.001
        record = recording.load_full_proto(timestamp, java_application)
        if not record:
            missing_full_records += 1
            continue
        httpstatus = int(record.http_status())
        if httpstatus >= 400:
            failed_requests += 1
            continue
        records.append(record)
        if len(records) % 10 == 0:
            logging.info('Download in progress..completed %d..', len(records))
    if not records:
        logging.info(
            'No full records present in memcache for succesful requests.')
    else:
        end_time = time.time()
        elapsed = max(end_time - start_time, 0)
        time_per_record = elapsed / len(records)
        logging.info(
            'Done. %d full records downloaded in %.2f secs '
            '[%.2f secs per full record]', len(records), elapsed,
            time_per_record)
        if missing_full_records:
            logging.info('Skipped %d summaries with missing full records',
                         missing_full_records)
        if failed_requests:
            logging.info(
                'Skipped %d summaries corresponding to failed requests',
                failed_requests)
    return records
Exemplo n.º 8
0
def load_full_proto_from_timestamp(timestamp):
    """Fetch a full detail AppStats from a summary proto timestamp."""
    timestamp = int(timestamp) * 0.001
    return recording.load_full_proto(timestamp)