Browse Source

Add exception count trace for Sentinel annotation aspectj support

Signed-off-by: Eric Zhao <sczyh16@gmail.com>
master
Eric Zhao 6 years ago
parent
commit
61a75af379
2 changed files with 7 additions and 1 deletions
  1. +3
    -1
      sentinel-extension/sentinel-annotation-aspectj/src/main/java/com/alibaba/csp/sentinel/annotation/aspectj/AbstractSentinelAspectSupport.java
  2. +4
    -0
      sentinel-extension/sentinel-annotation-aspectj/src/main/java/com/alibaba/csp/sentinel/annotation/aspectj/SentinelResourceAspect.java

+ 3
- 1
sentinel-extension/sentinel-annotation-aspectj/src/main/java/com/alibaba/csp/sentinel/annotation/aspectj/AbstractSentinelAspectSupport.java View File

@@ -20,6 +20,7 @@ import com.alibaba.csp.sentinel.slots.block.BlockException;
import com.alibaba.csp.sentinel.slots.block.degrade.DegradeException; import com.alibaba.csp.sentinel.slots.block.degrade.DegradeException;
import com.alibaba.csp.sentinel.util.MethodUtil; import com.alibaba.csp.sentinel.util.MethodUtil;
import com.alibaba.csp.sentinel.util.StringUtil; import com.alibaba.csp.sentinel.util.StringUtil;

import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.reflect.MethodSignature; import org.aspectj.lang.reflect.MethodSignature;
import org.slf4j.Logger; import org.slf4j.Logger;
@@ -47,7 +48,8 @@ public abstract class AbstractSentinelAspectSupport {


protected Object handleBlockException(ProceedingJoinPoint pjp, SentinelResource annotation, BlockException ex) protected Object handleBlockException(ProceedingJoinPoint pjp, SentinelResource annotation, BlockException ex)
throws Exception { 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, protected Object handleBlockException(ProceedingJoinPoint pjp, String fallback, String blockHandler,


+ 4
- 0
sentinel-extension/sentinel-annotation-aspectj/src/main/java/com/alibaba/csp/sentinel/annotation/aspectj/SentinelResourceAspect.java View File

@@ -18,6 +18,7 @@ package com.alibaba.csp.sentinel.annotation.aspectj;
import com.alibaba.csp.sentinel.Entry; import com.alibaba.csp.sentinel.Entry;
import com.alibaba.csp.sentinel.EntryType; import com.alibaba.csp.sentinel.EntryType;
import com.alibaba.csp.sentinel.SphU; import com.alibaba.csp.sentinel.SphU;
import com.alibaba.csp.sentinel.Tracer;
import com.alibaba.csp.sentinel.annotation.SentinelResource; import com.alibaba.csp.sentinel.annotation.SentinelResource;
import com.alibaba.csp.sentinel.slots.block.BlockException; import com.alibaba.csp.sentinel.slots.block.BlockException;
import org.aspectj.lang.ProceedingJoinPoint; import org.aspectj.lang.ProceedingJoinPoint;
@@ -57,6 +58,9 @@ public class SentinelResourceAspect extends AbstractSentinelAspectSupport {
return result; return result;
} catch (BlockException ex) { } catch (BlockException ex) {
return handleBlockException(pjp, annotation, ex); return handleBlockException(pjp, annotation, ex);
} catch (Throwable ex) {
Tracer.trace(ex);
throw ex;
} finally { } finally {
if (entry != null) { if (entry != null) {
entry.exit(); entry.exit();


Loading…
Cancel
Save