예제 #1
0
    def get(self):
        """ Handles get request for the web server. Returns that it is currently
    up in JSON. """
        cursor = self.get_argument("cursor", None)
        last_milliseconds = self.get_argument("last_milliseconds", None)
        try:
            if cursor:
                recent_stats = service_stats.scroll_recent(int(cursor))
            elif last_milliseconds:
                recent_stats = service_stats.get_recent(int(last_milliseconds))
            else:
                recent_stats = service_stats.get_recent()
        except ValueError:
            self.set_status(
                400, "cursor and last_milliseconds "
                "arguments should be integers")
            return

        with (yield stats_lock.acquire()):
            cumulative_counters = service_stats.get_cumulative_counters()

        tq_stats = {
            "current_requests": service_stats.current_requests,
            "cumulative_counters": cumulative_counters,
            "recent_stats": recent_stats
        }
        self.write(json.dumps(tq_stats))
예제 #2
0
  def get(self):
    """ Handles get request for the web server. Returns that it is currently
    up in JSON. """
    cursor = self.get_argument("cursor", None)
    last_milliseconds = self.get_argument("last_milliseconds", None)
    try:
      if cursor:
        recent_stats = service_stats.scroll_recent(int(cursor))
      elif last_milliseconds:
        recent_stats = service_stats.get_recent(int(last_milliseconds))
      else:
        recent_stats = service_stats.get_recent()
    except ValueError:
      self.set_status(400, "cursor and last_milliseconds "
                           "arguments should be integers")
      return

    with (yield stats_lock.acquire()):
      cumulative_counters = service_stats.get_cumulative_counters()

    tq_stats = {
      "current_requests": service_stats.current_requests,
      "cumulative_counters": cumulative_counters,
      "recent_stats": recent_stats
    }
    self.write(json.dumps(tq_stats))