Annotation Interface Monitored


@Target({METHOD,TYPE}) @Retention(RUNTIME) @Documented public @interface Monitored
Marks a method or class for enhanced performance monitoring.

Methods annotated with @Monitored will have detailed performance metrics collected by the PerformanceMonitoringAspect, including custom thresholds and alerting.

Example usage:


 @Monitored(threshold = 5000, trackMemory = true)
 public void performExpensiveOperation() {
     // Operation that should complete within 5 seconds
 }

 @Monitored(name = "UserLogin", tags = {"authentication", "critical"})
 public User loginUser(String username, String password) {
     // Custom name and tags for categorization
 }
 
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    boolean
    Whether to create a trace span for distributed tracing.
    Custom metrics to capture.
    boolean
    Whether to include method parameters in logs.
    boolean
    Whether to include return value in logs.
    Custom name for the monitored operation.
    double
    Sampling rate for this operation (0.0 to 1.0).
    Tags for categorizing the operation.
    long
    Performance threshold in milliseconds.
    boolean
    Whether to track memory usage for this operation.
  • Element Details

    • name

      String name
      Custom name for the monitored operation. Default is the method signature.
      Default:
      ""
    • threshold

      long threshold
      Performance threshold in milliseconds. Operations exceeding this will trigger alerts. Default is -1 (use global threshold).
      Default:
      -1L
    • trackMemory

      boolean trackMemory
      Whether to track memory usage for this operation. Default is false.
      Default:
      false
    • logParameters

      boolean logParameters
      Whether to include method parameters in logs. Default is false for security.
      Default:
      false
    • logResult

      boolean logResult
      Whether to include return value in logs. Default is false for security.
      Default:
      false
    • tags

      String[] tags
      Tags for categorizing the operation. Useful for filtering and reporting.
      Default:
      {}
    • samplingRate

      double samplingRate
      Sampling rate for this operation (0.0 to 1.0). 1.0 means monitor every call, 0.1 means monitor 10% of calls. Default is 1.0.
      Default:
      1.0
    • createSpan

      boolean createSpan
      Whether to create a trace span for distributed tracing. Default is false.
      Default:
      false
    • customMetrics

      String[] customMetrics
      Custom metrics to capture.
      Default:
      {}