@@ -65,3 +65,97 @@ func TestSplitQualifiedFunctionName(t *testing.T) {
65
65
})
66
66
}
67
67
}
68
+
69
+ //nolint: scopelint // false positive https://github.com/kyoh86/scopelint/issues/4
70
+ func TestFilterFrames (t * testing.T ) {
71
+ tests := []struct {
72
+ in []Frame
73
+ out []Frame
74
+ }{
75
+ // sanity check
76
+ {},
77
+ // filter out go internals and SDK internals; "sentry-go_test" is
78
+ // considered outside of the SDK and thus included (useful for testing)
79
+ {
80
+ in : []Frame {
81
+ {
82
+ Function : "goexit" ,
83
+ Module : "runtime" ,
84
+ AbsPath : "/goroot/src/runtime/asm_amd64.s" ,
85
+ InApp : false ,
86
+ },
87
+ {
88
+ Function : "tRunner" ,
89
+ Module : "testing" ,
90
+ AbsPath : "/goroot/src/testing/testing.go" ,
91
+ InApp : false ,
92
+ },
93
+ {
94
+ Function : "TestNewStacktrace.func1" ,
95
+ Module : "github.com/getsentry/sentry-go_test" ,
96
+ AbsPath : "/somewhere/sentry/sentry-go/stacktrace_external_test.go" ,
97
+ InApp : true ,
98
+ },
99
+ {
100
+ Function : "StacktraceTestHelper.NewStacktrace" ,
101
+ Module : "github.com/getsentry/sentry-go" ,
102
+ AbsPath : "/somewhere/sentry/sentry-go/stacktrace_test.go" ,
103
+ InApp : true ,
104
+ },
105
+ {
106
+ Function : "NewStacktrace" ,
107
+ Module : "github.com/getsentry/sentry-go" ,
108
+ AbsPath : "/somewhere/sentry/sentry-go/stacktrace.go" ,
109
+ InApp : true ,
110
+ },
111
+ },
112
+ out : []Frame {
113
+ {
114
+ Function : "TestNewStacktrace.func1" ,
115
+ Module : "github.com/getsentry/sentry-go_test" ,
116
+ AbsPath : "/somewhere/sentry/sentry-go/stacktrace_external_test.go" ,
117
+ InApp : true ,
118
+ },
119
+ },
120
+ },
121
+ // filter out integrations; SDK subpackages
122
+ {
123
+ in : []Frame {
124
+ {
125
+ Function : "Example.Integration" ,
126
+ Module : "github.com/getsentry/sentry-go/http/integration" ,
127
+ AbsPath : "/somewhere/sentry/sentry-go/http/integration/integration.go" ,
128
+ InApp : true ,
129
+ },
130
+ {
131
+ Function : "(*Handler).Handle" ,
132
+ Module : "github.com/getsentry/sentry-go/http" ,
133
+ AbsPath : "/somewhere/sentry/sentry-go/http/sentryhttp.go" ,
134
+ InApp : true ,
135
+ },
136
+ {
137
+ Function : "main" ,
138
+ Module : "main" ,
139
+ AbsPath : "/somewhere/example.com/pkg/main.go" ,
140
+ InApp : true ,
141
+ },
142
+ },
143
+ out : []Frame {
144
+ {
145
+ Function : "main" ,
146
+ Module : "main" ,
147
+ AbsPath : "/somewhere/example.com/pkg/main.go" ,
148
+ InApp : true ,
149
+ },
150
+ },
151
+ },
152
+ }
153
+ for _ , tt := range tests {
154
+ t .Run ("" , func (t * testing.T ) {
155
+ got := filterFrames (tt .in )
156
+ if diff := cmp .Diff (tt .out , got ); diff != "" {
157
+ t .Errorf ("filterFrames() mismatch (-want +got):\n %s" , diff )
158
+ }
159
+ })
160
+ }
161
+ }
0 commit comments