diff options
author | Paul "LeoNerd" Evans <paul@matrix.org> | 2015-03-16 17:21:59 +0000 |
---|---|---|
committer | Paul "LeoNerd" Evans <paul@matrix.org> | 2015-03-16 17:21:59 +0000 |
commit | be170b1426f31fb56fdb06e4b52ba3fdf617f246 (patch) | |
tree | 474110d214e92ac0bb766d4f353a168c0da63873 | |
parent | Merge pull request #110 from matrix-org/fix_ban (diff) | |
download | synapse-be170b1426f31fb56fdb06e4b52ba3fdf617f246.tar.xz |
Add a metric for the scheduling latency of SQL queries
Diffstat (limited to '')
-rw-r--r-- | synapse/storage/_base.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/synapse/storage/_base.py b/synapse/storage/_base.py index 40f2fc6d76..2979a83524 100644 --- a/synapse/storage/_base.py +++ b/synapse/storage/_base.py @@ -38,6 +38,8 @@ transaction_logger = logging.getLogger("synapse.storage.txn") metrics = synapse.metrics.get_metrics_for("synapse.storage") +sql_scheduling_timer = metrics.register_distribution("schedule_time") + sql_query_timer = metrics.register_distribution("query_time", labels=["verb"]) sql_txn_timer = metrics.register_distribution("transaction_time", labels=["desc"]) sql_getevents_timer = metrics.register_distribution("getEvents_time", labels=["desc"]) @@ -240,6 +242,8 @@ class SQLBaseStore(object): """Wraps the .runInteraction() method on the underlying db_pool.""" current_context = LoggingContext.current_context() + start_time = time.time() * 1000 + def inner_func(txn, *args, **kwargs): with LoggingContext("runInteraction") as context: current_context.copy_to(context) @@ -252,6 +256,7 @@ class SQLBaseStore(object): name = "%s-%x" % (desc, txn_id, ) + sql_scheduling_timer.inc_by(time.time() * 1000 - start_time) transaction_logger.debug("[TXN START] {%s}", name) try: return func(LoggingTransaction(txn, name), *args, **kwargs) |