diff options
author | Erik Johnston <erikj@jki.re> | 2016-08-10 14:16:14 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-10 14:16:14 +0100 |
commit | 5aeadb74144c8fd6b4c4398adc8e832c0296eee5 (patch) | |
tree | cb1e28f93b02d6aab74e60f2e5e1da42049cbafe /synapse/util/metrics.py | |
parent | Merge pull request #998 from matrix-org/erikj/pdu_fail_cache (diff) | |
parent | Measure federation send transaction resources (diff) | |
download | synapse-5aeadb74144c8fd6b4c4398adc8e832c0296eee5.tar.xz |
Merge pull request #999 from matrix-org/erikj/measure_more
Measure federation send transaction resources
Diffstat (limited to 'synapse/util/metrics.py')
-rw-r--r-- | synapse/util/metrics.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/synapse/util/metrics.py b/synapse/util/metrics.py index 0b944d3e63..4d7fee8868 100644 --- a/synapse/util/metrics.py +++ b/synapse/util/metrics.py @@ -13,10 +13,12 @@ # See the License for the specific language governing permissions and # limitations under the License. +from twisted.internet import defer from synapse.util.logcontext import LoggingContext import synapse.metrics +from functools import wraps import logging @@ -47,6 +49,18 @@ block_db_txn_duration = metrics.register_distribution( ) +def measure_func(name): + def wrapper(func): + @wraps(func) + @defer.inlineCallbacks + def measured_func(self, *args, **kwargs): + with Measure(self.clock, name): + r = yield func(self, *args, **kwargs) + defer.returnValue(r) + return measured_func + return wrapper + + class Measure(object): __slots__ = [ "clock", "name", "start_context", "start", "new_context", "ru_utime", |