Exemple #1
0
    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')
Exemple #2
0
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
Exemple #3
0
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
Exemple #4
0
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
Exemple #5
0
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
Exemple #7
0
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()
Exemple #8
0
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
Exemple #9
0
def test_get_group_by_tuple(config):
    config.group_by = (lambda: 'User', lambda: 3.0)
    assert get_group_by() == '(User,3.0)'
Exemple #10
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'
Exemple #11
0
def test_get_group_by_function_in_function(config):
    config.group_by = lambda: lambda: '1234'
    assert get_group_by() == '1234'