Annotation 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 ElementsModifier and TypeOptional ElementDescriptionbooleanWhether to create a trace span for distributed tracing.String[]Custom metrics to capture.booleanWhether to include method parameters in logs.booleanWhether to include return value in logs.Custom name for the monitored operation.doubleSampling rate for this operation (0.0 to 1.0).String[]Tags for categorizing the operation.longPerformance threshold in milliseconds.booleanWhether to track memory usage for this operation.
-
Element Details
-
name
String nameCustom name for the monitored operation. Default is the method signature.- Default:
""
-
threshold
long thresholdPerformance threshold in milliseconds. Operations exceeding this will trigger alerts. Default is -1 (use global threshold).- Default:
-1L
-
trackMemory
boolean trackMemoryWhether to track memory usage for this operation. Default is false.- Default:
false
-
logParameters
boolean logParametersWhether to include method parameters in logs. Default is false for security.- Default:
false
-
logResult
boolean logResultWhether to include return value in logs. Default is false for security.- Default:
false
-
tags
String[] tagsTags for categorizing the operation. Useful for filtering and reporting.- Default:
{}
-
samplingRate
double samplingRateSampling 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 createSpanWhether to create a trace span for distributed tracing. Default is false.- Default:
false
-
customMetrics
String[] customMetricsCustom metrics to capture.- Default:
{}
-