Sentry: Filtering out class proxies from stacktraces (in Java)

Created on 8 Oct 2017  路  11Comments  路  Source: getsentry/sentry

Hi,
I'm relatively new to Java, so I'm not sure how this really works, but Spring is using something (CGLIB?) to generate proxies and they're not really that interesting when it comes to stacktraces.

image

It would be nice, if Sentry could automatically recognize that the line in stacktrace is from a proxy and mark it as "library code".

Most helpful comment

Hey @fprochazka, this sounds like a safe/fine change to me. It should probably happen on the SDK (sentry-java) side. We could have a list of special cases we check for and exclude from the app frames. In this case I assume frames containing $$FastClassBySpringCGLIB$$ would be safe to exclude.

Do you mind opening an issue at sentry-java? I can try to get to this later this week.

All 11 comments

So we should be doing that already: https://github.com/getsentry/sentry/blob/master/src/sentry/interfaces/stacktrace.py#L38-L42

Well, not exactly that, but we should be stripping that bit out.

When testing this manually, it seems to do the right thing.

>>> _java_enhancer_re.sub(r'\1<auto>', 'foo$$FastClassBySprintCGLIB$$4ed8b6b')
'foo$$FastClassBySprintCGLIB$$<auto>'

Are you running a really old Sentry or something?

we should be stripping that bit out

For clarification: the nondeterministic bits are stripped out for consideration in the grouping hash generation algorithm, but we still display it as part of the stacktrace in the UI.

Ohhh, TIL. I thought we removed it entirely from the stack itself.

Actually I've installed it few days ago based on the current onpremise repository in a docker container :)

image

I think it's usefull info in the stack - you want to know it was called from a proxy, but it should not be marked as part of my app, since it's generated.

Hey @fprochazka, this sounds like a safe/fine change to me. It should probably happen on the SDK (sentry-java) side. We could have a list of special cases we check for and exclude from the app frames. In this case I assume frames containing $$FastClassBySpringCGLIB$$ would be safe to exclude.

Do you mind opening an issue at sentry-java? I can try to get to this later this week.

@bretthoerner you want to not send them to sentry server at all, or just mark them somehow? I'm not sure what "exclude from the app frames" means - if it means just to not mark them as part of my application, then yay! :)

Ya, I assume you're using the stacktrace.app.packages config option?

So in the SDK we won't mark frames as "in app" if they match the blacklist of regexes.

@bretthoerner awesome :+1:

Cool, closing in factor of that issue.

I delt with the same problem and wrote a utility that smartly filters out stacktrace based on user configuration. It works very well. I published this utility as part of my MgntUtils Open Source Java library. It is available on Github (https://github.com/michaelgantman/Mgnt) and Maven Central (https://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.github.michaelgantman%22%20AND%20a%3A%22MgntUtils%22). Here is the link to the article that explains what utilities are available in the library and how to use them: https://www.linkedin.com/pulse/open-source-java-library-some-useful-utilities-michael-gantman/

Was this page helpful?
0 / 5 - 0 ratings