Esempio n. 1
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))
Esempio n. 2
0
 def get(self):
   recording.dont_record()
   lineno = self.request.get('n')
   try:
     lineno = int(lineno)
   except:
     lineno = 0
   filename = self.request.get('f') or ''
   orig_filename = filename
   match = re.match('<path\[(\d+)\]>(.*)', filename)
   if match:
     index, tail = match.groups()
     index = int(index)
     if index < len(sys.path):
       filename = sys.path[index] + tail
   try:
     fp = open(filename)
   except IOError, err:
     self.response.out.write('<h1>IOError</h1><pre>%s</pre>' %
                             cgi.escape(str(err)))
     self.response.set_status(404)
Esempio n. 3
0
  def get(self):
    recording.dont_record()

    if not self.request.path.endswith('stats/'):
      self.redirect('stats/')
      return

    summaries = recording.load_summary_protos()

    allstats = {}
    pathstats = {}
    pivot_path_rpc = {}
    pivot_rpc_path = {}
    for index, summary in enumerate(summaries):
      path_key = recording.config.extract_key(summary)
      if path_key not in pathstats:
        pathstats[path_key] = [1, index+1]
      else:
        values = pathstats[path_key]
        values[0] += 1
        if len(values) >= 11:
          if values[-1]:
            values.append(0)
        else:
          values.append(index+1)
      if path_key not in pivot_path_rpc:
        pivot_path_rpc[path_key] = {}
      for x in summary.rpc_stats_list():
        rpc_key = x.service_call_name()
        value = x.total_amount_of_calls()
        if rpc_key in allstats:
          allstats[rpc_key] += value
        else:
          allstats[rpc_key] = value
        if rpc_key not in pivot_path_rpc[path_key]:
          pivot_path_rpc[path_key][rpc_key] = 0
        pivot_path_rpc[path_key][rpc_key] += value
        if rpc_key not in pivot_rpc_path:
          pivot_rpc_path[rpc_key] = {}
        if path_key not in pivot_rpc_path[rpc_key]:
          pivot_rpc_path[rpc_key][path_key] = 0
        pivot_rpc_path[rpc_key][path_key] += value

    allstats_by_count = []
    for k, v in allstats.iteritems():
      pivot = sorted(pivot_rpc_path[k].iteritems(),
                     key=lambda x: (-x[1], x[0]))
      allstats_by_count.append((k, v, pivot))
    allstats_by_count.sort(key=lambda x: (-x[1], x[0]))

    pathstats_by_count = []
    for path_key, values in pathstats.iteritems():
      pivot = sorted(pivot_path_rpc[path_key].iteritems(),
                     key=lambda x: (-x[1], x[0]))
      rpc_count = sum(x[1] for x in pivot)
      pathstats_by_count.append((path_key, rpc_count,
                                 values[0], values[1:], pivot))
    pathstats_by_count.sort(key=lambda x: (-x[1], -x[2], x[0]))

    data = {'requests': summaries,
            'allstats_by_count': allstats_by_count,
            'pathstats_by_count': pathstats_by_count,
            }
    self.response.out.write(render('main.html', data))