Skip to content
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

fix(stacktrace): Filter out internal SDK methods #125

Merged
merged 1 commit into from
Dec 18, 2019

Conversation

rhcarvalho
Copy link
Contributor

The frame.Module field in its current form may contain entries like:
github.com/getsentry/sentry-go.(*Hub)
github.com/getsentry/sentry-go.(*Client)
github.com/getsentry/sentry-go.(*Client)

Taking those into account now.

Fixes up #123.

The frame.Module field in its current form may contain entries like:
github.com/getsentry/sentry-go.(*Hub)
github.com/getsentry/sentry-go.(*Client)
github.com/getsentry/sentry-go.(*Client)

Taking those into account now.
@@ -206,7 +206,8 @@ func filterFrames(frames []Frame) []Frame {
continue
}
// sentry internal frames
if frame.Module == "github.com/getsentry/sentry-go" {
if frame.Module == "github.com/getsentry/sentry-go" ||
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably just unify this to a single strings.HasPrefix and remove ending dot

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or strings.Contains. The chance of false positive is very unlikely.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered using only strings.HasPrefix. Eventually, what we need to do is define what frame.Module is supposed to mean.
Quite likely it should be github.com/getsentry/sentry-go, and never github.com/getsentry/sentry-go.(*Hub). Then the direct string comparison with == would be the condition here. What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Double-checked it and agree. It should be direct comparison.
But why is deconstructFunctionName putting .(Hub) in frame.Module? It should be a part of a function name. And I'm pretty sure it works correctly, at least for the input that's supposedly incorrect - https://play.golang.org/p/U8SfYCLeyun

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The input is different, see https://play.golang.org/p/bA6FSn1qG8C

It returns the Method name without the type prefix, and the type goes into the package import path.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's actually good, as we can reproduce it now. So what should change is the way to determine which parts belong to the module and which to the function name. Buuut it'll probably require a regexp instead of simple . index search 😢

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We didn't touch deconstructFunctionName recently. I can add some new test cases and fix it/change the behavior in a separate PR. Then we can drop the || HasPrefix part :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #126

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quite likely it should be github.com/getsentry/sentry-go, and never github.com/getsentry/sentry-go.(*Hub). Then the direct string comparison with == would be the condition here.

Except that we have "subpackages": github.com/getsentry/sentry-go/http, github.com/getsentry/sentry-go/....

I was wrong, forgot about those for a moment :(

@kamilogorek kamilogorek self-requested a review December 18, 2019 15:08
@rhcarvalho rhcarvalho merged commit d743e93 into getsentry:master Dec 18, 2019
@rhcarvalho rhcarvalho deleted the stacktrace-methods branch December 18, 2019 15:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants