Esempio n. 1
0
 def get_summary_proto(self):
   """Return a protobuf representing a summary of this recorder."""
   summary = datamodel_pb.RequestStatProto()
   summary.set_start_timestamp_milliseconds(int(self.start_timestamp * 1000))
   method = self.http_method()
   if method != 'GET':
     summary.set_http_method(method)
   path = self.http_path()
   if path != '/':
     summary.set_http_path(path)
   query = self.http_query()
   if query:
     summary.set_http_query(query)
   status = int(self.http_status)
   if status != 200:
     summary.set_http_status(status)
   duration = int(1000 * (self.end_timestamp - self.start_timestamp))
   summary.set_duration_milliseconds(duration)
   api_mcycles = self.get_total_api_mcycles()
   if api_mcycles:
     summary.set_api_mcycles(api_mcycles)
   summary.set_processor_mcycles(quota.get_request_cpu_usage())
   summary.set_overhead_walltime_milliseconds(int(self.overhead * 1000))
   rpc_stats = self.get_rpcstats().items()
   rpc_stats.sort(key=lambda x: (-x[1], x[0]))
   for key, value in rpc_stats:
     x = summary.add_rpc_stats()
     x.set_service_call_name(key)
     x.set_total_amount_of_calls(value)
   return summary
Esempio n. 2
0
 def get_summary_proto(self):
   """Return a protobuf representing a summary of this recorder."""
   summary = datamodel_pb.RequestStatProto()
   summary.set_start_timestamp_milliseconds(int(self.start_timestamp * 1000))
   method = self.http_method()
   if method != 'GET':
     summary.set_http_method(method)
   path = self.http_path()
   if path != '/':
     summary.set_http_path(path)
   query = self.http_query()
   if query:
     summary.set_http_query(query)
   status = int(self.http_status)
   if status != 200:
     summary.set_http_status(status)
   duration = int(1000 * (self.end_timestamp - self.start_timestamp))
   summary.set_duration_milliseconds(duration)
   summary.set_overhead_walltime_milliseconds(int(self.overhead * 1000))
   rpc_stats = self.get_rpcstats().items()
   rpc_stats.sort(key=lambda x: (-x[1][0], x[0]))
   for key, value in rpc_stats:
     x = summary.add_rpc_stats()
     x.set_service_call_name(key)
     x.set_total_amount_of_calls(value[0])
     x.set_total_cost_of_calls_microdollars(value[1])
     for billed_op in value[2].itervalues():
       x.total_billed_ops_list().append(billed_op)
   return summary
Esempio n. 3
0
  def __init__(self, *args, **kwds):
    self._proto = datamodel_pb.RequestStatProto(*args, **kwds)


    for r in self.individual_stats_list():
      if not r.has_api_milliseconds():
        r.set_api_milliseconds(mcycles_to_msecs(r.api_mcycles()))
Esempio n. 4
0
def UnpickleFromFile(datafile):
    """Reads appstats data from file.

  Args:
    datafile: file object to read appstats data from.  File format is a
      pickled list of protobufs encoded as binary strings.

  Returns:
    List of RequestStatProto protobufs.
  """
    encoded_records = pickle.load(datafile)
    records = []
    for encoded_record in encoded_records:
        record = datamodel_pb.RequestStatProto(encoded_record)
        records.append(record)
        datafile.close()
    return records
Esempio n. 5
0
 def __init__(self, proto=None):
   if not isinstance(proto, datamodel_pb.RequestStatProto):
     proto = datamodel_pb.RequestStatProto(proto)
   self._proto = proto