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
    Modifier and Type
    Required Element
    Description
    Logical service name registered in the monitoring server.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    long
    How often buffered metrics are flushed to the server, in milliseconds.
    int
    Maximum number of metrics to buffer before triggering an immediate flush.
    Base URL of the monitoring server.
    SLA parameters for this service.
    boolean
    When true, all @RestController methods are intercepted automatically without requiring @MonitoredEndpoint on each method.
  • Element Details

    • name

      String name
      Logical service name registered in the monitoring server.
    • serverUrl

      String serverUrl
      Base URL of the monitoring server. Overridable via monitoring.server-url.
      Default:
      "http://localhost:8080"
    • sla

      Sla sla
      SLA parameters for this service.
      Default:
      @com.nmontytskyi.monitoring.annotation.Sla
    • trackAllEndpoints

      boolean trackAllEndpoints
      When true, all @RestController methods are intercepted automatically without requiring @MonitoredEndpoint on each method. Overridable via monitoring.track-all-endpoints.
      Default:
      false
    • bufferFlushIntervalMs

      long bufferFlushIntervalMs
      How often buffered metrics are flushed to the server, in milliseconds.
      Default:
      5000L
    • bufferMaxSize

      int bufferMaxSize
      Maximum number of metrics to buffer before triggering an immediate flush.
      Default:
      100