Annotation Interface TrackMetric


@Target(METHOD) @Retention(RUNTIME) @Documented public @interface TrackMetric
Marks an arbitrary method for execution time measurement as a technical metric.

Unlike MonitoredEndpoint, this annotation can be applied to any Spring-managed component: a service, repository, HTTP client, etc. It measures the method execution time and records it as a named metric.

Usage example:


 @Service
 public class InventoryService {

     @TrackMetric(name = "db.inventory.query", kind = MetricKind.TIMER)
     public List<Product> findAvailable() { ... }

     @TrackMetric(name = "orders.created", kind = MetricKind.COUNTER, description = "Orders placed")
     public Order createOrder(OrderRequest request) { ... }
 }
 
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    Unique metric name in "category.subcategory.action" format.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Human-readable description shown in the web interface and Swagger documentation.
    How the metric value should be interpreted.
    Unit of measurement.
  • Element Details

    • name

      String name
      Unique metric name in "category.subcategory.action" format. Examples: "db.query.time", "orders.created".
    • kind

      How the metric value should be interpreted. Defaults to MetricKind.COUNTER.
      Default:
      COUNTER
    • unit

      String unit
      Unit of measurement. Defaults to milliseconds. Used only for display purposes in the UI.
      Default:
      "ms"
    • description

      String description
      Human-readable description shown in the web interface and Swagger documentation.
      Default:
      ""