def test_get_group_by(self): """ Test whether the group_by returns the right result """ from flask_monitoringdashboard import config from flask_monitoringdashboard.core.group_by import get_group_by config.group_by = lambda: 3 self.assertEqual(get_group_by(), '3') config.group_by = (lambda: 'User', lambda: 3.0) self.assertEqual(get_group_by(), '(User,3.0)') config.group_by = lambda: lambda: '1234' self.assertEqual(get_group_by(), '1234')
def start_profiler_thread(endpoint): """ Starts a thread that profiles the main thread. """ current_thread = threading.current_thread().ident group_by = get_group_by() thread = StacktraceProfiler(current_thread, endpoint, get_ip(), group_by) thread.start() return thread
def start_outlier_thread(endpoint): """ Starts a thread that collects outliers.""" current_thread = threading.current_thread().ident group_by = get_group_by() thread = OutlierProfiler(current_thread, endpoint, get_ip(), group_by) thread.start() return thread
def start_profiler_thread(endpoint): """ Starts a thread that monitors the main thread. """ current_thread = threading.current_thread().ident ip = request.environ['REMOTE_ADDR'] group_by = get_group_by() thread = StacktraceProfiler(current_thread, endpoint, ip, group_by) thread.start() return thread
def start_outlier_thread(endpoint): """ Starts a thread that collects outliers.""" current_thread = threading.current_thread().ident ip = request.environ['REMOTE_ADDR'] group_by = get_group_by() thread = OutlierProfiler(current_thread, endpoint, ip, group_by) thread.start() return thread
def start_profiler_thread(endpoint): """ Starts a thread that profiles the main thread. """ current_thread = threading.current_thread().ident ip = request.environ[config.ip_header] group_by = get_group_by() thread = StacktraceProfiler(current_thread, endpoint, ip, group_by) thread.start() return thread
def start_performance_thread(endpoint, duration, status_code): """ Starts a thread that updates performance, utilization and last_requested in the database. :param endpoint: Endpoint object :param duration: duration of the request :param status_code: HTTP status code of the request """ group_by = get_group_by() PerformanceProfiler(endpoint, get_ip(), duration, group_by, status_code).start()
def start_profiler_and_outlier_thread(endpoint): """ Starts two threads: PerformanceProfiler and StacktraceProfiler. """ current_thread = threading.current_thread().ident ip = get_ip() group_by = get_group_by() outlier = OutlierProfiler(current_thread, endpoint, ip, group_by) thread = StacktraceProfiler(current_thread, endpoint, ip, group_by, outlier) thread.start() outlier.start() return thread
def test_get_group_by_tuple(config): config.group_by = (lambda: 'User', lambda: 3.0) assert get_group_by() == '(User,3.0)'
def test_get_group_by_function(config): """Test whether the group_by returns the right result.""" config.group_by = lambda: 3 assert get_group_by() == '3'
def test_get_group_by_function_in_function(config): config.group_by = lambda: lambda: '1234' assert get_group_by() == '1234'