Skip to content

Commit e63e11a

Browse files
authored
Merge pull request #164 from flask-dashboard/development
Development
2 parents 2ac73bc + 2eb3018 commit e63e11a

File tree

97 files changed

+2701
-1298
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

97 files changed

+2701
-1298
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,3 +100,6 @@ ENV/
100100
# Rope project settings
101101
.ropeproject
102102

103+
# own scripts
104+
flask_monitoringdashboard/make_requests.py
105+
flask_monitoringdashboard/session_test.py

README.md

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,37 @@
33
[![Documentation Status](https://readthedocs.org/projects/flask-monitoringdashboard/badge/?version=latest)](http://flask-monitoringdashboard.readthedocs.io/en/latest/?badge=latest)
44
[![codecov](https://codecov.io/gh/flask-dashboard/Flask-MonitoringDashboard/branch/master/graph/badge.svg)](https://codecov.io/gh/flask-dashboard/Flask-MonitoringDashboard)
55
[![PyPI version](https://badge.fury.io/py/Flask-MonitoringDashboard.svg)](https://badge.fury.io/py/Flask-MonitoringDashboard)
6-
[![Gitter chat](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/Flask-MonitoringDashboard/Lobby)
76
[![Py-version](https://img.shields.io/pypi/pyversions/flask_monitoringdashboard.svg)](https://img.shields.io/pypi/pyversions/flask_monitoringdashboard.svg)
87
[![Downloads](http://pepy.tech/badge/flask-monitoringdashboard)](http://pepy.tech/count/flask-monitoringdashboard)
98

109
Dashboard for automatic monitoring of Flask web-services.
1110

1211
The Flask Monitoring Dashboard is an extension that offers four main functionalities with little effort from the Flask developer:
13-
- **Monitor the Flask application:**
14-
Our Dashboard allows you to see which endpoints process a lot of request and how fast.
15-
Additionally, it provides information about the evolving performance of an endpoint throughout different versions if you’re using git.
12+
13+
- **Monitor the performance and utilization:**
14+
The Dashboard allows you to see which endpoints process a lot of requests and how fast.
15+
Additionally, it provides information about the evolving performance of an endpoint throughout different versions if you're using git.
16+
17+
- **Profile requests and endpoints:**
18+
The execution path of every request is tracked and stored into the database. This allows you to gain
19+
insight over which functions in your code take the most time to execute. Since all requests for an
20+
endpoint are also merged together, the Dashboard provides an overview of which functions are used in
21+
which endpoint.
22+
1623
- **Monitor your test coverage:**
17-
The dashboard allows you to find out which endpoints are covered by unit tests, allowing also for integration with Travis for automation purposes.
18-
For more information, see [this file](http://flask-monitoringdashboard.readthedocs.io/en/latest/functionality.html#test-coverage-monitoring).
24+
The Dashboard allows you to find out which endpoints are covered by unit tests, allowing also for integration with Travis for automation purposes.
25+
For more information, see [this file](http://flask-monitoringdashboard.readthedocs.io/en/latest/functionality.html#test-coverage-monitoring)
26+
1927
- **Collect extra information about outliers:**
20-
Outliers are requests that take much longer to process than regular requests.
21-
The dashboard automatically detects that a request is an outlier and stores extra information about it (stack trace, request values, Request headers, Request environment).
22-
- **Visualize the collected data in a number useful graphs:**
28+
Outliers are requests that take much longer to process than regular requests.
29+
The Dashboard automatically detects that a request is an outlier and stores extra information about it (stack trace, request values, Request headers, Request environment).
30+
2331
The dashboard is automatically added to your existing Flask application.
2432
You can view the results by default using the default endpoint (this can be configured to another route):
2533

2634
[/dashboard](http://localhost:5000/dashboard)
2735

28-
For a more advanced documentation, take a look at the information on [this site](http://flask-monitoringdashboard.readthedocs.io/en/latest/functionality.html).
36+
For more advanced documentation, take a look at the information on [this site](http://flask-monitoringdashboard.readthedocs.io/en/latest/functionality.html).
2937

3038
## Installation
3139
To install from source, download the source code, then run this:
@@ -46,7 +54,8 @@ Adding the extension to your Flask app is simple:
4654
dashboard.bind(app)
4755

4856
## Documentation
49-
For a more advanced documentation, see [this site](http://flask-monitoringdashboard.readthedocs.io).
57+
For more advanced documentation, see [this site](http://flask-monitoringdashboard.readthedocs.io).
58+
If you run into trouble migrating from version 1.X.X to version 2.0.0, this site also helps you solve this.
5059

5160
## Screenshots
5261
![Screenshot 1](/docs/img/screenshot1.png)

config.cfg

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[dashboard]
2+
APP_VERSION=1.0
3+
GIT=/<path to your project>/.git/
4+
CUSTOM_LINK='dashboard'
5+
MONITOR_LEVEL=3
6+
OUTLIER_DETECTION_CONSTANT=2.5
7+
SAMPLING_PERIOD=20
8+
9+
[authentication]
10+
USERNAME='admin'
11+
PASSWORD='admin'
12+
GUEST_USERNAME='guest'
13+
GUEST_PASSWORD='[dashboardguest!, second_pw!]'
14+
SECURITY_TOKEN='cc83733cb0af8b884ff6577086b87909'
15+
16+
[database]
17+
TABLE_PREFIX=''
18+
DATABASE=sqlite:////<path to your project>/dashboard.db
19+
20+
[visualization]
21+
TIMEZONE='Europe/Amsterdam'
22+
COLORS={'main':'[0,97,255]',
23+
'static':'[255,153,0]'}

docs/changelog.rst

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,28 @@ Unreleased
99
----------
1010
Changed
1111

12-
- Restructuring of Test-Monitoring page
12+
-
13+
14+
15+
v2.0.0
16+
----------
17+
Changed
18+
19+
- Added a configuration option to prefix a table in the database
20+
21+
- Optimize queries, such that viewing data is faster
22+
23+
- Updated database scheme
24+
25+
- Implemented functionality to customize time window of graphs
26+
27+
- Implemented a profiler for Request profiling
28+
29+
- Implemented a profiler for Endpoint profiling
30+
31+
- Refactored current code, which improves readability
32+
33+
- Refactoring of Test-Monitoring page
1334

1435
- Identify testRun by Travis build number
1536

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
version = constants['version']
2929

3030
release = version
31-
copyright = '{}, {}'.format(datetime.datetime.utcnow().year, author)
31+
copyright = '{}, {}. Version {}'.format(datetime.datetime.utcnow().year, author, version)
3232

3333
# -- General configuration ---------------------------------------------------
3434

docs/configuration.rst

Lines changed: 63 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Configuration
22
=============
3-
Once you have successfully installed the Flask Monitoring Dashboard with information from
3+
Once you have successfully installed the Flask-MonitoringDashboard using the instructions from
44
`this page <installation.html>`_, you can use the advanced features by correctly configuring the Dashboard.
55

66
Using a configuration file
@@ -33,8 +33,8 @@ Thus, it becomes:
3333
if __name__ == '__main__':
3434
app.run(debug=True)
3535
36-
Instead of having a hard-coded string containing the location of the config file in the code above, it is also possible
37-
to define an environment variable that specifies the location of this config file.
36+
Instead of having a hard-coded string containing the location of the config file in the code above,
37+
it is also possible to define an environment variable that specifies the location of this config file.
3838
The line should then be:
3939

4040
.. code-block:: python
@@ -45,75 +45,95 @@ This will configure the Dashboard based on the file provided in the environment
4545

4646
The content of the configuration file
4747
-------------------------------------
48-
Once the setup is complete, a configuration file (e.g. 'config.cfg') should be set next to the python file that
49-
contains the entry point of the app. The following things can be configured:
48+
Once the setup is complete, a `configuration file`_ (e.g. 'config.cfg') should be set next to the python
49+
file that contains the entry point of the app. The following properties can be configured:
50+
51+
.. _`configuration file`: https://github.com/flask-dashboard/Flask-MonitoringDashboard/tree/master/config.cfg
5052

5153
.. code-block:: python
5254
5355
[dashboard]
5456
APP_VERSION=1.0
55-
CUSTOM_LINK=dashboard
56-
DATABASE=sqlite:////<path to your project>/dashboard.db
57-
DEFAULT_MONITOR=True
58-
TIMEZONE='Europe/Amsterdam'
59-
USERNAME=admin
60-
PASSWORD=admin
61-
GUEST_USERNAME=guest
62-
GUEST_PASSWORD=['dashboardguest!', 'second_pw!']
6357
GIT=/<path to your project>/.git/
58+
CUSTOM_LINK='dashboard'
59+
MONITOR_LEVEL=3
6460
OUTLIER_DETECTION_CONSTANT=2.5
65-
OUTLIERS_ENABLED=True
61+
SAMPLING_PERIOD=20
62+
63+
[authentication]
64+
USERNAME='admin'
65+
PASSWORD='admin'
66+
GUEST_USERNAME='guest'
67+
GUEST_PASSWORD='[dashboardguest!, second_pw!]'
6668
SECURITY_TOKEN='cc83733cb0af8b884ff6577086b87909'
67-
TEST_DIR=/<path to your project>/tests/
69+
70+
[database]
71+
TABLE_PREFIX=''
72+
DATABASE=sqlite:////<path to your project>/dashboard.db
73+
74+
[visualization]
75+
TIMEZONE='Europe/Amsterdam'
6876
COLORS={'main':'[0,97,255]',
6977
'static':'[255,153,0]'}
7078
71-
This might look a bit overwhelming, but the following list explains everything in detail:
7279
73-
- **APP_VERSION:** The version of the application that you use.
74-
Updating the version helps in showing differences in execution times of a function over a period of time.
80+
As can be seen above, the configuration is split into 4 headers:
7581

76-
- **CUSTOM_LINK:** The Dashboard can be visited at localhost:5000/{{CUSTOM_LINK}}.
82+
Dashboard
83+
~~~~~~~~~
7784

78-
- **DATABASE:** Suppose you have multiple projects where you're working on and want to separate the results.
79-
Then you can specify different database_names, such that the result of each project is stored in its own database.
85+
- **APP_VERSION:** The version of the application that you use.
86+
Updating the version allows seeing the changes in the execution time of requests over multiple versions.
8087

81-
- **DEFAULT_MONITOR:** When this configuration is set to True, new endpoints are automatically monitored by the Dashboard.
88+
- **GIT:** Since updating the version in the configuration-file when updating code isn't very convenient,
89+
another way is to provide the location of the git-folder. From the git-folder,
90+
the version is automatically retrieved by reading the commit-id (hashed value).
91+
The specified value is the location to the git-folder. This is relative to the configuration-file.
8292

83-
- **TIMEZONE:** The timezone for converting a UTC timestamp to a local timestamp. For a list of all
84-
timezones, use the following:
93+
- **CUSTOM_LINK:** The Dashboard can be visited at localhost:5000/{{CUSTOM_LINK}}.
8594

86-
.. code-block:: python
95+
- **MONITOR_LEVEL**: The level for monitoring your endpoints. The default value is 3. For more information, see the
96+
Rules page.
8797

88-
import pytz # pip install pytz
89-
print(pytz.all_timezones)
98+
- **OUTLIER_DETECTION_CONSTANT:** When the execution time is greater than :math:`constant * average`,
99+
extra information is logged into the database. A default value for this variable is :math:`2.5`.
90100

91-
The dashboard saves the time of every request by default in a UTC-timestamp. However, if you want to display
92-
it in a local timestamp, you need this property.
101+
- **SAMPLING_PERIOD:** Time between two profiler-samples. The time must be specified in ms.
102+
If this value is not set, the profiler monitors continuously.
103+
104+
Authentication
105+
~~~~~~~~~~~~~~
93106

94107
- **USERNAME** and **PASSWORD:** Must be used for logging into the Dashboard.
95108
Thus both are required.
96109

97110
- **GUEST_USERNAME** and **GUEST_PASSWORD:** A guest can only see the results, but cannot configure/download any data.
98111

99-
- **GIT:** Since updating the version in the configuration-file when updating code isn't very useful,
100-
it is a better idea to provide the location of the git-folder.
101-
From the git-folder,
102-
The version is automatically retrieved by reading the commit-id (hashed value).
103-
The location is relative to the configuration-file.
112+
- **SECURITY_TOKEN:** The token that is used for exporting the data to other services. If you leave this unchanged,
113+
any service is able to retrieve the data from the database.
104114

105-
- **OUTLIER_DETECTION_CONSTANT:** When the execution time is more than this :math:`constant * average`,
106-
extra information is logged into the database.
107-
A default value for this variable is :math:`2.5`.
115+
Database
116+
~~~~~~~~
108117

109-
- **OUTLIERS_ENABLED:** Whether you want to collect information about outliers. If you set this to true,
110-
the expected overhead of the Dashboard is a bit larger, as you can find
111-
`here <https://github.com/flask-dashboard/Testing-Dashboard-Overhead>`_.
118+
- **TABLE_PREFIX:** A prefix to every table that the Flask-MonitoringDashboard uses, to ensure that there are no
119+
conflicts with the other tables, that are specified by the user of the dashboard.
112120

113-
- **SECURITY_TOKEN:** The token that is used for exporting the data to other services. If you leave this unchanged,
114-
any service is able to retrieve the data from the database.
121+
- **DATABASE:** Suppose you have multiple projects that you're working on and want to separate the results.
122+
Then you can specify different database_names, such that the result of each project is stored in its own database.
123+
124+
Visualization
125+
~~~~~~~~~~~~~
126+
127+
- **TIMEZONE:** The timezone for converting a UTC timestamp to a local timestamp. For a list of all
128+
timezones, use the following:
115129

116-
- **TEST_DIR:** Specifies where the unit tests reside. This will show up in the configuration in the Dashboard.
130+
.. code-block:: python
131+
132+
import pytz # pip install pytz
133+
print(pytz.all_timezones)
134+
135+
The dashboard saves the time of every request by default in a UTC-timestamp. However, if you want to display
136+
it in a local timestamp, you need this property.
117137

118138
- **COLORS:** The endpoints are automatically hashed into a color.
119139
However, if you want to specify a different color for an endpoint, you can set this variable.

docs/contact.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,26 +12,26 @@ Currently, the team consists of three active developers:
1212
+------------+----------------------------------------------------------------------+
1313
| |Picture1| | | **Patrick Vogel** |
1414
| | | |
15-
| | | Core developer |
15+
| | | Project Leader |
1616
| | | |
1717
| | | **E-mail:** `patrickvogel@live.nl <mailto:patrickvogel@live.nl>`_. |
1818
+------------+----------------------------------------------------------------------+
19-
| |Picture2| | | **Thijs Klooster** |
19+
| |Picture2| | | **Bogdan Petre** |
2020
| | | |
21-
| | | Test Monitor Specialist |
21+
| | | Core Developer |
2222
+------------+----------------------------------------------------------------------+
23-
| |Picture3| | | **Bogdan Petre** |
23+
| |Picture3| | | **Thijs Klooster** |
2424
| | | |
25-
| | | Outlier Specialist |
25+
| | | Test Monitor Specialist |
2626
+------------+----------------------------------------------------------------------+
2727

2828
.. |Picture1| image:: https://avatars2.githubusercontent.com/u/17162650?s=460&v=4
2929
..:width: 100px
3030

31-
.. |Picture2| image:: https://avatars3.githubusercontent.com/u/17165311?s=400&v=4
31+
.. |Picture2| image:: https://avatars2.githubusercontent.com/u/7281856?s=400&v=4
3232
..:width: 100px
3333

34-
.. |Picture3| image:: https://avatars2.githubusercontent.com/u/7281856?s=400&v=4
34+
.. |Picture3| image:: https://avatars3.githubusercontent.com/u/17165311?s=400&v=4
3535
..:width: 100px
3636

3737

docs/developing.rst

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
Developing
22
==========
3-
This page provides information about contributing to the Flask Monitoring Dashboard.
3+
This page provides information about contributing to the Flask-MonitoringDashboard.
44
Furthermore, a number of useful tools for improving the quality of the code are discussed.
55

66

77
Implementation
88
--------------
9-
The Dashboard is implemented in the following 6 folders: core, database, static, templates, test
9+
The Dashboard is implemented in the following 6 directories: core, database, static, templates, test
1010
and views. Together this forms a Model-View-Controller-pattern:
1111

1212
- **Model**: The model consists of the database-code. To be more specific, it is defined in
1313
'Flask-MonitoringDashboard/database.__init__.py'.
1414

15-
- **View**: The view is a combination of the following three folders:
15+
- **View**: The view is a combination of the following three directories:
1616

1717
- **static**: contains some CSS and JS files.
1818

@@ -27,13 +27,15 @@ and views. Together this forms a Model-View-Controller-pattern:
2727
fmd_base.html
2828
├──fmd_dashboard/overview.html
2929
│ └──fmd_dashboard/graph.html
30-
│ └──fmd_dashboard/graph-details.html
31-
│ └──fmd_dashboard/outliers.html
30+
│ ├──fmd_dashboard/graph-details.html
31+
│ │ └──fmd_dashboard/outliers.html
32+
│ ├──fmd_dashboard/profiler.html
33+
│ │ └──fmd_dashboard/grouped_profiler.html
34+
│ └──fmd_testmonitor/endpoint.html
3235
├──fmd_testmonitor/testmonitor.html
33-
├──fmd_testmonitor/testresult.html
3436
├──fmd_config.html
3537
├──fmd_login.html
36-
└──fmd_urles.html
38+
└──fmd_rules.html
3739
fmd_export-data.html
3840

3941

@@ -61,7 +63,7 @@ and views. Together this forms a Model-View-Controller-pattern:
6163

6264
- **fmd_testmonitor/testmonitor.html**: For rendering the `Testmonitor-page`_.
6365

64-
- **fmd_testmonitor/testresult.html**: For rendering the results of the Testmonitor.
66+
- **fmd_testmonitor/endpoint.html**: For rendering the results of the Testmonitor.
6567

6668
.. _`Configuration-page`: http://localhost:5000/dashboard/configuration
6769
.. _`Login-page`: http://localhost:5000/dashboard/login
@@ -136,6 +138,22 @@ The following tools are used for helping the development of the Dashboard:
136138
.. _Sphinx: www.sphinx-doc.org
137139
.. _ReadTheDocs: http://flask-monitoringdashboard.readthedocs.io
138140

141+
Database Scheme
142+
---------------
143+
If you're interested in the data that the Flask-MonitoringDashboard stores, have a look at the database scheme below.
144+
145+
Note the following:
146+
147+
- A key represents the Primary Key of the corresponding table. In the StackLine-table, the Primary Key consists
148+
of a combination of two fields (request_id and position).
149+
150+
- The blue arrow points to the Foreign Key that is used to combine the results of multiple tables.
151+
152+
.. figure :: img/database_scheme.png
153+
:width: 100%
154+
155+
156+
139157
Versions
140158
--------
141159
The Dashboard uses `Semantic-versioning`_. Therefore, it is specified in a **Major** . **Minor** . **Patch** -format:

0 commit comments

Comments
 (0)