From 1f379e28253d8a259e5af4fa5c45a5836448ca03 Mon Sep 17 00:00:00 2001 From: Brian Kennedy Date: Fri, 21 Jul 2023 10:12:34 -0700 Subject: [PATCH] Log cleanup (#79) * 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 --- moesifdjango/job_scheduler.py | 5 +---- moesifdjango/middleware.py | 1 + 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/moesifdjango/job_scheduler.py b/moesifdjango/job_scheduler.py index af3fb14..1f2495f 100644 --- a/moesifdjango/job_scheduler.py +++ b/moesifdjango/job_scheduler.py @@ -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(): @@ -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: diff --git a/moesifdjango/middleware.py b/moesifdjango/middleware.py index 0c9ef35..aa9758f 100644 --- a/moesifdjango/middleware.py +++ b/moesifdjango/middleware.py @@ -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),