This application provides a profiling mechanism for monitoring method execution times in a Spring Boot application. It leverages Spring Boot Actuator to expose profiling data through custom endpoints.
The profiling application is designed to help developers monitor and analyze the execution times of methods annotated
with a custom @ActuatorProfiling annotation. The profiling data is exposed through Spring Boot Actuator endpoints.
- Profiling of method execution times.
- Customizable profiling settings.
- Exposed endpoints for retrieving profiling data.
- Thread-safe handling of profiling data.
<dependency>
<groupId>io.github.litefunction</groupId>
<artifactId>spring-boot-starter-actuator-profiling</artifactId>
<version>1.0.0</version>
</dependency>
- Java 11 or higher
- Maven or Gradle
The application can be configured using properties in application.properties or application.yml.
profiling.actuator.maxCountList=100
profiling.actuator.enabler=trueAdding Profiling to Methods
add properties
management.endpoints.web.exposure.include=actuatorProfilingDetail,actuatorProfilingTo profile a method, simply annotate it with @ActuatorProfiling and optionally provide a name:
import com.lite.function.profiling.ActuatorProfiling;
public class ExampleService {
@ActuatorProfiling(name = "exampleMethod")
public void exampleMethod() {
// method logic
}
}Profiling data can be accessed through the provided Actuator endpoints.
Endpoint: /actuator/actuatorProfiling
"executingProfilingMethod": {
"exampleMethod": 403
}
exampleMethod - name from @ActuatorProfiling
403 - what happens during the execution of the last call
Endpoint: /actuator/actuatorProfilingDetail/{name}
{
"name": "exampleMethod",
"executingProfilingMethodVals": [
{
"delta": 506,
"localDateTime": "2024-06-23T14:28:39.523107"
},
{
"delta": 103,
"localDateTime": "2024-06-23T14:28:43.101866"
},
{
"delta": 904,
"localDateTime": "2024-06-23T14:28:44.564218"
},
{
"delta": 403,
"localDateTime": "2024-06-23T14:28:47.180746"
}
]
}