Annotation Interface TrackBusinessMetric


@Target(METHOD) @Retention(RUNTIME) @Documented public @interface TrackBusinessMetric
Marks a method for business metric collection after each successful invocation.

Allows correlating business activity with technical metrics of the service. For example, if CPU rises to 90%, it becomes visible that the number of processed orders dropped simultaneously. The metric is incremented by 1 on each successful method call without an exception.

Usage example:


 @Service
 public class OrderService {

     @TrackBusinessMetric(name = "orders.created", unit = "count")
     public Order createOrder(OrderRequest request) { ... }

     @TrackBusinessMetric(name = "orders.cancelled", unit = "count", description = "Cancelled orders")
     public void cancelOrder(Long orderId) { ... }

     @TrackBusinessMetric(name = "payments.processed", unit = "uah", description = "Processed payment amount")
     public Payment processPayment(PaymentRequest request) { ... }
 }
 

Note: the metric is recorded only on successful method completion. If an exception is thrown, it is not recorded.

  • Required Element Summary

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

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    Human-readable description shown in reports and the dashboard.
    Unit of measurement.
  • Element Details

    • name

      String name
      Unique business metric name in "entity.action" format. Examples: "orders.created", "payments.failed".
    • unit

      String unit
      Unit of measurement. Examples: "count", "uah", "items".
      Default:
      "count"
    • description

      String description
      Human-readable description shown in reports and the dashboard.
      Default:
      ""