mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +00:00
[dashboard] New, add statsd metrics to the API (#9519)
This commit is contained in:
committed by
GitHub
parent
d9ebd32485
commit
7b11b44abe
@@ -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")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user