Skip to content

Commit

Permalink
Check the request time against the current time after sending a batch (
Browse files Browse the repository at this point in the history
…#78)

* Check the request time against the current time after sending a batch and log in debug mode

* v2.3.3

* Fix string DateTime and log info
  • Loading branch information
bakennedy authored Jul 12, 2023
1 parent 0777605 commit ae97674
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions moesifdjango/job_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def fetch_app_config(self, config, config_etag, sampling_percentage, last_update


def batch_events(self, api_client, moesif_events_queue, debug, batch_size):

print("Starting batch events job")
batch_events = []
try:
while not moesif_events_queue.empty():
Expand All @@ -58,10 +58,16 @@ def batch_events(self, api_client, moesif_events_queue, debug, batch_size):
break

if batch_events:
req_time = batch_events[0].request.time
req_time = datetime.strptime(req_time, '%Y-%m-%dT%H:%M:%S.%f')
batch_response_config_etag, batch_response_rules_etag = self.send_events(api_client, batch_events, debug)
batch_events[:] = []
# Set the last time event job ran after sending events
return batch_response_config_etag, batch_response_rules_etag, datetime.utcnow()
batch_send_time = datetime.utcnow()
delta = batch_send_time - req_time
if debug and delta.total_seconds() > 0:
print("Warning: It took %s seconds to send events to Moesif. req.time=%s now=%s"%(delta.total_seconds(), req_time, batch_send_time))
return batch_response_config_etag, batch_response_rules_etag, batch_send_time
else:
if debug:
print("No events to send")
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.3.2',
version='2.3.3',

description='Moesif Middleware for Python Django',
long_description=long_description,
Expand Down

0 comments on commit ae97674

Please sign in to comment.