-
Notifications
You must be signed in to change notification settings - Fork 77
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
Add support for filtering stack traces in the log4j2 implementation #167
Add support for filtering stack traces in the log4j2 implementation #167
Conversation
@felixbarny / @eyalkoren Since version 1.29.0 of the Java agent was released recently, could you please spare some time to provide feedback on this PR? |
ping |
What are some of the use cases for wanting to filter out a stack frame? |
My use case is to filter out (most of) the framework stack frames, which can be very noisy on an application server and usually do not add valuable information. e.g. I would like to compress
into something like
This should increase readability (especially when there are also nested exceptions) and reduce storage costs. I am aware that in some (rare) case we might loose valuable stack frames, but overall I think its worth the downside. |
I will have a look into |
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.
LGTM
@eyalkoren could you also have a look?
Oops, didn't see this PR out there. I just submitted something similar except that it uses log4j2's I've confirmed that it works with filters, e.g. |
@tobiasstadler please take a look at #177 - would you be able to use this approach for your needs? |
@eyalkoren My solution uses |
You could roll your own It's a bit of a shame that the throwable converters that ship with log4j2 aren't really designed to be extended, that would have made it pretty trivial to build a custom one that just tweaks the behavior of filtering out stack frames. |
Yes, I am aware. Yours is more performant. This is why I emphasized that in general, same overhead that would be applied through using the same capabilities in log4j2 is acceptable.
Could that be a solution that satisfies all? What if you take the more efficient approach from this PR and use it within a custom @tobiasstadler just an example where providing the maximum flexibility is preferable- assume that we use the filtering approach from this PR only and it solves what it needs to perfectly. However, for another user the most important thing is to put a hard limit on the number of stack trace elements they want to get logged. The general-purpose approach allows that with the builtin converter even though we didn't think of that. |
I just want to "exclude" stack frames from stack traces that match some list of patterns. I am fine with anything providing support for this. |
@tobiasstadler could you port your desired implementation into a |
I'm not convinced that we should add custom implementations for |
It would, but if others can benefit from it, why not have it here? After all, it is very relevant to log manipulation that is probably common for ECS users. Are you worried about the maintenance burden? That indeed has overhead, but if we make it pluggable, it provides a nice encapsulation and I think it could be a nice example for other users of how it can be done. |
I just think adding utilities is not in scope of this project and could be a slippery slope. I agree it's useful but not specific to ECS. Maybe upstream log4j2 would be a better home for that |
@tobiasstadler we decided to go with the generic approach of #177 because it is extensible very flexibly, as demonstrated through With that, you can apply any custom formatting, like the one in this PR. Would that work well for your use case? |
I will have a look |
This is similar to what
%xEx{filters(...)}
does.