Annotation Interface MonitoredMicroservice
@Target(TYPE)
@Retention(RUNTIME)
@Documented
@Import(MonitoringAutoConfiguration.class)
public @interface MonitoredMicroservice
Enables full monitoring for a Spring Boot microservice with a single annotation.
Place this annotation on the main @SpringBootApplication class.
The monitoring starter will auto-register the service, intercept endpoints,
buffer metrics, and flush them in batches to the monitoring server.
All annotation attributes act as defaults: they are applied first
and can be overridden via application.yml (e.g. monitoring.server-url).
Usage example:
@SpringBootApplication
@MonitoredMicroservice(
name = "order-service",
serverUrl = "http://monitoring-server:8080",
sla = @Sla(maxResponseTimeMs = 500, uptimePercent = 99.9),
trackAllEndpoints = true
)
public class OrderServiceApplication {
public static void main(String[] args) {
SpringApplication.run(OrderServiceApplication.class, args);
}
}
-
Required Element Summary
Required Elements -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionlongHow often buffered metrics are flushed to the server, in milliseconds.intMaximum number of metrics to buffer before triggering an immediate flush.Base URL of the monitoring server.SLA parameters for this service.booleanWhentrue, all@RestControllermethods are intercepted automatically without requiring@MonitoredEndpointon each method.
-
Element Details
-
name
String nameLogical service name registered in the monitoring server. -
serverUrl
String serverUrlBase URL of the monitoring server. Overridable viamonitoring.server-url.- Default:
"http://localhost:8080"
-
sla
-
trackAllEndpoints
boolean trackAllEndpointsWhentrue, all@RestControllermethods are intercepted automatically without requiring@MonitoredEndpointon each method. Overridable viamonitoring.track-all-endpoints.- Default:
false
-
bufferFlushIntervalMs
long bufferFlushIntervalMsHow often buffered metrics are flushed to the server, in milliseconds.- Default:
5000L
-
bufferMaxSize
int bufferMaxSizeMaximum number of metrics to buffer before triggering an immediate flush.- Default:
100
-