What package is the actuator base path stored?

Tags: , , ,



I am looking to log all of my Spring-Boot project’s request. My pointcuts work fine for my programming, and I can get the sub paths, but not the base actuator path.

  • com.example.demo...(..) – This works for my programming

  • org.springframework.boot.actuate...(..) – This works for paths like http://localhost:8080/actuator/info or http://localhost:8080/actuator/health. This works

None of my pointcuts work for just “http://localhost:8080/actuator” with no other path. I have tried looking through the org.springframework.boot.actuate paths and through the actuator jar to see if I missed a path, but I cannot find anything. I’ve looked through org.springframework.boot.actuate.autoconfigure, but that doesn’t seem to be right.

I just need to capture it and log the request, but I cannot find http://localhost:8080/actuator

Thanks

Answer

To save someone else the trouble.

The class that serves http://yourhost:8080/actuator base path is

https://github.com/spring-projects/spring-boot/blob/0a4c26532dff6f3fa1bf6d2e1c2a74549191117a/spring-boot-project/spring-boot-actuator/src/main/java/org/springframework/boot/actuate/endpoint/web/servlet/WebMvcEndpointHandlerMapping.java

The programming that handles the page, is around line 76 (in current version). Unfortunately, it is an inner class that is not public and Spring AOP doesn’t seem to be able to find it.

So, if you are able to, probably the Filter answer above is good, but doing Spring AOP cannot go against that class directly. Unfortunately, the Filter may not work in my situation, but someone else might be glad for this information.



Source: stackoverflow