Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Exception tracking to JamonPerformanceMonitorInterceptor [SPR-12068] #16684

Closed
spring-projects-issues opened this issue Aug 5, 2014 · 8 comments
Assignees
Labels
in: core type: enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Aug 5, 2014

Steve Souza opened SPR-12068 and commented

JamonPerformanceMonitorInterceptor currently grabs the method name and tracks performance of methods.

It would nice to add exception tracking to this. The idea is that if any of the methods monitored by JamonPerformanceMonitorInterceptor throw an exception jamon can count them. This would entail counting 2 things.

  1. The number of overall exceptions using a jamon lable like: com.jamonapi.Exceptions
  2. The number of specific exceptions using the exception class name as the lable. Examples are: java.io.EOFException, and javax.sql.rowset.serial.SerialException. But they could be anything.

This is very useful for tracking problems that are occurring in a system.

In addition if the user tracks the N most recent exceptions (via a JAMon buffer listener) the full stack traces would be viewable via the jamon war. The stack traces are also visible via the monitor associated with the method which is already available in JamonPerformanceMonitorInterceptor.

Note these capabilities only entail adding a few lines of code. Other jamon monitoring modules already use this approach. Note I am the author of jamon and could add this as a pull request if you would like to include it.

Here is an example of what the data would look like in the jamon war. The screens include both the exception count as well as viewing full stack traces (however i am not proposing the arguments capability that is discussed in the link)

http://jamonapi.sourceforge.net/spring_aop_monitoring.html#whatdoesitlooklike

Cheers,
Steve


Affects: 4.1 RC1

Referenced from: commits 51e4b07

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Aug 5, 2014

Juergen Hoeller commented

This sounds fine, and a pull request would be much appreciated!

Juergen

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Aug 5, 2014

Steve Souza commented

I checked out the code, but I am unable to build the project.

I followed the instructions on this page. https://github.com/spring-projects/spring-framework#building-from-source

I use max osx. The following is my jdk info:
echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home
Macintosh-c8bcc88febc6:spring-framework stevesouza$ java -version
java version "1.8.0_20-ea"
Java(TM) SE Runtime Environment (build 1.8.0_20-ea-b23)
Java HotSpot(TM) 64-Bit Server VM (build 25.20-b22, mixed mode)

I get the following error when i run ./gradlew install

Executing task ':spring-core:compileJava' (up-to-date check took 0.332 secs) due to:
No history is available.
All input files are considered out-of-date for incremental task ':spring-core:compileJava'.
Compiling with JDK Java compiler API.
/Users/stevesouza/gitrepo/spring-framework/spring-core/src/main/java/org/springframework/util/concurrent/SettableListenableFuture.java:170: warning: [unchecked] unchecked cast
return (T) value.get();
^

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Aug 5, 2014

Steve Souza commented

I should add that this was also in the output....In particular the reference to '-Werror'

All input files are considered out-of-date for incremental task ':spring-core:compileJava'.
Compiling with JDK Java compiler API.
/Users/stevesouza/gitrepo/spring-framework/spring-core/src/main/java/org/springframework/util/concurrent/SettableListenableFuture.java:116: warning: [cast] redundant cast to T
return (T) this.listenableFuture.get();
^
where T is a type-variable:
T extends Object declared in class SettableListenableFuture
/Users/stevesouza/gitrepo/spring-framework/spring-core/src/main/java/org/springframework/util/concurrent/SettableListenableFuture.java:170: warning: [unchecked] unchecked cast
return (T) value.get();
^
required: T
found: Object
where T is a type-variable:
T extends Object declared in class SettableTask
error: warnings found and -Werror specified
1 error
2 warnings

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Aug 7, 2014

Steve Souza commented

Ok, I made the changes, and added tests. Here are the changes: stevensouza@b892c50

Let me know if anything else needs to be done.

A couple notes.

  • I was unable to compile spring, so I made the changes in my own project and copied the files over when done.
  • I was able to run my unit tests successfully and also tested it in Spring by adding it to my applicationContext.xml and it worked.
  • However, because I couldn't get Spring to compile/test the code I didn't run the Spring test suite.
  • One thing I wasn't sure of is if the jamon jar is available as a jar in your test suite. It would need to be.
  • Although not required jamon 2.78 is the latest version so if it has to be added to your build file that should be used (it is in maven).

Here is what the applicationContext entry would look like. Note I disabled exception tracking by default so as not to change the current users behaviour (although I think having it enabled is a better default). The property below 'trackExceptions' controls this behaviour.

<bean id="jamonMonitoringAspectInterceptor" class="org.springframework.aop.interceptor.JamonPerformanceMonitorInterceptor">
    <property name="trackAllInvocations" value="true"></property>
    <property name="trackExceptions" value="true"></property>
</bean>

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Aug 17, 2014

Steve Souza commented

Hi, just wanted to check on the status/next steps for this change.

Thanks,
Steve

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Aug 18, 2014

Steve Souza commented

Also, this would be an easy port to other versions of spring as the change is isolated to JamonPerformanceMonitorInterceptor and that file hasn't changed in a while.

Steve

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Aug 18, 2014

Juergen Hoeller commented

Added for 4.1 now, as fixed behavior. I don't see backwards compatiblity arguments here, at least not for a 4.1 release... More importantly, the other interceptors that JAMon ships track exceptions by default as well, so we should be consistent with those.

I'm afraid we won't be backporting this since we're expecting people to upgrade rather ambitiously these days... 4.1 immediately supersedes the 4.0.x line in that respect. 3.2.x is in rather strict maintenance mode already, and we are not maintaining older branches at all anymore.

Juergen

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Aug 18, 2014

Steve Souza commented

Ok, makes sense. Thanks Juergen. I looked at the code and like that exception tracing is always enabled. It will be a nice surprise for developers that use JamonPerformanceMonitorInterceptor when they see Exception tracing magically appear for them when 4.1 is released.

@spring-projects-issues spring-projects-issues added type: enhancement in: core labels Jan 11, 2019
@spring-projects-issues spring-projects-issues added this to the 4.1 GA milestone Jan 11, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: core type: enhancement
Projects
None yet
Development

No branches or pull requests

2 participants