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))
def load_full_proto(timestamp): """Load the full record for a given timestamp. Args: timestamp: The start_timestamp of the record, as a float in seconds (see make_key() for details). Returns: A RequestStatProto instance if the record exists and can be loaded; None otherwise. """ full_key = recording.make_key(timestamp) + recording.config.FULL_SUFFIX full_binary = memcache.get(full_key, namespace=recording.config.KEY_NAMESPACE) if full_binary is None: logging.info("No full record at %s", full_key) return None try: full = protobuf.decode_message(apphosting.RequestStatProto, full_binary) except Exception, err: logging.warn("Bad full record at %s: %s", full_key, err) return None
def load_full_proto(timestamp): """Load the full record for a given timestamp. Args: timestamp: The start_timestamp of the record, as a float in seconds (see make_key() for details). Returns: A RequestStatProto instance if the record exists and can be loaded; None otherwise. """ full_key = recording.make_key(timestamp) + recording.config.FULL_SUFFIX full_binary = memcache.get(full_key, namespace=recording.config.KEY_NAMESPACE) if full_binary is None: logging.info('No full record at %s', full_key) return None try: full = protobuf.decode_message(apphosting.RequestStatProto, full_binary) except Exception, err: logging.warn('Bad full record at %s: %s', full_key, err) return None