Hands-On High Performance with Spring 5
by Chintan Mehta, Subhash Shah, Pritesh Shah, Prashant Goswami, Dinesh Radadiya
Custom monitoring interceptor
PerformanceMonitorInterceptor is a very basic and simple way to monitor the execution of our method time. However, most of the time we would need more a controlled way to monitor the method and its parameters. For that, we can implement our custom interceptor, either by extending AbstractMonitoringInterceptor or writing around advice or a custom annotation. Here we will write a custom interceptor extending AbstractMonitoringInterceptor.
Let's extend the AbstractMonitoringInterceptor class and override the invokeUnderTrace method to log the start, end, and duration of a method. We can also log a warning if the method execution lasts more than 5 milliseconds. The following is the code sample for the custom monitoring ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access