Context In Time
 


Introduction
The ability to offline inspect object state and other contextual information associated with business transactions is extremely useful when performing post problem analysis on an reported application error or performance incident. This article introduces the new object field state graph recording capabilities available in the latest JXInsight 4.2 early access builds that enables application support staff to accurately perform root cause analysis.


Sample Application
The application used to demonstrate the object state recording capabilities is the Hotel Booking demo that is distributed with the JBoss Seam 1.0. The Booking application demonstrates the use of JBoss Seam in a Java EE 5 environment with transaction and persistence context management handled by the EJB container. The following web page is the entry point into the use case to be tested. Prior to the clicking of the "View Hotel" URL timeline monitoring was enabled within the JXInsight application management console. A timeline snapshot was taken after the completion of the request.

Note: The timeline snapshot used in this article is distributed with the latest JXInsight 4.2 early access builds. The snapshot is named journalling-jboss-seam-sample-timeline.snp and is located in the snapshots sub directory of the management console installation.




Timeline Analysis
The table shown below lists the traced executions during the processing of the HTTP request. Within the timeline graphic the complete request processing time is visually partitioned for each trace group (Servlet, JNDI, EJB, and JDBC). The basic container and component request processing steps traced during the test execution are:

1 Dispatch HTTP Request to FacesServlet
1.1 JNDI lookup for HotelBooking bean (Stateful Session EJB)
1.1.1 Create EntityManager via EntityManagerFactory
1.2 Call selectHotel() on the HotelBooking bean
1.2.1 Call getSelectedHotel() on the HotelSearching bean (Stateless Session EJB)
1.2.2 Call merge() on the EntityManager with the selected Hotel bean (Entity EJB)





Object State Memento
The standard JXInsight trace extensions capture contextual information for each traced execution. This includes target, arguments, result and exception. The contextual information can be inspected via navigation of the object field state graph recorded within the associated memento object held within the timeline model. The level of detail recorded is similar to that found in standard Java code debuggers but without the associated overhead of running the JVM in debug mode continuously.

To display a memento for a selected row in the traces table simply click on the table view's drop down menu (top right hand corner of view) and select the "Open Memento" menu item. A tree view of the object field state graph for the contextual objects mentioned above will be displayed in a dialog window.

HTTP Request [1040]
The tree view below shows the argument field state graph for the servlet request intercepted via the JXInsight ServletFilter trace extension. Note that Class metadata is recorded within the memento allowing for object reference classification. Within the memento model it is possible to interrogate the value of session attributes.




JNDI Lookup [1044]
The memento below shows the object field state graph of the returned object (result) from the JNDI lookup call. The hashCode attributed listed for every object reference is the one returned via a call to System.identityhashCode(). This attribute value aids in manually comparing the equality of object references.




Create EntityManager [1047]
The memento recorded for the traced createEntityManager() call shows the use (instance field reference) of a Hibernate SessionFactoryImpl instance within the EntityManagerFactoryImpl object. Note the recording of dynamic state information such as "open=true" within the returned EntityManager instance.




Select Hotel [1049]
JBoss container related information can also be inspected offline. Here the tree view shows the AOP (Aspect Oriented Programming) runtime and meta state information for the HotelBooking object reference post the invocation of selectHotel(). Note the returned value is a string value used in determining the next appropriate view state transition.




Selected Hotel [1053]
Inspecting the returned state of the Hotel entity to be rendered on the request web page is extremely easy within the memento tree view.




Merge Hotel[1055]
By comparing the hashCode value of the argument and result contextual objects it can be seen that the object returned via the merge() call is a new instance of the Hotel entity but with the same data field values. Note the system identity hashCode of the Hotel argument equals the hashCode of the returned object in the previous step.




System Properties
The following system properties control the amount of contextual information collected and the depth of the object field state graph.

# the contextual information added to the trace memento
jxinsight.server.profiler.timeline.trace.memento.args.include=true|false (default false)
jxinsight.server.profiler.timeline.trace.memento.exception.include=true|false (default true)
jxinsight.server.profiler.timeline.trace.memento.result.include=true|false (default false)
jxinsight.server.profiler.timeline.trace.memento.target.include=true|false (default false)

# the maximum depth of the object graph
jxinsight.server.cmdb.ext.reflect.maxdepth=8

# the number of array elements recorded
jxinsight.server.cmdb.ext.reflect.field.array.maxlength=132

# should fields with null values be recorded
jxinsight.server.cmdb.ext.reflect.field.nulls.include=false

# should arrays with null elements be recorded
jxinsight.server.cmdb.ext.reflect.field.array.nulls.include=false

# should the internal fields of the java.lang.String class be introspected
jxinsight.server.cmdb.ext.reflect.field.string.fields.include=false

# filter the field state inspection by package and classname
jxinsight.server.cmdb.ext.reflect.field.types.excludes=<classname-prefix-1,classname-prefix-2,...>
jxinsight.server.cmdb.ext.reflect.field.types.includes=<classname-prefix-1,classname-prefix-2,...>

# truncate the length of strings added to the memento
jxinsight.server.cmdb.ext.reflect.field.string.maxlength=512

# limit the generation of memento models in the timeline to those traces exceeding a clocktime (microseconds).
jxinsight.server.profiler.timeline.trace.memento.filter.clocktime=0

# filter the generation of memento models in the timeline based on matching trace string
# both properties take a comma separated string value consisting of trace identifiers prefixes to be excluded or included.
# to limit the generation of memento models to ejb traces specify -Djxinsight.server.profiler.timeline.trace.memento.filter.identifiers.excludes=${ejbobject,${ejbhome
jxinsight.server.profiler.timeline.trace.memento.filter.identifiers.includes=
jxinsight.server.profiler.timeline.trace.memento.filter.identifiers.excludes=


William Louth, JXInsight's Product Architect