JBoss AOP Tracing
 


Summary
This article details the integration of JXInsight 4.1.1 with JBoss AOP via a custom trace extension that enables the delivery of an extensible application performance and test management solution for enterprise Java applications. The article is a follow-up to two previous Insight articles [1, 2] which discussed the cost benefit analysis of current instrumentation techniques and tools.

About JBoss AOP
A 100% Pure Java aspect oriented framework usable in any programming environment or tightly integrated with the JBoss application server. JBoss AOP is not only a framework, but also a prepackaged set of aspects that are applied via annotations, point cut expressions, or dynamically at runtime. Some of these include caching, asynchronous communication, transactions, security, and remoting.

About JXInsight
The leading Java application performance test and management solution (APTM), JXInsight, delivers an extensible distributed tracing, profiling and transaction event pattern analysis platform that enables development, test and operations staff to provide a comprehensive end-to-end user experience performance monitoring and management solution for mission criticial Java enterprise applications.



Introduction
AOP allows system developers to express the behavior of cross-cutting concerns in a modular fashion. AOP allows multiple concerns to be separately expressed but unified at compile or runtime within programs. Examples of cross-cutting concerns include remoting, replication, caching, configuration, instrumentation, security and synchronization. An AOP framework comes with a rich set of point cut expressions that can be used to define various join points in a program where aspects (advices) should be applied. A join point is a well defined place in the structure of execution flow of a program. The most common join points are method calls and executions. A point cut expression defines a set of join points where one or more advices can be attached. An advice is the behavior to execute at a join point. Attaching an advice is typically performed by the weaving of aspect oriented code into a program's code. Weaving can involve statically compiling the advice code with the program code, dynamically inserting aspects when code is loaded, or modifying the system interpreter to execute aspects.


Clock Application

The Clock example used in the initial tracing article [1] has had all explicit instrumentation calls removed. Instead instrumentation will be performed by JBoss AOP aspect oriented framework during the loading of the application classes.




JBoss AOP Integration
The integration of JXInsight with JBoss AOP is performed via the registration of JXInsight's TraceInterceptor in the jboss-aop.xml file along with the definition of point cut expression identifying locations in program structure where the tracing concern must be weaved into. The TraceInterceptor will generate profiled traces for intercepted invocations of methods and constructors. The traces generated by the interceptor can then be analyzed at various levels of detail across one or more servers in a cluster within the metrics, profile and timeline snapshots.



The trace extension can be configured to delimit a trace into distinct trace identifiers via a system property or Java bean property.
-Djxinsight.server.tracer.ext.jboss.aop.trace.identifiers=${jboss.aop.classname},${jboss.aop.operation}

Variables must be delimited by a comma. The list of possible variables for traces are:
${jboss.aop.codesource}
${jboss.aop.package}
${jboss.aop.classname}
${jboss.aop.fullclassname}
${jboss.aop.operation}
${jboss.aop.method}
${jboss.aop.signature}
${trace.timestamp}
${trace.object.hashcode}
${trace.thread.hashcode}
${trace.thread.name}

NOTE: The following system property needs to be set to ensure that load time weaving is not performed on JXInsight classes which are encrypted by default.
-Djboss.aop.exclude=com.jinspired


The following script was used to run the Clock example with the JXInsight JVMPI agent and JBoss AOP JVMTI agent on the Mac OSX with Java 5.

#!/bin/sh

JXINSIGHT=/Users/wlouth/IdeaProjects/jxinsight

DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:${JXINSIGHT}/bin/osx
export DYLD_LIBRARY_PATH

CLASSPATH=${JXINSIGHT}/testing/classes
CLASSPATH=${CLASSPATH}:${JXINSIGHT}/jbossaop/lib/javassist.jar:${JXINSIGHT}/jbossaop/lib/trove.jar:
CLASSPATH=${CLASSPATH}:${JXINSIGHT}/jbossaop/lib/concurrent.jar:${JXINSIGHT}/jbossaop/lib/jboss-common.jar
CLASSPATH=${CLASSPATH}:${JXINSIGHT}/release/current/lib/jxinsight-all.jar

echo ${CLASSPATH}

JBOSS_AOP_OPTS="-Djboss.aop.exclude=com.jinspired -Djboss.aop.include=com.jinspired.jxinsight.examples"
JBOSS_AOP_OPTS=${JBOSS_AOP_OPTS}" -Djboss.aop.path=${JXINSIGHT}/testing/jboss-aop.xml"

echo ${JBOSS_AOP_OPTS}

MAIN_CLASS=com.jinspired.jxinsight.examples.Clock
JVM_OPTS="-Xms64M -Xrunjdbinsight -javaagent:${JXINSIGHT}/jbossaop/lib/jboss-aop-jdk50.jar"

exec java ${JVM_OPTS} ${JBOSS_AOP_OPTS} -cp ${CLASSPATH} ${MAIN_CLASS}




JXInsight Enhanced Performance Analysis
Running the Clock example produces the following visualizations within the JXInsight application analysis and management console. Resource timing and usage measurements such as CPU, Service [3], Thread Waiting, Thread Blocking, Clock Adjusted, and GC [4], have been collected for each trace generated. JXInsight can also record statistics for object allocations within traces [5].

Note: This is only a small selection of the many application performance analysis and management features of JXInsight's award winning console.



From within the console, the class and interface inheritance hierarchy can be explored for classes and methods appearing in a profile snapshot. Outgoing and incoming call trees for JBoss AOP interceptions are also presented. Note: The JXInsight management console includes class and method classifications for JBoss AOP enhanced classes.




The JXInsight timeline analysis [6, 7, 8] of the Clock application provides a history of traced interceptions along with complete call stacks. With JXInsight's advanced timeline analysis that can span clusters or JVM processes application management staff have powerful visualizations that can relate trace events in time. The timeline visualization provides distributed concurrency analysis that can help detect resource bottlenecks caused by extreme peaks in workload.




Referenced Insight Articles
1. Instrumented Tracing
2. Integrating JXInsight with the Java Interactive Profiler (JIP)
3. JXInsight Clock Times and Service Times for Resource Concurrency Detection
4. Benchmarking and Garbage Collection
5. OutOfMemoryError's Are Not Always Caused By Memory Leaks
6. Timeline Analysis and Execution Behavioral Patterns
7. Performance Problems in mixing OLAP and OLTP Workloads
8.
Tracing and Profiling Distributed WorkManagers


William Louth, JXInsight's Product Architect