diff --git a/moesifdjango/middleware.py b/moesifdjango/middleware.py index 3ccf9f1..eb2c4ae 100644 --- a/moesifdjango/middleware.py +++ b/moesifdjango/middleware.py @@ -51,7 +51,7 @@ def __init__(self, get_response): # below comment for setting moesif base_uri to a test server. if self.middleware_settings.get('LOCAL_DEBUG', False): Configuration.BASE_URI = self.get_configuration_uri(self.middleware_settings, 'BASE_URI', 'LOCAL_MOESIF_BASEURL') - Configuration.version = 'moesifdjango-python/2.1.5' + Configuration.version = 'moesifdjango-python/2.2.0' if settings.MOESIF_MIDDLEWARE.get('CAPTURE_OUTGOING_REQUESTS', False): try: if self.DEBUG: @@ -170,11 +170,13 @@ def __call__(self, request): # Code to be executed for each request before # the view (and later middleware) are called. - # Initialize Transaction Id - transaction_id = None - # Request Time req_time = datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S.%f")[:-3] + if self.DEBUG: + print("event request time: ", req_time) + + # Initialize Transaction Id + transaction_id = None try: request._mo_body = request.body @@ -190,6 +192,11 @@ def __call__(self, request): # Code to be executed for each request/response after # the view is called. + # Response Time + rsp_time = datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S.%f")[:-3] + if self.DEBUG: + print("event response time: ", rsp_time) + # Check if need to skip logging event skip_event_response = self.logger_helper.skip_event(request, response, self.middleware_settings, self.DEBUG) if skip_event_response: @@ -224,8 +231,6 @@ def __call__(self, request): # Prepare Response Body rsp_body, rsp_body_transfer_encoding = self.logger_helper.prepare_response_body(response, rsp_headers, self.LOG_BODY, self.middleware_settings) - # Response Time - rsp_time = datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S.%f")[:-3] # Prepare Event Request Model event_req = self.event_mapper.to_request(req_time, uri,request.method, self.api_version, ip_address, diff --git a/moesifdjango/middleware_pre19.py b/moesifdjango/middleware_pre19.py index fde69d9..85f91f0 100644 --- a/moesifdjango/middleware_pre19.py +++ b/moesifdjango/middleware_pre19.py @@ -45,7 +45,7 @@ def __init__(self): # below comment for setting moesif base_uri to a test server. if self.middleware_settings.get('LOCAL_DEBUG', False): Configuration.BASE_URI = self.get_configuration_uri(self.middleware_settings, 'BASE_URI', 'LOCAL_MOESIF_BASEURL') - Configuration.version = 'moesifdjango-python/2.1.5' + Configuration.version = 'moesifdjango-python/2.2.0' if settings.MOESIF_MIDDLEWARE.get('CAPTURE_OUTGOING_REQUESTS', False): try: if self.DEBUG: @@ -156,7 +156,10 @@ def process_response(self, request, response): # Code to be executed for each request before # the view (and later middleware) are called. + # Request time req_time = request.moesif_req_time + if self.DEBUG: + print("event request time: ", req_time) if self.DEBUG: print("raw body before getting response") @@ -164,6 +167,10 @@ def process_response(self, request, response): # response = get_response(request) # Code to be executed for each request/response after # the view is called. + # Response Time + rsp_time = datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S.%f")[:-3] + if self.DEBUG: + print("event response time: ", rsp_time) # Check if need to skip logging event skip_event_response = self.logger_helper.skip_event(request, response, self.middleware_settings, self.DEBUG) @@ -201,9 +208,6 @@ def process_response(self, request, response): self.LOG_BODY, self.middleware_settings) - # Response Time - rsp_time = datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S.%f")[:-3] - # Prepare Event Request Model event_req = self.event_mapper.to_request(req_time, uri, request.method, self.api_version, ip_address, req_headers, req_body, req_body_transfer_encoding) diff --git a/setup.py b/setup.py index e39846f..2bc2144 100644 --- a/setup.py +++ b/setup.py @@ -28,7 +28,7 @@ # Versions should comply with PEP440. For a discussion on single-sourcing # the version across setup.py and the project code, see # https://packaging.python.org/en/latest/single_source_version.html - version='2.1.6', + version='2.2.0', description='Moesif Middleware for Python Django', long_description=long_description,