Skip to content

Commit

Permalink
Log cleanup (#79)
Browse files Browse the repository at this point in the history
* Fix 0s instead of 60s threshold for delay alert and remove log message in default condition that there are no events

* Moving start job log statement to the actual start of the job instead of inside each run of batch_events
  • Loading branch information
bakennedy committed Jul 21, 2023
1 parent ae97674 commit 1f379e2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 4 deletions.
5 changes: 1 addition & 4 deletions moesifdjango/job_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ 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 @@ -65,12 +64,10 @@ def batch_events(self, api_client, moesif_events_queue, debug, batch_size):
# Set the last time event job ran after sending events
batch_send_time = datetime.utcnow()
delta = batch_send_time - req_time
if debug and delta.total_seconds() > 0:
if debug and delta.total_seconds() > 60:
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")
# Set the last time event job ran but no message to read from the queue
return None, None, datetime.utcnow()
except Exception as e:
Expand Down
1 change: 1 addition & 0 deletions moesifdjango/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ def schedule_event_background_job(self):
if not self.scheduler.get_jobs():
self.scheduler.add_listener(self.event_listener, EVENT_JOB_EXECUTED | EVENT_JOB_ERROR)
self.scheduler.start()
print("Starting batch events job")
self.scheduler.add_job(
func=lambda: self.job_scheduler.batch_events(self.api_client, self.mo_events_queue, self.DEBUG,
self.event_batch_size),
Expand Down

0 comments on commit 1f379e2

Please sign in to comment.