private List<Tag> createTags(MethodProceedingJoinPoint methodProceedingJoinPoint, Throwable throwable) { return Arrays.asList( getClassNameTag(methodProceedingJoinPoint), getMethodNameTag(methodProceedingJoinPoint), getExceptionTag(throwable), getHostNameTag()); }
@Around("org.slinkyframework.application.SlinkyApplicationArchitecture.applicationOperations()") public Object loggingAdvice(ProceedingJoinPoint proceedingJoinPoint) throws Throwable { return super.metricsAdvice(proceedingJoinPoint); } }
private Timer.Builder getTimerBuilder(MethodProceedingJoinPoint methodProceedingJoinPoint, Throwable throwable) { return Timer.builder(format(METRIC_NAME, getComponentType())) .tags(createTags(methodProceedingJoinPoint, throwable)) .description(format("Timer of %s operations", getComponentType())); }
public Object metricsAdvice(ProceedingJoinPoint proceedingJoinPoint) throws Throwable { Object result; MethodProceedingJoinPoint methodProceedingJoinPoint = new MethodProceedingJoinPoint(proceedingJoinPoint); final Clock clock = Metrics.globalRegistry.config().clock(); final long startTime = clock.monotonicTime(); try { result = proceedingJoinPoint.proceed(); getTimerBuilder(methodProceedingJoinPoint, null) .register(Metrics.globalRegistry) .record(clock.monotonicTime() - startTime, TimeUnit.NANOSECONDS); } catch (Throwable e) { getTimerBuilder(methodProceedingJoinPoint, e) .register(Metrics.globalRegistry) .record(clock.monotonicTime() - startTime, TimeUnit.NANOSECONDS); throw e; } return result; }
@Around("org.slinkyframework.client.SlinkyClientArchitecture.clientOperations()") public Object loggingAdvice(ProceedingJoinPoint proceedingJoinPoint) throws Throwable { return super.metricsAdvice(proceedingJoinPoint); } }