[dashboard] New, add statsd metrics to the API (#9519)

This commit is contained in:
Daniel Vaz Gaspar
2020-04-16 10:54:45 +01:00
committed by GitHub
parent d9ebd32485
commit 7b11b44abe
5 changed files with 240 additions and 48 deletions

View File

@@ -38,8 +38,10 @@ from email.mime.text import MIMEText
from email.utils import formatdate
from enum import Enum
from time import struct_time
from timeit import default_timer
from typing import (
Any,
Callable,
Dict,
Iterator,
List,
@@ -1223,6 +1225,21 @@ def create_ssl_cert_file(certificate: str) -> str:
return path
def time_function(func: Callable, *args, **kwargs) -> Tuple[float, Any]:
"""
Measures the amount of time a function takes to execute in ms
:param func: The function execution time to measure
:param args: args to be passed to the function
:param kwargs: kwargs to be passed to the function
:return: A tuple with the duration and response from the function
"""
start = default_timer()
response = func(*args, **kwargs)
stop = default_timer()
return stop - start, response
def MediumText() -> Variant:
return Text().with_variant(MEDIUMTEXT(), "mysql")