Enhancement/expcetions to ignore - #683
Merged
sczyh30 merged 6 commits intoApr 21, 2019
Merged
Conversation
sczyh30
approved these changes
Apr 21, 2019
Member
|
Thanks for contributing. I've added some test cases and improved the code. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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类。