-
Notifications
You must be signed in to change notification settings - Fork 881
Add custom stacktrace renderer which is length limit aware #7281
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
base: main
Are you sure you want to change the base?
Conversation
Arguments.of(withMultipleSuppressed), | ||
Arguments.of(withNestedSuppressed), | ||
// with cause, cycle, and suppressed! | ||
Arguments.of(withKitchenSink)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Anyone else have ideas of additional exceptions to further stress the edge cases?
assertThat(new StackTraceRenderer(throwable, 1000).render()) | ||
.isEqualTo(jdkStackTrace(throwable, 1000)); | ||
assertThat(new StackTraceRenderer(throwable, Integer.MAX_VALUE).render()) | ||
.isEqualTo(jdkStackTrace(throwable, Integer.MAX_VALUE)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love this test: for a list of exceptions render each at a variety of length limits, and compare the result to the built-in JDK stack trace renderer.
@@ -107,7 +105,9 @@ public static Object applyAttributeLengthLimit(Object value, int lengthLimit) { | |||
} | |||
|
|||
public static void addExceptionAttributes( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing I've considered is retaining some sort of system property / env var to fallback to the built-in JDK exception rendering. Would offer a nice escape hatch to revert to the built-in jdk rendering in case there's any bugs in the code, but downside is it would be hard to know when it would be safe to finally remove.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7281 +/- ##
============================================
+ Coverage 89.61% 90.02% +0.41%
- Complexity 6858 6926 +68
============================================
Files 780 788 +8
Lines 20718 20925 +207
Branches 2020 2038 +18
============================================
+ Hits 18566 18838 +272
+ Misses 1512 1444 -68
- Partials 640 643 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…y-java into better-stacktrace-render
Replace
Throwable#printStackTrace(PrintStream)
exception stacktrace rendering with a custom implementation which is aware of attribute length limits, and exits early to avoid unnecessary work. The result is significantly improved memory and cpu, with gains proportional to the difference between the total stack trace length and the attribute length limit. I.e. if you have a really long stack trace (i.e. 100k+ chars) and relatively small length limit (i.e. 1k chars), you'll have more to gain with this improvement.Benchmark results: