Annotation 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 -
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionHuman-readable description shown in the web interface and Swagger documentation.How the metric value should be interpreted.Unit of measurement.
-
Element Details
-
name
String nameUnique metric name in"category.subcategory.action"format. Examples:"db.query.time","orders.created". -
kind
MetricKind kindHow the metric value should be interpreted. Defaults toMetricKind.COUNTER.- Default:
COUNTER
-
unit
String unitUnit of measurement. Defaults to milliseconds. Used only for display purposes in the UI.- Default:
"ms"
-
description
String descriptionHuman-readable description shown in the web interface and Swagger documentation.- Default:
""
-