Announcement Announcement Module
Collapse
No announcement yet.
AMS - Why no thruput metrics for @Transactional? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • AMS - Why no thruput metrics for @Transactional?

    I am preparing for a large-scale scalability test of a Flex 3/LCDS 2.6/Spring 2.5 financial services application. I thought AMS would be a great way to monitor and record the throughput of the back-end Spring-based services during the load test.

    I'm evaluating AMS for the first time and I have a few questions.

    1) How come my Spring-managed services marked with @Transactional annotations don't have any "Throughput" metrics in AMS? The operations of these services show up in AMS as "Spring Service Methods" so out-of-the box I can monitor the execution time of the these operations. All good. Problem is I also want to monitor the calls/second of these operations (not really a "rocket science" requirement). Looking at the AMS documentation it appears that AMS services of type "Spring Service Method" only have "Performance" metrics by default. Grr.

    2) What's the easiest way to monitor the calls/second of my services? Is there another Spring annotation I can use to provoke the AMS agent to collect throughput metrics or do I have to implement my own custom metrics and expose them as @ManagedMetrics?

    Any help from die hard AMS experts would be much appreciated as this is a neat product that I'd like to use more.

  • #2
    1) How come my Spring-managed services marked with @Transactional annotations don't have any "Throughput" metrics in AMS?
    There isn't any technical reason they aren't there. I'll open up an enhancement request to get them added.

    2) What's the easiest way to monitor the calls/second of my services? Is there another Spring annotation I can use to provoke the AMS agent to collect throughput metrics or do I have to implement my own custom metrics and expose them as @ManagedMetrics?
    Disclaimer - We are working on solidifying the monitoring API so we can expose it for you to code against in a future release. Until then, here is how you might make this work in the current release (note that b/c we haven't published the API yet, none of the code below is documented and most definitely subject to change).
    Code:
    ...
    import com.springsource.management.agent.bootstrap.Bootstrap;
    import com.springsource.management.agent.monitoring.MonitorInstanceKey;
    import com.springsource.management.agent.monitoring.MonitorRepository;
    import com.springsource.management.agent.monitoring.PerformanceMonitor;
    import com.springsource.management.agent.monitoring.proxy.MethodNameFormatter;
    
    @Transactional
    @ManagedResource(objectName = "spring.application:application=swf-booking-mvc,type=BookingService,name=jpaBookingService")
    public class JpaBookingService implements BookingService {
    ...
    
    @ManagedMetric(category = MetricCategory.THROUGHPUT, metricType = MetricType.GAUGE)
    public double getBookingsSavedPerSecond() {
       //Performance Monitors for stereotyped components are named by this MethodNameFormatter,which adds in the signature to support overloading.  
       //Other monitors created by instrumented jars typically just use method name (i.e. "saveBooking")
       final String methodName = ((MethodNameFormatter) Bootstrap.getContext().getBean("methodNameFormatter"))
    		    .parse(getClass().getMethod("saveBooking", Booking.class));
       
       //Look up the performance monitor for the saveBooking method of this instance of JpaBookingService
       final PerformanceMonitor saveBookingMonitor = ((MonitorRepository) Bootstrap.getContext().getBean(
    		    "monitorRepository")).getPerformanceMonitor(new MonitorInstanceKey(methodName, this));
       
       final Measure throughput = saveBookingMonitor.getThroughput();
       //Default measurement is 1/ms. Convert to 1/s
       return throughput.convertTo(BaseUnit.ONE.divide(BaseUnit.SECOND)).doubleValue();
    }
    }
    Essentially, you have to expose a separate MBean containing the metrics yourself using @ManagedMetric. However, you can get access to the PerformanceMonitors we are already using to keep track of your stereotyped components, so you don't have to implement the monitoring yourself.

    As you may know, autodetection of JMX annotations does not work against interface-based proxies (see Spring ref manual). Therefore, you may want to create a wrapper class to expose your @ManagedMetrics. Otherwise, you need to do at least 2 things to proxy the target class of your @Transactional object using CGLIB:
    1) use <tx:annotation-driven proxy-target-class="true" />
    2) Add a management.config file to your application classpath where monitor.proxyTargetClass=true. See https://www.covalent.net/resource/do...iguration.html for additional info on configuring AMS.

    Let me know how this works for you.

    Thanks,
    Jennifer

    Comment

    Working...
    X