@Monitor your page/component and service interface methods via JMX
Java Shell Groovy
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
src
wrapper
.gitignore
README.md
build.gradle
gradlew
gradlew.bat

README.md

Tapestry Monitoring

Tapestry Monitoring is intended to be a lightweight, unobtrusive method to introduce JMX performance metrics to any application built with the Apache Tapestry Web Framework.

javasimon was chosen as the basis for the metrics for it's ease of use, highly performant stopwatch functionality and ready to use MBeans.

Monitoring functionality can be added to any IOC Service or Component method. In the simplest case the @Monitor annotation can simply be added to the method and an MBean will automatically be created and registered using the tapestry-jmx MBeanSupport.

Example

package org.example.testapp.pages;
...
public class Index {

    @Monitor
    void onActivate(EventContext args) throws InterruptedException { }

    @Monitor
    Block onUpdateZone() {}
}

This creates two JMX MBeans

org.example.testapp:package=pages,name=Index,monitor=onActivate(EventContext),type=Monitor
org.example.testapp:package=pages,name=Index,monitor=onUpdateZone,type=Monitor

Connecting to your service via VisualVM with the MBeans Browser you will see your monitor hierarchy:

  • org.example.testapp
    • Monitor
      • pages
        • Index
          • onActivate(EventContext)
          • onUpdateZone()

Naming your Monitor

If you'd like a little bit of control over your object name you can provide a name to the @Monitor

package org.example.testapp.pages;
...
public class Index {

    @Monitor("load_index_page")
    void onActivate(EventContext args) throws InterruptedException { }

    @Monitor("update_user_section")
    Block onUpdateZone() {}
}

And now you can see

  • org.example.testapp
    • Monitor
      • pages
        • Index
          • load_index_page
          • update_user_section

Contributing a new naming strategy

Monitor names are generated by the [MonitorNameGenerator] mng. It is implemented as a Strategy Builder so that different strategies can be used per-class. The strategy match is done over the class hierarchy so you can choose to configure a default strategy by configuring a naming strategy for Object.

Example

 @Contribute(MonitorNameGenerator.class)
 public static void simpleNameGenerator(MappedConfiguration<Class, MonitorNameGenerator> configuration) {
     configuration.add(Object.class, new MonitorNameGenerator {

     public String getMonitorName(Class owningClass, Method method) {
         return owningClass.getName() + "." + method.getName();
     }

     public ObjectName getJmxObjectName(Class owningClass, Method method) {
         try {
             return new ObjectName("app:method=" + getMonitorName(owningClass, method));
         } catch (MalformedObjectNameException e) {
             throw new RuntimeException(e);
         }
     }
}

And VisualVM will show

  • app
    • org.example.testapp.Index
      • onActivate
      • onUpdateZone