Skip to content

Commit

Permalink
Add exception count trace for Sentinel annotation aspectj support
Browse files Browse the repository at this point in the history
Signed-off-by: Eric Zhao <[email protected]>
  • Loading branch information
sczyh30 committed Nov 2, 2018
1 parent 8f85dc5 commit 61a75af
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeException;
import com.alibaba.csp.sentinel.util.MethodUtil;
import com.alibaba.csp.sentinel.util.StringUtil;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.reflect.MethodSignature;
import org.slf4j.Logger;
Expand Down Expand Up @@ -47,7 +48,8 @@ protected String getResourceName(String resourceName, Method method) {

protected Object handleBlockException(ProceedingJoinPoint pjp, SentinelResource annotation, BlockException ex)
throws Exception {
return handleBlockException(pjp, annotation.fallback(), annotation.blockHandler(), annotation.blockHandlerClass(), ex);
return handleBlockException(pjp, annotation.fallback(), annotation.blockHandler(),
annotation.blockHandlerClass(), ex);
}

protected Object handleBlockException(ProceedingJoinPoint pjp, String fallback, String blockHandler,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.alibaba.csp.sentinel.Entry;
import com.alibaba.csp.sentinel.EntryType;
import com.alibaba.csp.sentinel.SphU;
import com.alibaba.csp.sentinel.Tracer;
import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.aspectj.lang.ProceedingJoinPoint;
Expand Down Expand Up @@ -57,6 +58,9 @@ public Object invokeResourceWithSentinel(ProceedingJoinPoint pjp) throws Throwab
return result;
} catch (BlockException ex) {
return handleBlockException(pjp, annotation, ex);
} catch (Throwable ex) {
Tracer.trace(ex);
throw ex;
} finally {
if (entry != null) {
entry.exit();
Expand Down

0 comments on commit 61a75af

Please sign in to comment.