예제 #1
0
 def get(self, id=None):
     items = []
     queue_items = yield gen.Task(self.application.work_queue.items)
     for item in sorted(queue_items, key=self._key):
         items.append({
             'host'  : item[0],
             'count' : item[1],
             'total' : item[2],
             'ave_resp' : float("%.2f" % systemMetrics.ave('response:%s' % item[0])),
         })
     self.finish(json.dumps(items))
예제 #2
0
 def get(self):
     metrics = {}
     for k, v in systemMetrics.items():
         if not k.startswith("pipeline:"):
             continue
         _, step, kind = k.split(':')
         if step not in metrics:
             metrics[step] = {}
         if kind == 'calls':
             metrics[step]['calls']  = systemMetrics.value(k)
         elif kind == 'time':
             metrics[step]['median'] = int(systemMetrics.median(k) * 1000)
             metrics[step]['ave']    = int(systemMetrics.ave(k) * 1000)
     if not metrics:
         return self.finish(json.dumps([]))
     else:
         return self.finish(json.dumps( [dict([('id',k)]+list(v.items())) for k, v in metrics.items()] ))