metrics for the sheetsync

pull/101/head
Christopher Usher 5 years ago
parent 928f9733d2
commit f9ce41ef32

@ -18,6 +18,15 @@ from common.database import DBManager, query
from .sheets import Sheets from .sheets import Sheets
sheets_synced = prom.Counter(
'sheets_synced',
'Number of successful sheet syncs',
)
sync_errors = prom.Counter(
'sync_errors',
'Number of errors syncing sheets',
)
class SheetSync(object): class SheetSync(object):
@ -118,12 +127,14 @@ class SheetSync(object):
if isinstance(e, HTTPError): if isinstance(e, HTTPError):
detail = ": {}".format(e.response.content) detail = ": {}".format(e.response.content)
logging.exception("Failed to sync{}".format(detail)) logging.exception("Failed to sync{}".format(detail))
sync_errors.inc()
# To ensure a fresh slate and clear any DB-related errors, get a new conn on error. # To ensure a fresh slate and clear any DB-related errors, get a new conn on error.
# This is heavy-handed but simple and effective. # This is heavy-handed but simple and effective.
self.conn = self.dbmanager.get_conn() self.conn = self.dbmanager.get_conn()
self.wait(self.ERROR_RETRY_INTERVAL) self.wait(self.ERROR_RETRY_INTERVAL)
else: else:
logging.info("Successful sync") logging.info("Successful sync")
sheets_synced.inc()
self.wait(self.RETRY_INTERVAL) self.wait(self.RETRY_INTERVAL)
def get_events(self): def get_events(self):

Loading…
Cancel
Save