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

Add MemoryInfo to sentry event #1337

Merged
merged 29 commits into from
Dec 16, 2021
Merged
Changes from 5 commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
b01f17c
AddMemoryInfo
SimonCropp Nov 23, 2021
8674995
Merge branch 'main' into AddMemoryInfo
SimonCropp Nov 24, 2021
d31efab
Merge branch 'main' into AddMemoryInfo
SimonCropp Nov 25, 2021
8e08af9
Merge branch 'main' into AddMemoryInfo
SimonCropp Nov 26, 2021
28f93d4
Merge branch 'main' into AddMemoryInfo
SimonCropp Nov 28, 2021
fd8855a
Update src/Sentry/Internal/MainSentryEventProcessor.cs
SimonCropp Dec 8, 2021
17c4fae
Merge branch 'main' into AddMemoryInfo
SimonCropp Dec 8, 2021
8e7c664
Merge branch 'main' into AddMemoryInfo
SimonCropp Dec 10, 2021
dfbe02b
Merge branch 'main' into AddMemoryInfo
SimonCropp Dec 14, 2021
05462d4
Update CHANGELOG.md
SimonCropp Dec 14, 2021
dd1fa6b
Merge branch 'main' into AddMemoryInfo
SimonCropp Dec 14, 2021
c147960
.
SimonCropp Dec 14, 2021
dfe09cf
Format code
getsentry-bot Dec 14, 2021
d00ddf8
Merge branch 'main' into AddMemoryInfo
SimonCropp Dec 14, 2021
34a3074
Merge branch 'main' into AddMemoryInfo
SimonCropp Dec 14, 2021
c332a1c
Update src/Sentry/Internal/MainSentryEventProcessor.cs
SimonCropp Dec 14, 2021
e9cfa49
.
SimonCropp Dec 16, 2021
1fc5af7
Merge branch 'main' into AddMemoryInfo
SimonCropp Dec 16, 2021
f5f6d88
.
SimonCropp Dec 16, 2021
dd7827b
Format code
getsentry-bot Dec 16, 2021
46fe6b1
Update MainSentryEventProcessorTests.cs
SimonCropp Dec 16, 2021
f4b2f96
Update MainSentryEventProcessorTests.cs
SimonCropp Dec 16, 2021
a16a350
Merge branch 'AddMemoryInfo' of https://github.com/getsentry/sentry-d…
SimonCropp Dec 16, 2021
6b1e286
.
SimonCropp Dec 16, 2021
b914fbf
Format code
getsentry-bot Dec 16, 2021
5104de7
Update MainSentryEventProcessorTests.cs
SimonCropp Dec 16, 2021
aa844a9
Update MainSentryEventProcessorTests.cs
SimonCropp Dec 16, 2021
b064d72
Merge branch 'AddMemoryInfo' of https://github.com/getsentry/sentry-d…
SimonCropp Dec 16, 2021
6e234b2
Update CHANGELOG.md
SimonCropp Dec 16, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions src/Sentry/Internal/MainSentryEventProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ internal class MainSentryEventProcessor : ISentryEventProcessor
{
internal const string CultureInfoKey = "Current Culture";
internal const string CurrentUiCultureKey = "Current UI Culture";
internal const string MemoryInfoKey = "Memory Info";

private readonly Enricher _enricher;

Expand Down Expand Up @@ -54,6 +55,7 @@ public SentryEvent Process(SentryEvent @event)
@event.Contexts[CurrentUiCultureKey] = currentUiCultureMap;
}

AddMemoryInfo(@event.Contexts);
if (@event.ServerName == null)
{
// Value set on the options take precedence over device name.
Expand Down Expand Up @@ -134,6 +136,35 @@ public SentryEvent Process(SentryEvent @event)
return @event;
}

private void AddMemoryInfo(Contexts contexts)
{
#if NETCOREAPP3_0 || NET5_0_OR_GREATER
SimonCropp marked this conversation as resolved.
Show resolved Hide resolved
var memoryInfo = GC.GetGCMemoryInfo();
var values = new Dictionary<string, string>
{
{"TotalAllocatedBytes", GC.GetTotalAllocatedBytes().ToString()},
{"FragmentedBytes", memoryInfo.FragmentedBytes.ToString()},
{"HeapSizeBytes", memoryInfo.HeapSizeBytes.ToString()},
{"HighMemoryLoadThresholdBytes", memoryInfo.HighMemoryLoadThresholdBytes.ToString()},
{"TotalAvailableMemoryBytes", memoryInfo.TotalAvailableMemoryBytes.ToString()},
{"MemoryLoadBytes", memoryInfo.MemoryLoadBytes.ToString()},
};
#if NET5_0_OR_GREATER
values.Add("TotalCommittedBytes", memoryInfo.TotalCommittedBytes.ToString());
values.Add("PromotedBytes", memoryInfo.PromotedBytes.ToString());
values.Add("PinnedObjectsCount", memoryInfo.PinnedObjectsCount.ToString());
values.Add("PauseTimePercentage", memoryInfo.PauseTimePercentage.ToString());
values.Add("PauseDurations", memoryInfo.PauseDurations.ToString());
values.Add("Index", memoryInfo.Index.ToString());
values.Add("Generation", memoryInfo.Generation.ToString());
values.Add("FinalizationPendingCount", memoryInfo.FinalizationPendingCount.ToString());
values.Add("Concurrent", memoryInfo.Concurrent.ToString());
values.Add("Compacted", memoryInfo.Compacted.ToString());
#endif
contexts[MemoryInfoKey] = values;
SimonCropp marked this conversation as resolved.
Show resolved Hide resolved
#endif
}

private static IDictionary<string, string>? CultureInfoToDictionary(CultureInfo cultureInfo)
{
var dic = new Dictionary<string, string>();
Expand Down