-
Notifications
You must be signed in to change notification settings - Fork 20
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
Filtering stack trace #144
Filtering stack trace #144
Conversation
add "ThrowableFormat.Filter" with options to NoFilter" and "Excluding" add test for "Filter" add example
Codecov Report
@@ Coverage Diff @@
## master #144 +/- ##
==========================================
- Coverage 93.33% 93.20% -0.13%
==========================================
Files 32 32
Lines 465 471 +6
Branches 9 12 +3
==========================================
+ Hits 434 439 +5
- Misses 31 32 +1
Continue to review full report at Codecov.
|
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.
Hi @lightning95
Thanks for PR, it looks very promising! Good to see that you care about performance. I have couple of comments though
|
||
object Excluding { | ||
def apply(prefixes: String*): Excluding = new Excluding(prefixes.toSet) | ||
def apply(prefixes: IterableOnceCompat[String]): Excluding = new Excluding(prefixes.toSetCompat) |
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.
What's the point of going so generic here? It adds unneccessary complexity for benefits I'm clearly missing
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 think, users may want to construct ThrowableFormat.Filter.Excluding
from any Traversable
(Iterable
)
e.g. read from typesafe config and create logging format, having to do something like this:
Filter.Excluding(config.getStringList("exclude"): _ *)
or
Filter.Excluding(config.getStringList("exclude").toSet)
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 think it's fine for the end user to convert whatever they have to the set on their own
writeStackTrace(builder, depth.fold(t.getStackTrace)(t.getStackTrace.take), indent) | ||
|
||
val filteredStackTrace = filter.fold(t.getStackTrace)(set => | ||
t.getStackTrace.filterNot(row => set.contains(row.getClassName.stripSuffix("$"))) |
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.
Would it be faster to move this check into writeStackTrace
loop and save few allocations?
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.
then we'll need to move the t.getStackTrace.take
part into writeStackTrace
loop too, because we could take(5)
and then filter them out, having empty list of rows.
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.
yeah, it's possible to just count amount of actual lines printed and stop whenever depth
is achieved
no worries, it's a matter of optimization in separate PR then
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.
Can I make this PR for optimization?
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.
@lightning95 sorry haven't noticed it earlier
yes, feel free to
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.
Thanks for the PR @lightning95
I'm going to merge it, update the documentation and land the release soon
That's the first solution to #137.
But I have several concerns about it:
Depth.Fixed(1)
), but to optimize it, it would require something like thisAnd again, here (
t.getStackTrace.to(LazyList)
) requires 2.12-2.13 compatibility.