mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-05-02 13:36:02 -04:00
Measure federation send transaction resources
This commit is contained in:
parent
d45489474d
commit
3bc9629be5
2 changed files with 21 additions and 5 deletions
|
@ -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",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue