Skip to content

Commit

Permalink
Merge pull request #62 from flask-dashboard/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
mircealungu committed Mar 6, 2018
2 parents 90dfa0a + 23efbf8 commit 6195126
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 23 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.rst
Expand Up @@ -11,6 +11,8 @@ Changed

- Added TODO List

- Updated functionality to retrieve the stacktrace of an Outlier


v1.10.0
----------
Expand Down
5 changes: 0 additions & 5 deletions TODO.rst
Expand Up @@ -21,11 +21,6 @@ Features to be implemented
- Page '/result/<endpoint>/time_per_version' - Max 10 versions per plot.
- Page '/result/<endpoint>/outliers' - Max 20 results per table.

- [ ] Updating the Outlier-object, as it now works by writing all stack-traces to a file.
Once this is done, read everything from it.
This is a security flaw, and doesn't produce the right value if multiple requests are using this file at the same
time.

Work in progress
----------------
*Use this section if someone is already working on an item above.*
25 changes: 8 additions & 17 deletions flask_monitoringdashboard/outlier.py
Expand Up @@ -7,7 +7,7 @@

import time
import traceback
from threading import Thread, enumerate
from threading import Thread
import sys
import psutil

Expand All @@ -33,23 +33,14 @@ def log_stack_trace(stack_info):
# average is in ms, sleep requires seconds
time.sleep(stack_info.average / 1000.0)

# iterate through every active thread and get the stack-trace
# iterate through every active thread and store the stack-trace
stack_list = []
try:
for th in enumerate():
try:
f = open(LOG_FILE, 'w')
stack_list.extend(['', str(th)])
traceback.print_stack(sys._current_frames()[th.ident], file=f)
f.close()
f = open(LOG_FILE, 'r')
stack_list.extend(f.readlines())
except Exception as e:
print('Exception occurred: {}'.format(e))
traceback.print_exc()
except Exception as e:
print('Exception occurred: {}'.format(e))
traceback.print_exc()
for thread_id, stack in sys._current_frames().items():
stack_list.append("\n# Thread_id: %s" % thread_id)
for filename, lineno, name, line in traceback.extract_stack(stack):
stack_list.append('File: "%s", line %d, in %s' % (filename, lineno, name))
if line:
stack_list.append(" %s" % (line.strip()))

# Set the values in the object
stack_info.stacktrace = '<br />'.join(stack_list)
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -13,7 +13,7 @@ def desc():

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

0 comments on commit 6195126

Please sign in to comment.