Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhancement/expcetions to ignore #683

Merged
merged 6 commits into from
Apr 21, 2019

Conversation

yikangfeng
Copy link

Describe what this PR does / why we need it

在实际开发中,例如在Controller 上某个方法上打了@SentinelResource注解用于降级,这个时候,在这个方法上进行入参判断抛出的,例如IllegalArgumentException 异常,不想用于Sentinel作为一次异常被统计。所以在@SentinelResource 注解上增加了 exceptionsToIgnore 可以由用户指定哪些异常可以不被Sentinel统计。

Does this pull request fix one issue?

Describe how you did it

在@SentinelResource 注解上增加了 exceptionsToIgnore 可以由用户指定哪些异常可以不被Sentinel统计。然后在AbstractSentinelAspectSupport抽象类的traceException方法中增加,先判断exceptionsToIgnore 是否有配置,如果有,看当前抛出来的异常是否在被忽略的范围内,如果在,直接返回。如果不在,再判断是否应该被Traced.

Describe how to verify it

在 一个打有@SentinelResource 注解的方法上,为 exceptionsToIgnore 配置一个例如 IllegalArgumentException.class, 然后调用看抛出来的这个异常是否算在错误率里面。

Special notes for reviews

主要改动的代码有两处:
1.sentinel-core 下的@SentinelResource 注解
2.sentinel-annotation-aspectj 工程下的AbstractSentinelAspectSupport类。

@sczyh30 sczyh30 added kind/enhancement Category issues or prs related to enhancement. to-review To review labels Apr 18, 2019
@sczyh30 sczyh30 merged commit 78c31c6 into alibaba:master Apr 21, 2019
@sczyh30 sczyh30 removed the to-review To review label Apr 21, 2019
@sczyh30
Copy link
Member

sczyh30 commented Apr 21, 2019

Thanks for contributing. I've added some test cases and improved the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Category issues or prs related to enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants