def collect(self): self.time_finish = datetime.now() domain_name = bottle.request.headers.get('X-Domain-Name', 'None') if domain_name.lower() == 'none': domain_name = 'default-domain' project_name = bottle.request.headers.get('X-Project-Name', 'None') if project_name.lower() == 'none': project_name = 'default-project' # Create api stats object self.api_stats = VncApiStats( object_type=self.obj_type, operation_type=bottle.request.method, user=bottle.request.headers.get('X-User-Name'), useragent=bottle.request.headers.get( 'X-Contrail-Useragent', bottle.request.headers.get('User-Agent')), remote_ip=bottle.request.headers.get('Host'), domain_name=domain_name, project_name=project_name, response_time_in_usec=(self.time_finish - self.time_start).total_seconds() * 1000000, response_size=self.response_size, response_code=self.response_code, )
def collect(self): self.time_finish = datetime.now() response_time = (self.time_finish - self.time_start) response_time_in_usec = ((response_time.days*24*60*60) + (response_time.seconds*1000000) + response_time.microseconds) domain_name = bottle.request.headers.get('X-Domain-Name', 'None') if domain_name.lower() == 'none': domain_name = 'default-domain' project_name = bottle.request.headers.get('X-Project-Name', 'None') if project_name.lower() == 'none': project_name = 'default-project' # Create api stats object self.api_stats = VncApiStats( object_type=self.obj_type, operation_type=bottle.request.method, req_id=bottle.request.headers.get('X-Request-Id', ''), user=bottle.request.headers.get('X-User-Name', ''), useragent=bottle.request.headers.get('X-Contrail-Useragent', bottle.request.headers.get('User-Agent')), remote_ip=bottle.request.remote_addr, domain_name=domain_name, project_name=project_name, response_time_in_usec=response_time_in_usec, response_size=self.response_size, resp_code=str(self.response_code), )