Question

How to measure the performance of all the action classes of struts 1.2 application?

I am looking for a way to collect performance statistics on how long each action took.Any idea if this can be done? A piece of code would be greatly appreciated?

Was it helpful?

Solution

Easy and pure-Java EE option: you can set a Filter in front of the struts servlet (struts 1) that just hands it the control, but stopwatches its execution time. Some doc on filters:

http://www.oracle.com/technetwork/java/filters-137243.html

Aspect oriented solutions:

If your applications packs Spring framework, you can do the same thing in much a fine grain scale by setting some aspect that measures the execution time of each service/dao/etc.

Instrumenting classes in Spring: http://docs.spring.io/spring/docs/current/spring-framework-reference/html/overview.html

And, if you want to set an aspect straight on your Action classes, you can set an agent class in your JVM startup (always if your operations people allow you) and instrument them. Here is an example of a DIY instrumented performance reporter:

http://chimpler.wordpress.com/2013/11/05/implementing-a-java-agent-to-instrument-code/

Please note that the bit with the -javaagent swith for the JVM must be in the startup of your application server - you may have to give sound arguments for it to your operations people, as always when you propose some change to production environment config

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top