mirror of
https://github.com/GSA/notifications-api.git
synced 2026-09-08 21:33:13 -04:00
Merge pull request #2963 from alphagov/catch-exception-for-event
Catch and log any exception thrown in the checkin event method.
This commit is contained in:
@@ -352,6 +352,7 @@ def setup_sqlalchemy_events(app):
|
|||||||
|
|
||||||
@event.listens_for(db.engine, 'checkout')
|
@event.listens_for(db.engine, 'checkout')
|
||||||
def checkout(dbapi_connection, connection_record, connection_proxy):
|
def checkout(dbapi_connection, connection_record, connection_proxy):
|
||||||
|
try:
|
||||||
# connection given to a web worker
|
# connection given to a web worker
|
||||||
TOTAL_CHECKED_OUT_DB_CONNECTIONS.inc()
|
TOTAL_CHECKED_OUT_DB_CONNECTIONS.inc()
|
||||||
|
|
||||||
@@ -384,9 +385,12 @@ def setup_sqlalchemy_events(app):
|
|||||||
'host': 'unknown',
|
'host': 'unknown',
|
||||||
'url_rule': 'unknown',
|
'url_rule': 'unknown',
|
||||||
}
|
}
|
||||||
|
except Exception:
|
||||||
|
current_app.logger.exception("Exception caught for checkout event.")
|
||||||
|
|
||||||
@event.listens_for(db.engine, 'checkin')
|
@event.listens_for(db.engine, 'checkin')
|
||||||
def checkin(dbapi_connection, connection_record):
|
def checkin(dbapi_connection, connection_record):
|
||||||
|
try:
|
||||||
# connection returned by a web worker
|
# connection returned by a web worker
|
||||||
TOTAL_CHECKED_OUT_DB_CONNECTIONS.dec()
|
TOTAL_CHECKED_OUT_DB_CONNECTIONS.dec()
|
||||||
|
|
||||||
@@ -398,3 +402,5 @@ def setup_sqlalchemy_events(app):
|
|||||||
connection_record.info['request_data']['host'],
|
connection_record.info['request_data']['host'],
|
||||||
connection_record.info['request_data']['url_rule']
|
connection_record.info['request_data']['url_rule']
|
||||||
).observe(duration)
|
).observe(duration)
|
||||||
|
except Exception:
|
||||||
|
current_app.logger.exception("Exception caught for checkin event.")
|
||||||
|
|||||||
Reference in New Issue
Block a user