steve souza

Ranch Hand
+ Follow
since Jun 26, 2002
Merit badge: grant badges
For More
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by steve souza

Automon is an open source project that combines the power of AOP (using AspectJ) with any monitoring or logging tools you already use to declaratively monitor your Java methods for performance and any exceptions they may throw.

Automon let’s you control ‘what’ you want to monitor indepedently from the tool that you use to monitor (‘how’). This makes it easy to swap between monitoring tools such as Jamon, Yammer metrics, New Relic, StatsD, JavaSimon or your own implementation. Automon defers to these tools to time methods and count exceptions.

The other powerful part of Automon is that it uses AspectJ at runtime to allow you to declaratively determine what to monitor via an xml configuration file. You do this by defining AspectJ ’pointcuts’ in the config file. 'Pointcuts' match the code you want to monitor, and work similarly to regular expressions. For example to monitor your Rest api you might specify the following pointcut that will monitor all public methods in a rest package:

For more information see The best way to get started is to look in the examples directory available here: It is also available on Maven.
9 years ago
Note Spring 4.1 now has exception tracking added to JamonPerformanceMonitorInterceptor
9 years ago
Another thing I should mention. Just yesterday I released jamon 2.78 which allows you to view any of your monitored jvms with the jamon war. These jvms could be part of a distributed application or part separate java apps within your organization. Check it out! You can download directly or via maven.
9 years ago
You will also have to enable the buffer listener for any place you would like to see the exceptions. This is from my code, so something like this should work if you call it from your constructor. This is the equiavlent of what the video shows you how to do in the gui, bu because you don't want to do this via the gui each time you start the server this is a better choice.

9 years ago
you should also see a jamon label with the specific exception too: java.lang.RuntimeException
9 years ago
Ok, there is some miscommunications. You are looking in the wrong place. The place where you are looking for exceptions is a deprecated way to see them. Click on the com.jamonapi.Exceptions you mention (The blue square under the Monitor column in jamonadmin.jsp). Here you can add a jamonlistener FIFOBuffer. Probably good to watch one of these videos to see how that is done....

Some overlap, but here is another one...

9 years ago
Also, unless you think you will use this, I would just get rid of it...

logger.trace("JAMon performance statistics for method [" + name + "]:\n" + monitor);
9 years ago
You will have to give me more information. Is it being called at all? Or is JamonPerformanceMonitorInterceptor still being called. You could write the class name out to see which is called. Are you seeing the timing stats and not the exception information or are you not seeing either? Maybe make the jamon label (name variable) slightly different (i.e. nam+="TESTING") to make sure your class is being called. Make sure the methods you are calling are throwing exceptions!! You could even explicitly throw one in the try block just to see what happens. Also, post your spring xml file.

Try all that and give me some more information.
9 years ago
Alternatively, you can inherit from JamonPerformanceMonitorInterceptor and add the simple code that it would take to track exceptions. The following untested code does that.

It will count overall exceptions 'com.jamonapi.Exceptions' (general), and specific exceptions (FileNotFoundException, IllegalArgumentException etc). In addition you can look at the stacktraces in the jamon web app if you enable the FIFOBuffer. The stack trace can be displayed under the spring method name, and the general and specific exceptions.

Change to.
9 years ago
Unfortunately Springs JamonPerformanceMonitorInterceptor does not track exceptions. JamonAspect which is part of the jamon jar does though. Here is more information about it:

Here is a sample spring xml that uses JamonAspect:

If that doesn't work for you it would be easy copy the JamonPerformanceMonitorInterceptor code and have it track exceptions. I have been meaning to do that anyway.

I notice you have older versions of much of your software stack (jdk, spring). I haven't tested jamon with these versions of software.

9 years ago
not calling 'stop' has no effect on memory in jamon. The only result is that the 'active' number will continually climb, but the objects themselves will be properly garbage collected when the code goes out of scope.
Ok, I know PreparedStatements are the way to go in general and I'm a big fan. However, the more I think about it it I think it would be quite difficult to write a generalized query engine that would work for any select statement with any backend where users can input any sql. For example the following are possible and of course any other selects the user might want to input.

select col, sum(col), count(col), (select max(age) from companies) from table where name in (select name from archivetable where name in ('joe', 'jim', 'jon'))

Orders.OrderTime AS LatestOrderTime, 'Q1'
(SELECT ID FROM dbo.Orders WHERE CustomerID = Customers.ID))
AS TotalItemsPurchased
dbo.Customers INNER JOIN dbo.Orders
ON Customers.ID = Orders.CustomerID
Orders.ID IN (SELECT ID FROM LatestOrders)

Good idea. If possible I would rather use a well tested framework than to create my own. Being as many people have to have dynamic sql in their applications I was hoping there was something already out there. And it isn't just about sql injection. It is also about disallowing dialect specific commands such as drop database, add user etc.
I know PreparedStatements are the best practice for not allowing SQL injection, but in my case I have to come up with a dynamic query screen that allows users to enter queries that return various ResultSets of their choosing. Is there a java library that protects against SQL injection for non-PreparedStatements? Ideally it would be configurable to go beyond that and allow me to specify things like how many tables are allowed in the query, whether deletes/updates/inserts are allowed, and how many tables can be used in a join etc.
Yes, but it would be better not to do this in code, but make it a property that can be changed. If you don't have this then you can put it in your code that returns connections.
12 years ago