Skip to content

Commit 2f5ce53

Browse files
committed
[Sentry] Use attachment for loaded modules instead
Due to breadcrumbs having 8192 char limit
1 parent b4a5fb1 commit 2f5ce53

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

Hi3Helper.Core/Classes/SentryHelper/SentryHelper.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99
using System.Collections.Concurrent;
1010
using System.Collections.Generic;
1111
using System.Diagnostics;
12+
using System.IO;
1213
using System.Linq;
14+
using System.Text;
1315
using System.Text.RegularExpressions;
1416

1517
// ReSharper disable UnusedAutoPropertyAccessor.Global
@@ -483,8 +485,11 @@ private static Task ExceptionHandlerInner(Exception ex, ExceptionType exT = Exce
483485
}
484486
});
485487

486-
SentrySdk.AddBreadcrumb("Loaded Modules", "AppInfo",
487-
"system.module", modulesInfo.ToDictionary());
488+
var sbModulesInfo = new StringBuilder();
489+
foreach (var (key, value) in modulesInfo)
490+
{
491+
sbModulesInfo.AppendLine($"{key}: {value}");
492+
}
488493

489494
ex.Data[Mechanism.HandledKey] ??= exT == ExceptionType.Handled;
490495

@@ -513,6 +518,9 @@ private static Task ExceptionHandlerInner(Exception ex, ExceptionType exT = Exce
513518
SentrySdk.CaptureException(ex, s =>
514519
{
515520
s.AddAttachment(LoggerBase.LogPath, AttachmentType.Default, "text/plain");
521+
s.AddAttachment(new MemoryStream(Encoding.UTF8.GetBytes(sbModulesInfo.ToString())),
522+
"LoadedModules.txt", AttachmentType.Default,
523+
"text/plain");
516524
});
517525
}
518526
else

0 commit comments

Comments
 (0)