Skip to content

Commit e81057a

Browse files
committed
Improve exception monitoring documentation
- Expand exception monitoring section with comprehensive details - Fix code blocks to use proper reStructuredText syntax - Add sections on automatic capture, manual capture, and viewing exceptions - Fix Python 3.9 compatibility issue in conf.py (datetime.UTC -> datetime.now())
1 parent fd17b26 commit e81057a

File tree

2 files changed

+71
-11
lines changed

2 files changed

+71
-11
lines changed

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
version = constants['version']
3131

3232
release = version
33-
copyright = '{}, {}. Version {}'.format(datetime.datetime.now(datetime.UTC).year, author, version)
33+
copyright = '{}, {}. Version {}'.format(datetime.datetime.now().year, author, version)
3434

3535
# -- General configuration ---------------------------------------------------
3636

docs/functionality.rst

Lines changed: 70 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -186,16 +186,76 @@ and standard deviation, and also total execution time.
186186

187187

188188
2. Exception Monitoring
189-
~~~~~~~~~~~~~~~~~~~~
190-
Flask-MonitoringDashboard automatically logs unhandled exceptions with full stack traces, showing where and why errors occur, if you have monitoring level 1 or above.
191-
192-
To capture handled exceptions manually and save them for displaying in the exception dashboard:
193-
```python
194-
try:
195-
# Your code
196-
except Exception as e:
197-
dashboard.capture(e) # Logs exception with stack trace for debugging
198-
```
189+
~~~~~~~~~~~~~~~~~~~~~~~~
190+
191+
Flask-MonitoringDashboard provides comprehensive exception monitoring to help you track
192+
and debug errors in your application. Exception monitoring is automatically enabled for
193+
all endpoints with monitoring level 1 or above.
194+
195+
Automatic Exception Capture
196+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
197+
198+
All unhandled exceptions are automatically captured with:
199+
200+
- Full stack traces showing the exact line where the error occurred
201+
- Exception type and message
202+
- Request context (endpoint, method, parameters)
203+
- Timestamp and occurrence count
204+
- Function code context with syntax highlighting
205+
206+
The captured exceptions are grouped by their stack trace signature, making it easy to
207+
identify recurring issues.
208+
209+
Manual Exception Capture
210+
^^^^^^^^^^^^^^^^^^^^^^^^^
211+
212+
You can also manually capture exceptions for better debugging:
213+
214+
.. code-block:: python
215+
216+
from flask_monitoringdashboard import capture_exception
217+
218+
try:
219+
# Your code that might raise an exception
220+
result = risky_operation()
221+
except ValueError as e:
222+
capture_exception(e) # Manually capture with stack trace
223+
# Handle the error gracefully
224+
return "An error occurred", 400
225+
226+
This is useful when you want to track handled exceptions or add additional context
227+
to error reporting.
228+
229+
Viewing Exceptions in the Dashboard
230+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
231+
232+
To view captured exceptions:
233+
234+
1. **Application-wide view:** Go to http://localhost:5000/dashboard/exceptions
235+
236+
This shows all exceptions across all endpoints, with:
237+
238+
- Exception count by type
239+
- Most recent occurrences
240+
- Affected endpoints
241+
- Filtering by exception type, endpoint, or time period
242+
243+
2. **Endpoint-specific view:** Click on any endpoint in the Overview, then navigate to
244+
the Exceptions tab: http://localhost:5000/dashboard/endpoint/:endpoint_id:/exceptions
245+
246+
This shows exceptions specific to that endpoint with:
247+
248+
- Stack trace visualization with syntax-highlighted code
249+
- Line numbers and function names
250+
- Ability to expand/collapse stack frames
251+
- Full file paths on hover
252+
253+
Exception Data Management
254+
^^^^^^^^^^^^^^^^^^^^^^^^^^
255+
256+
Exception data is automatically cleaned up as part of the database pruning schedule
257+
(see section 5 below). When you run database pruning, old exception occurrences
258+
are removed along with orphaned exception types and messages.
199259

200260

201261

0 commit comments

Comments
 (0)