Logging Errors to the Database(design page)

Abstract :

Log uncaught exceptions to a database table, along with associated metadata (date/time, user, page and/or service, stack trace summary, unique identifier) and provide this information to users in the default error handler so that they can provide a specific error log id along with their bug report. Provide tools to mine this database table to find patterns in error messages, users who frequently hit problems, and to assist in proactively improving the system regardless of whether or not users are reporting their errors.

Implementation:

This idea is already implemented in Haiti which includes creating two tables

The exception_log table lists summary information and metadata about the overall exception:

exception_log (
 id,
 -- Primary key of the table exception_class,
 -- The specific type of exception that was thrown (eg. NullPointerException) message,
– The exception message ( eg. throwable.getMessage() ) exception_datetime,
 -- Timestampfor the exception user_id
 -- References user to store which user experienced the error)

The exception_log_detail table lists the specific stack trace information that is relevant. This might be restricted on only those parts of a stack trace that provide useful, actionable information (for example, only those classes that match a certain pattern, or only those lines of a stack trace that contain certain information):

exception_log_detail (  id,             

    – Primary key of the table  exception_log_id,  

– References the exception_log table above  file_name,     

     – The filename extracted from the stack trace  class_name,     

    – Theclass name extracted from the stack trace  class_name,   

      – The method name extracted from the stack trace  line_number    

     – The line number extracted from the stack trace)
the main thing is to fill these two tables every time an unhandled exception occurs. Since we are using jsp's , every time there is an unhandled exception the default error page is shown (in this case it is ErrorHandler.jsp). Before we display this page , we need to take the exception object and create an entry in the above  two tables.
In order to do that we would have to create the following things exception.hbm.xml , exceptionDAO entity , exceptionLogDao entity , hibernateExceptionDao, exceptionHandlerService which contains methods to store the data in the tables.
So the ErrorHandler.jsp call the exceptionHandlerService to store the details about an exception in the above defined table. We can use the strace element in java , which would give us the name of the class, name of the file , name of the method. By using the smart matching we can include more details in the above tables.
After recording the details in the above tables , the ErrorHandler.jsp should show the message and a link to "More Details".
When the user clicks on this link , a pop up should be displayed which provides a summary of the exception based on what was recorded in the tables above.
We can also provide the admin with the UI which would help him do the following

  1. An interface that allows for the exception log to be queried by user, datetime, exception class, frequency . This page would be presented as a search page , where the user can select any parameters , the module will generate the dynamic query which would be executed on the above tables and the results would be shown in the same pag.

  1. An ability to view the specifics of a particular exception and to link it to a ticket and/or mark it as resolved when the underlying code problem has been fixed  when we are displaying the list of exceptions as list in the search page , for every exception we should have an option there to link it with the ticket.We can access the jira vis RPC , i dont know much but certainly we can use jira programatically   (http://confluence.atlassian.com/display/JIRA/JIRA+RPC+Services).                                                              

  2. An ability to delete all exception logs either by date range or by exception class. We can take the date from the user and delete all the records from the db

  1. A handful of summary reports which are emailed to a configurable list of addresses on a scheduled basis that report on:

    1. Most common errors reported which are not yet resolved

    2. All errors reported during the last period (eg. last day, last week, etc depending on frequency of the report)  To implement this feature the admin need to set the list of recipients who would like to receive the report as well as he can even configure the criteria.At the backend we would need to get all the reports based on the criteria set , retrieve the list of recipients and send them an email. The reports can be created using jasper reports.

Time Line:

I have defined the goals set for me and the mid term evaluation can include goal 1, 2

Final evaluation : 3, 4

** +5 are the buffers in case of any road block

SMART Goal #1:Get the basic structure of the module

  • Measure: Getting the service to add data into the tables and testing the service methods.

  • Create the tables in the hbm.xml.

  • Create the related entities

  • Create HibernatexxxDao to put the data in the db

  • Create  business methods in it where we can include logging of errors  if any exception occurs.

  • Modifying the Errorhandler.jsp to log in the errors first and then show the user the exception message and "More Details" link.

  • Creating a pop up to show the details of the error.

  • Deadline: 5th June.+ 5

SMART Goal #2:Design the search page

  • Measure: Add more business methods to the existing service and get the UI for admin

  • Build a search page with parameters so that the admin can search the exception based on frequency , exception_class , user , etc

  • Add the method for searching in the service class.

  • An ability to delete all exception logs based on date or exception class

  • Deadline:25th June.+5

SMART Goal #3:Linking the ticket with JIRA

  • Measure: Admin can link a particular exception to jira ticket.

  • Research on how to interface with jira

  • Establish the communication with it and try to link the exception with the jira ticket

  • Deadline: 13th July+5

SMART Goal #4:Providing Report Support

  • Measure: Provide the page where the admin can configure the address for receiving the reports and also the criteria for generating reports.

  • Generating the reports based on the criteria set by the admin

  • Deadline: 13th August.