I am trying to add Pointcut on execution of a method to total time taken by method to execute. But my pointcut is not getting called. Similar method which does not throws any exception , pointcut for that method is being called.I am not able to findout the exact root cause or issue with my pointcut expression.
@Pointcut(
value =
"execution(* com.customer.service.ExecuteCustomerService.initiateExecuteCustomer(..))")
private void logExecuteCustomer() {}
@Around(
value ="logExecuteCustomer()")
public Object TimerMonitoring(ProceedingJoinPoint proceedingJoinPoint) throws Throwable {
MethodSignature methodSignature = (MethodSignature) proceedingJoinPoint.getSignature();
// calculate method execution time
long startTime = System.currentTimeMillis();
Object result = proceedingJoinPoint.proceed();
long endTime = System.currentTimeMillis();
try {
String desc =
methodSignature.getDeclaringType().getSimpleName() + "." + methodSignature.getName();
metricsService.metricsTimer(desc, (endTime - startTime));
} catch (Exception exception) {
log.error("Error while processing metrics ", exception);
}
return result;
}
Method
public void initiateExecuteCustomer(
ChargeTransaction chargeTransactionFromKafka, boolean ignoreCollectionDate)
throws CustomerException {
String key = LOGGER_KEY + chargeTransactionFromKafka.getOrderNo();
long serviceStartTime = System.currentTimeMillis();
// some java code
}