Skip to content

Commit 9beef00

Browse files
authored
fix: system frames marked as inApp (#4236)
* fix: system frames marked as inApp * changelog
1 parent c5965ab commit 9beef00

File tree

5 files changed

+116
-42
lines changed

5 files changed

+116
-42
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
- Rename MemoryInfo.AllocatedBytes to MemoryInfo.TotalAllocatedBytes ([#4243](https://github.com/getsentry/sentry-dotnet/pull/4243))
88

9+
### Fixes
10+
11+
- Fix InApp Exclude for frames without Module by checking against frame's Package ([#4236](https://github.com/getsentry/sentry-dotnet/pull/4236))
12+
913
## 5.9.0
1014

1115
### Features

src/Sentry/SentryOptions.cs

Lines changed: 46 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,48 +1292,7 @@ public SentryOptions()
12921292
Native = new NativeOptions(this);
12931293
#endif
12941294

1295-
InAppExclude = new() {
1296-
"System",
1297-
"Mono",
1298-
"Sentry",
1299-
"Microsoft",
1300-
"MS", // MS.Win32, MS.Internal, etc: Desktop apps
1301-
"ABI.Microsoft", // MAUI
1302-
"WinRT", // WinRT, UWP, WinUI
1303-
"UIKit", // iOS / MacCatalyst
1304-
"Newtonsoft.Json",
1305-
"FSharp",
1306-
"Serilog",
1307-
"Giraffe",
1308-
"NLog",
1309-
"Npgsql",
1310-
"RabbitMQ",
1311-
"Hangfire",
1312-
"IdentityServer4",
1313-
"AWSSDK",
1314-
"Polly",
1315-
"Swashbuckle",
1316-
"FluentValidation",
1317-
"Autofac",
1318-
"Stackexchange.Redis",
1319-
"Dapper",
1320-
"RestSharp",
1321-
"SkiaSharp",
1322-
"IdentityModel",
1323-
"SqlitePclRaw",
1324-
"Xamarin",
1325-
"Android", // Ex: Android.Runtime.JNINativeWrapper...
1326-
"Google",
1327-
"MongoDB",
1328-
"Remotion.Linq",
1329-
"AutoMapper",
1330-
"Nest",
1331-
"Owin",
1332-
"MediatR",
1333-
"ICSharpCode",
1334-
"Grpc",
1335-
"ServiceStack"
1336-
};
1295+
InAppExclude = GetDefaultInAppExclude();
13371296

13381297
#if DEBUG
13391298
InAppInclude = new()
@@ -1827,4 +1786,49 @@ internal void SetupLogging()
18271786
// In the future, this will most likely contain process ID
18281787
return TryGetDsnSpecificCacheDirectoryPath();
18291788
}
1789+
1790+
internal static List<StringOrRegex> GetDefaultInAppExclude() =>
1791+
[
1792+
"System",
1793+
"Mono",
1794+
"Sentry",
1795+
"Microsoft",
1796+
"MS", // MS.Win32, MS.Internal, etc: Desktop apps
1797+
"ABI.Microsoft", // MAUI
1798+
"WinRT", // WinRT, UWP, WinUI
1799+
"UIKit", // iOS / MacCatalyst
1800+
"Newtonsoft.Json",
1801+
"FSharp",
1802+
"Serilog",
1803+
"Giraffe",
1804+
"NLog",
1805+
"Npgsql",
1806+
"RabbitMQ",
1807+
"Hangfire",
1808+
"IdentityServer4",
1809+
"AWSSDK",
1810+
"Polly",
1811+
"Swashbuckle",
1812+
"FluentValidation",
1813+
"Autofac",
1814+
"Stackexchange.Redis",
1815+
"Dapper",
1816+
"RestSharp",
1817+
"SkiaSharp",
1818+
"IdentityModel",
1819+
"SqlitePclRaw",
1820+
"Xamarin",
1821+
"Android", // Ex: Android.Runtime.JNINativeWrapper...
1822+
"Google",
1823+
"MongoDB",
1824+
"Remotion.Linq",
1825+
"AutoMapper",
1826+
"Nest",
1827+
"Owin",
1828+
"MediatR",
1829+
"ICSharpCode",
1830+
"Grpc",
1831+
"ServiceStack",
1832+
"Java.Interop",
1833+
];
18301834
}

src/Sentry/SentryStackFrame.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,10 @@ public void ConfigureAppFrame(SentryOptions options)
201201
{
202202
ConfigureAppFrame(options, Module, LazyModuleMatcher.Value);
203203
}
204+
else if (!string.IsNullOrEmpty(Package))
205+
{
206+
ConfigureAppFrame(options, Package, LazyModuleMatcher.Value);
207+
}
204208
else if (!string.IsNullOrEmpty(Function))
205209
{
206210
ConfigureAppFrame(options, Function, LazyFunctionMatcher.Value);

test/Sentry.Tests/Protocol/Exceptions/SentryStackFrameTests.cs

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,58 @@ public void ConfigureAppFrame_WithDefaultOptions_RecognizesSentryInternalFrame()
222222
Assert.False(sut.InApp);
223223
}
224224

225+
[Fact]
226+
public void ConfigureAppFrame_WithDefaultOptions_NotBuiltInIgnoredMarkedAsInApp()
227+
{
228+
var options = new SentryOptions();
229+
var sut = new SentryStackFrame
230+
{
231+
Function = "async void MainActivity.OnCreate(Bundle savedInstanceState)+(?) =\\u003E { }",
232+
Package = "SymbolCollector.Android, Version=1.23.0.0, Culture=neutral, PublicKeyToken=null"
233+
};
234+
235+
// Act
236+
sut.ConfigureAppFrame(options);
237+
238+
// Assert
239+
Assert.True(sut.InApp);
240+
}
241+
242+
[Fact]
243+
public void ConfigureAppFrame_WithDefaultOptions_JavaPackageNotInApp()
244+
{
245+
var options = new SentryOptions();
246+
var sut = new SentryStackFrame
247+
{
248+
Function = "void StaticMethods.CallStaticVoidMethod(JniObjectReference, JniMethodInfo, JniArgumentValue*)",
249+
Package = "Java.Interop, Version=9.0.0.0, Culture=neutral, PublicKeyToken=84e04ff9cfb79065"
250+
};
251+
252+
// Act
253+
sut.ConfigureAppFrame(options);
254+
255+
// Assert
256+
Assert.False(sut.InApp);
257+
}
258+
259+
[Fact]
260+
public void ConfigureAppFrame_WithDefaultOptions_SystemPackageNotInApp()
261+
{
262+
var options = new SentryOptions();
263+
var sut = new SentryStackFrame
264+
{
265+
Function = "void Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, string path, bool isDirError)",
266+
Package = "System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e",
267+
FileName = "Interop.IOErrors.cs",
268+
};
269+
270+
// Act
271+
sut.ConfigureAppFrame(options);
272+
273+
// Assert
274+
Assert.False(sut.InApp);
275+
}
276+
225277
[Fact]
226278
public void ConfigureAppFrame_InAppAlreadySet_InAppIgnored()
227279
{

test/Sentry.Tests/SentryOptionsTests.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,16 @@ public void AddInAppExclude_StoredInOptions()
334334
Assert.Contains(sut.InAppExclude!, actual => actual.ToString() == expected);
335335
}
336336

337+
[Fact]
338+
public void AddInAppExclude_DoesNotOverrideDefaults()
339+
{
340+
var sut = new SentryOptions();
341+
const string expected = "test";
342+
sut.AddInAppExclude(expected);
343+
Assert.All(SentryOptions.GetDefaultInAppExclude(),
344+
item => Assert.Contains(item, sut.InAppExclude!));
345+
}
346+
337347
[Fact]
338348
public void AddInAppExcludeRegex_StoredInOptions()
339349
{

0 commit comments

Comments
 (0)