- Add jamon.jar to the application classpath
- Use JAMon's datasource proxy to monitor SQL
- Implement the JAMonServletFilter to monitor page hits
- Leverage Spring AOP via Spring's JamonPerformanceMonitorInterceptor class to monitor services
- Add a Spring filter to monitor Grails controllers.
We'll add this to the doWithSpring closure. First we'll define a jamonInterceptor bean. It accepts a prefix attribute, which can be set to anything you like:
def doWithSpring = {
jamonInterceptor( org.springframework.aop.interceptor.JamonPerformanceMonitorInterceptor, true, true ) {
prefix="Class."
}
}
def monBeanNames = application.serviceClasses.collect{ it.shortName[0].toLowerCase() + it.shortName[1..-1] }
if (monBeanNames) {
autoProxyCreator( org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator ) {
proxyTargetClass="true"
interceptorNames=["jamonInterceptor"]
beanNames=monBeanNames as String[]
}
}
Put it all together, it looks like this:
def doWithSpring = {
def monBeanNames = application.serviceClasses.collect{ it.shortName[0].toLowerCase() + it.shortName[1..-1] }
if (monBeanNames) {
jamonInterceptor(org.springframework.aop.interceptor.JamonPerformanceMonitorInterceptor, true, true) {
prefix="Class."
}
autoProxyCreator(org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator) {
proxyTargetClass="true"
interceptorNames=["jamonInterceptor"]
beanNames=monBeanNames as String[]
}
}
In part 4 of this series, we'll complete task #5 and deploy our JAMon plugin.