| Total Complexity | 2 |
| Total Lines | 28 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | package io.mcarle.sciurus.monitor; |
||
| 9 | 1 | class MonitorAspectHandler { |
|
| 10 | |||
| 11 | static Object executeAndMeasure(ProceedingJoinPoint joinPoint) throws Throwable { |
||
| 12 | 1 | MethodSignature signature = (MethodSignature) joinPoint.getSignature(); |
|
| 13 | |||
| 14 | 1 | Object returnValue = null; |
|
| 15 | 1 | Throwable throwable = null; |
|
| 16 | 1 | long duration = 0; |
|
| 17 | 1 | long before = System.nanoTime(); |
|
| 18 | try { |
||
| 19 | 1 | returnValue = joinPoint.proceed(); |
|
| 20 | 1 | duration = System.nanoTime() - before; |
|
| 21 | 1 | } catch (Throwable t) { |
|
| 22 | 1 | duration = System.nanoTime() - before; |
|
| 23 | 1 | throwable = t; |
|
| 24 | 1 | throw t; |
|
| 25 | } finally { |
||
| 26 | 1 | MonitorRegister.INSTANCE.notifyRegisteredMonitors( |
|
| 27 | 1 | Duration.of(duration, ChronoUnit.NANOS), |
|
| 28 | 1 | signature.getDeclaringTypeName(), |
|
| 29 | 1 | signature.getMethod(), |
|
| 30 | 1 | joinPoint.getArgs(), |
|
| 31 | 1 | throwable, |
|
| 32 | 1 | signature.getReturnType(), |
|
| 33 | 1 | returnValue |
|
| 34 | ); |
||
| 35 | } |
||
| 36 | 1 | return returnValue; |
|
| 37 | } |
||
| 39 |