Add exceptionsToTrace configuration support in @SentinelResource annotation - #543
Conversation
Codecov Report
@@ Coverage Diff @@
## master #543 +/- ##
============================================
+ Coverage 37.63% 38.74% +1.11%
- Complexity 1100 1216 +116
============================================
Files 259 275 +16
Lines 8171 8702 +531
Branches 1113 1163 +50
============================================
+ Hits 3075 3372 +297
- Misses 4697 4900 +203
- Partials 399 430 +31
Continue to review full report at Codecov.
|
sczyh30
left a comment
There was a problem hiding this comment.
Plz also reformat your code to match Alibaba Java Code Guideline.
| return false; | ||
| } | ||
| for (Class exceptionToTrace : exceptionsToTrace) { | ||
| if (ex.getClass().isAssignableFrom(exceptionToTrace)) { |
There was a problem hiding this comment.
It seems incorrect. For each exception to trace, it should be:
| if (ex.getClass().isAssignableFrom(exceptionToTrace)) { | |
| if (exceptionToTrace.isAssignableFrom(ex.getClass())) { |
Please be sure to add test cases and run the demo to verify it.
| return handleBlockException(pjp, annotation, ex); | ||
| } catch (Throwable ex) { | ||
| Tracer.trace(ex); | ||
| if (isTrackedException(ex, annotation.exceptionsToTrace())) { |
There was a problem hiding this comment.
Maybe we can move the logic to AbstractSentinelAspectSupport class to support extension for sub-classes. E.g.:
protected void traceException(Throwable ex, SentinelResource annotation)|
Thanks for contributing. I'll help to update the test cases and refactor code later. Please note that every new feature or enhancement must carry corresponding test cases. |
|
Improved in 61c5250 |
Describe what this PR does / why we need it
In some scenarios,this resource will be degraded when it throws a specific exception.
So the configuration of exception class that should be traced (blocked), is needed.
Does this pull request fix one issue?
Fixes #540
Describe how you did it
Add the configuration of exception classes that would be traced.
Describe how to verify it
None
Special notes for reviews
None