简体   繁体   中英

Spring Boot defines REST Interface, want to time Request - Response

I'm using Spring Boot to define a REST Interface and want to define a metric that times Request to Response.

I could just start the timer, when the function is called and stop it at the return, but that seems not right, since I don't know when Spring sends out the actual message. Is this possible without messing with the actual code behind Spring?

We use Perf4J to time operations. Our application is structured as Filters -> Controller -> Business Logic -> Data Access -> Data Store . In the first year we used to log response times for every request at both the Filter and Business Logic layers. However, we did not see too much difference in times recorded at these two layers (less than 10%) so we have standardised on timing just the business logic operations.

Try to read more on Spring MVC Interceptors. Quite a good introduction and example can be found here: http://www.journaldev.com/2676/spring-mvc-interceptors-example-handlerinterceptor-and-handlerinterceptoradapter

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM