Skip to content

Commit

Permalink
Log committed message count for all providers.
Browse files Browse the repository at this point in the history
Summary:
This lets us easily measure raw sync throughput for all accounts, not just
Gmail ones. Fixes T408.

Test Plan: Run Gmail and Exchange syncs and check that the logs look good.

Reviewers: kav-ya

Reviewed By: kav-ya

Maniphest Tasks: T408

Differential Revision: https://review.inboxapp.com/D437
  • Loading branch information
emfree authored and Charles Gruenwald committed Sep 9, 2014
1 parent 55499cc commit 51e8251
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
7 changes: 4 additions & 3 deletions inbox/mailsync/backends/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from sqlalchemy.exc import DataError, IntegrityError

from inbox.log import get_logger
logger = get_logger()
log = get_logger()
from inbox.util.concurrency import retry_and_report_killed
from inbox.util.itert import partition
from inbox.models import (Account, Folder, MAX_FOLDER_NAME_LENGTH)
Expand Down Expand Up @@ -148,8 +148,9 @@ def create_db_objects(account_id, db_session, log, folder_name, raw_messages,
return new_uids


def commit_uids(db_session, log, new_uids):
def commit_uids(db_session, new_uids):
try:
log.info(new_committed_message_count=len(new_uids))
log.info("Committing {0} UIDs".format(len(new_uids)))
db_session.add_all(new_uids)
db_session.commit()
Expand Down Expand Up @@ -212,7 +213,7 @@ def __init__(self, account, heartbeat=1, retry_fail_classes=[]):
self.inbox = Queue()
# how often to check inbox, in seconds
self.heartbeat = heartbeat
self.log = logger.new(component='mail sync', account_id=account.id)
self.log = log.new(component='mail sync', account_id=account.id)
self.account_id = account.id
self.email_address = account.email_address
self.provider_name = account.provider
Expand Down
3 changes: 1 addition & 2 deletions inbox/mailsync/backends/gmail.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,7 @@ def download_and_commit_uids(self, crispin_client, folder_name, uids):
new_imapuids = create_db_objects(
self.account_id, db_session, log, folder_name,
raw_messages, self.create_message)
commit_uids(db_session, log, new_imapuids)
log.info(new_committed_message_count=len(new_imapuids))
commit_uids(db_session, new_imapuids)
return len(new_imapuids)

def __download_queued_threads(self, crispin_client,
Expand Down
2 changes: 1 addition & 1 deletion inbox/mailsync/backends/imap/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ def download_and_commit_uids(self, crispin_client, folder_name, uids):
new_imapuids = create_db_objects(
self.account_id, db_session, log, folder_name,
raw_messages, self.create_message)
commit_uids(db_session, log, new_imapuids)
commit_uids(db_session, new_imapuids)
return len(new_imapuids)

def update_metadata(self, crispin_client, updated):
Expand Down

0 comments on commit 51e8251

Please sign in to comment.