diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 5f02d0deb..4ce2b0426 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -11,6 +11,8 @@ Changed - Added TODO List +- Updated functionality to retrieve the stacktrace of an Outlier + v1.10.0 ---------- diff --git a/TODO.rst b/TODO.rst index 3d02d497e..b3bd1ad74 100644 --- a/TODO.rst +++ b/TODO.rst @@ -21,11 +21,6 @@ Features to be implemented - Page '/result//time_per_version' - Max 10 versions per plot. - Page '/result//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.* diff --git a/flask_monitoringdashboard/outlier.py b/flask_monitoringdashboard/outlier.py index 121d4924b..be77e0567 100644 --- a/flask_monitoringdashboard/outlier.py +++ b/flask_monitoringdashboard/outlier.py @@ -7,7 +7,7 @@ import time import traceback -from threading import Thread, enumerate +from threading import Thread import sys import psutil @@ -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 = '
'.join(stack_list) diff --git a/setup.py b/setup.py index 4376bb358..63961f86d 100644 --- a/setup.py +++ b/setup.py @@ -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',