Skip to content

Commit b776edc

Browse files
update logging to log when batch is empty on flush or flush of batch size
1 parent a2fe995 commit b776edc

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

optimizely/event/event_processor.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,13 @@ def flush(self):
222222

223223
def _flush_queue(self):
224224
""" Flushes event_queue by dispatching events. """
225-
self.logger.debug('Flushing the queue.')
226-
if len(self._current_batch) == 0:
225+
batch_len = len(self._current_batch)
226+
if batch_len == 0:
227+
self.logger.debug('Nothing to flush.')
227228
return
228229

230+
self.logger.debug('Flushing batch size ' + str(batch_len))
231+
229232
with self.LOCK:
230233
to_process_batch = list(self._current_batch)
231234
self._current_batch = list()

tests/test_event_processor.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def test_flush_once_max_timeout(self):
179179
self.optimizely.logger = SimpleLogger(enums.LogLevels.DEBUG)
180180

181181
with mock.patch.object(self.optimizely, 'logger') as mock_config_logging:
182-
self._set_event_processor(event_dispatcher, mock_config_logging)
182+
self._set_event_processor(event_dispatcher, self.optimizely.logger)
183183

184184
user_event = self._build_conversion_event(self.event_name)
185185
self.event_processor.process(user_event)
@@ -192,7 +192,8 @@ def test_flush_once_max_timeout(self):
192192
self.assertTrue(mock_config_logging.debug.called)
193193
mock_config_logging.debug.assert_any_call('Received event of type ConversionEvent for user test_user.')
194194
mock_config_logging.debug.assert_any_call('Flush interval deadline. Flushed queue.')
195-
self.assertTrue(mock_config_logging.debug.call_count == 2)
195+
mock_config_logging.debug.assert_any_call('Flushing batch size 1')
196+
self.assertTrue(mock_config_logging.debug.call_count == 3)
196197
self.optimizely.logger = SimpleLogger()
197198

198199
def test_flush_max_batch_size(self):

0 commit comments

Comments
 (0)