path: util/aop/aop-service/src/main/java/com/knubisoft/aop/service/MethodCallsCountAspect.java

MethodCallsCountAspect works on the service layer and collects metrics about how many times each public method has been called.

For counting we use the Micrometer library and its Counter, for each method, the first time it is called, a Counter is created using the CounterFactory and performs an increment, if the Counter for method already exists, CounterFactory will return an existing instead of creating a new one.

MethodCallsCountAspect annotated with @ConditionalOnProperty(value = "management.serviceLayerMetrics.methodCallsCountEnabled", havingValue = "true"), so to 'enable' this aspect you must set the property management.serviceLayerMetrics.methodCallsCountEnabled within the application.yaml to true.


Metrics we collect using Micrometer are also available for Prometheus (we create PrometheusMeterRegistry) and can be retrieved by the Spring Actuator endpoint your_host:your_port/actuator/prometheus