Measure and log API execution time in Spring Boot with one annotation, automatic setup, and configurable thresholds.
Warning
Supports Spring Boot 4+ with Java 21+
Spring Boot 3.x and Java versions below 21 are not supported.
- Track execution time using one annotation:
@TrackExecutionTime - Web context logging: HTTP method + path + query string
- Endpoint-level logging for request-driven flows
- Configurable output unit and log threshold
- Autoconfiguration when dependency is present
Add this dependency in your application pom.xml:
<dependency>
<groupId>io.github.sathwikhbhat</groupId>
<artifactId>api-execution-tracker</artifactId>
<version>1.0.0</version>
</dependency>Add this dependency in your application build.gradle.kts:
implementation("io.github.sathwikhbhat:api-execution-tracker:1.0.0")Note
You can also find this dependency and usage details for other build tools (sbt, ivy, grape etc.) on the Maven Central Repository page for API Execution Tracker.
Annotate a class or specific methods:
import io.github.sathwikhbhat.apiexecutiontracker.annotation.TrackExecutionTime;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
@RestController
@TrackExecutionTime
public class DemoController {
@GetMapping("/hello")
public String hello() {
return "Hello";
}
}Property prefix: tracker
tracker:
enabled: true
time-unit: milliseconds
threshold: 0| Property | Type | Default | Description |
|---|---|---|---|
tracker.enabled |
boolean |
true |
Enables/disables tracking |
tracker.time-unit |
seconds | milliseconds | microseconds | nanoseconds |
milliseconds |
Output time unit |
tracker.threshold |
long |
0 |
Minimum duration to log, interpreted in tracker.time-unit |
Important
tracker.threshold always uses the same unit as tracker.time-unit.
By default, tracker.time-unit is milliseconds, so the threshold is in milliseconds.
If you set tracker.time-unit to seconds, the threshold will be read in seconds.
When called during an HTTP request:
GET /api/v1/users executed in 12 milliseconds
- Logging output is request-context driven.
- If an annotated method runs during an active HTTP request (including service methods called by controllers), logs show the endpoint path (for example,
GET /api/v1/xyz) instead of the Java method signature. - In practice for request-driven usage, expect endpoint-based logs rather than per-method signature logs.
- Execution time is logged even when the request flow throws an error/exception.
For internals and contribution workflow, see DEVELOPER_README.