logging: Add logging in deferred_work queue processor.

Adds logging statements in deferred_work queue consume.
This commit is contained in:
Abhijeet Prasad Bodas 2020-10-29 12:30:39 +05:30 committed by Tim Abbott
parent 7fbd75630f
commit e98a8856c7
1 changed files with 5 additions and 1 deletions

View File

@ -768,6 +768,7 @@ class DeferredWorker(QueueProcessingWorker):
MAX_CONSUME_SECONDS = None
def consume(self, event: Dict[str, Any]) -> None:
start = time.time()
if event['type'] == 'mark_stream_messages_as_read':
user_profile = get_user_profile_by_id(event['user_profile_id'])
@ -795,7 +796,6 @@ class DeferredWorker(QueueProcessingWorker):
event['user_profile_id'])
retry_event(self.queue_name, event, failure_processor)
elif event['type'] == 'realm_export':
start = time.time()
realm = Realm.objects.get(id=event['realm_id'])
output_dir = tempfile.mkdtemp(prefix="zulip-export-")
export_event = RealmAuditLog.objects.get(id=event['id'])
@ -844,6 +844,10 @@ class DeferredWorker(QueueProcessingWorker):
user_profile.realm.string_id, time.time() - start,
)
end = time.time()
logger.info("deferred_work processed %s event (%dms)", event['type'],
(end-start)*1000)
@assign_queue('test', is_test_queue=True)
class TestWorker(QueueProcessingWorker):
# This worker allows you to test the queue worker infrastructure without