Skip to content

Commit

Permalink
Merge pull request #81 from flask-dashboard/outlier
Browse files Browse the repository at this point in the history
Outlier
  • Loading branch information
mircealungu committed Apr 8, 2018
2 parents 91c9fe7 + 3e71c8a commit eda664a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 2 deletions.
5 changes: 5 additions & 0 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ the entry point of the app. The following things can be configured:
GUEST_PASSWORD=['dashboardguest!', 'second_pw!']
GIT=/<path to your project>/.git/
OUTLIER_DETECTION_CONSTANT=2.5
DASHBOARD_ENABLED = True
TEST_DIR=/<path to your project>/tests/
N=5
SUBMIT_RESULTS_URL=http://0.0.0.0:5000/dashboard/submit-test-results
Expand Down Expand Up @@ -90,6 +91,10 @@ This might look a bit overwhelming, but the following list explains everything i
extra information is logged into the database.
A default value for this variable is :math:`2.5`, but can be changed in the config-file.

- **OUTLIERS_ENABLED:** Whether you want to collect information about outliers. If you set this to true,
the expected overhead is a bit larger, as you can find
`here <https://github.com/flask-dashboard/Testing-Dashboard-Overhead>`_.

- **TEST_DIR**, **N**, **SUBMIT_RESULTS_URL:**
To enable Travis to run your unit tests and send the results to the dashboard, you have to set those values:

Expand Down
5 changes: 5 additions & 0 deletions flask_monitoringdashboard/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def __init__(self):
self.outlier_detection_constant = 2.5
self.colors = {}
self.security_token = 'cc83733cb0af8b884ff6577086b87909'
self.outliers_enabled = True

# define a custom function to retrieve the session_id or username
self.get_group_by = None
Expand Down Expand Up @@ -56,6 +57,8 @@ def init_from(self, file=None, envvar=None):
SECURITY_TOKEN: Used for getting the data in /get_json_data/<security_token>
OUTLIERS_ENABLED: Whether you want the Dashboard to collect extra information about outliers.
:param file: a string pointing to the location of the config-file
:param envvar: a string specifying which environment variable holds the config file location
"""
Expand Down Expand Up @@ -84,6 +87,8 @@ def init_from(self, file=None, envvar=None):
self.database_name = parser.get('dashboard', 'DATABASE')
if parser.has_option('dashboard', 'TEST_DIR'):
self.test_dir = parser.get('dashboard', 'TEST_DIR')
if parser.has_option('dashboard', 'OUTLIERS_ENABLED'):
self.outliers_enabled = parser.get('dashboard', 'OUTLIERS_ENABLED') == "True"

# For manually defining colors of specific endpoints
if parser.has_option('dashboard', 'COLORS'):
Expand Down
3 changes: 3 additions & 0 deletions flask_monitoringdashboard/measurement.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ def wrapper(*args, **kwargs):


def get_average(endpoint):
if not config.outliers_enabled:
return None

if endpoint in endpoint_count:
if endpoint_count[endpoint] < 10:
return None
Expand Down
2 changes: 1 addition & 1 deletion flask_monitoringdashboard/outlier.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self, average):
self.stopped = False

try:
thread = Thread(target=self.log_stack_trace, args=(self,))
thread = Thread(target=self.log_stack_trace)
thread.start()
except Exception as e:
print('Can\'t log traceback information: {}'.format(e))
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def desc():

setuptools.setup(
name="Flask-MonitoringDashboard",
version='1.11.1',
version='1.11.2',
packages=setuptools.find_packages(),
include_package_data=True,
platforms='Any',
Expand Down

0 comments on commit eda664a

Please sign in to comment.