-
-
Notifications
You must be signed in to change notification settings - Fork 205
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
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
b01f17c
AddMemoryInfo
SimonCropp 8674995
Merge branch 'main' into AddMemoryInfo
SimonCropp d31efab
Merge branch 'main' into AddMemoryInfo
SimonCropp 8e08af9
Merge branch 'main' into AddMemoryInfo
SimonCropp 28f93d4
Merge branch 'main' into AddMemoryInfo
SimonCropp fd8855a
Update src/Sentry/Internal/MainSentryEventProcessor.cs
SimonCropp 17c4fae
Merge branch 'main' into AddMemoryInfo
SimonCropp 8e7c664
Merge branch 'main' into AddMemoryInfo
SimonCropp dfbe02b
Merge branch 'main' into AddMemoryInfo
SimonCropp 05462d4
Update CHANGELOG.md
SimonCropp dd1fa6b
Merge branch 'main' into AddMemoryInfo
SimonCropp c147960
.
SimonCropp dfe09cf
Format code
getsentry-bot d00ddf8
Merge branch 'main' into AddMemoryInfo
SimonCropp 34a3074
Merge branch 'main' into AddMemoryInfo
SimonCropp c332a1c
Update src/Sentry/Internal/MainSentryEventProcessor.cs
SimonCropp e9cfa49
.
SimonCropp 1fc5af7
Merge branch 'main' into AddMemoryInfo
SimonCropp f5f6d88
.
SimonCropp dd7827b
Format code
getsentry-bot 46fe6b1
Update MainSentryEventProcessorTests.cs
SimonCropp f4b2f96
Update MainSentryEventProcessorTests.cs
SimonCropp a16a350
Merge branch 'AddMemoryInfo' of https://github.com/getsentry/sentry-d…
SimonCropp 6b1e286
.
SimonCropp b914fbf
Format code
getsentry-bot 5104de7
Update MainSentryEventProcessorTests.cs
SimonCropp aa844a9
Update MainSentryEventProcessorTests.cs
SimonCropp b064d72
Merge branch 'AddMemoryInfo' of https://github.com/getsentry/sentry-d…
SimonCropp 6e234b2
Update CHANGELOG.md
SimonCropp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
#if NETCOREAPP3_0_OR_GREATER | ||
|
||
using System; | ||
using System.Text.Json; | ||
using Sentry.Extensibility; | ||
|
||
namespace Sentry | ||
{ | ||
internal sealed class MemoryInfo : IJsonSerializable | ||
{ | ||
public long AllocatedBytes { get; } | ||
public long FragmentedBytes { get; } | ||
public long HeapSizeBytes { get; } | ||
public long HighMemoryLoadThresholdBytes { get; } | ||
public long TotalAvailableMemoryBytes { get; } | ||
public long MemoryLoadBytes { get; } | ||
|
||
#if NET5_0_OR_GREATER | ||
public long TotalCommittedBytes { get; } | ||
public long PromotedBytes { get; } | ||
public long PinnedObjectsCount { get; } | ||
public double PauseTimePercentage { get; } | ||
public TimeSpan[] PauseDurations { get; } | ||
public long Index { get; } | ||
public int Generation { get; } | ||
public long FinalizationPendingCount { get; } | ||
public bool Compacted { get; } | ||
public bool Concurrent { get; } | ||
|
||
public MemoryInfo( | ||
long allocatedBytes, | ||
long fragmentedBytes, | ||
long heapSizeBytes, | ||
long highMemoryLoadThresholdBytes, | ||
long totalAvailableMemoryBytes, | ||
long memoryLoadBytes, | ||
long totalCommittedBytes, | ||
long promotedBytes, | ||
long pinnedObjectsCount, | ||
double pauseTimePercentage, | ||
long index, | ||
int generation, | ||
long finalizationPendingCount, | ||
bool compacted, | ||
bool concurrent, | ||
TimeSpan[] pauseDurations) | ||
{ | ||
AllocatedBytes = allocatedBytes; | ||
FragmentedBytes = fragmentedBytes; | ||
HeapSizeBytes = heapSizeBytes; | ||
HighMemoryLoadThresholdBytes = highMemoryLoadThresholdBytes; | ||
TotalAvailableMemoryBytes = totalAvailableMemoryBytes; | ||
MemoryLoadBytes = memoryLoadBytes; | ||
TotalCommittedBytes = totalCommittedBytes; | ||
PromotedBytes = promotedBytes; | ||
PinnedObjectsCount = pinnedObjectsCount; | ||
PauseTimePercentage = pauseTimePercentage; | ||
PauseDurations = pauseDurations; | ||
Index = index; | ||
Generation = generation; | ||
FinalizationPendingCount = finalizationPendingCount; | ||
Compacted = compacted; | ||
Concurrent = concurrent; | ||
} | ||
#else | ||
public MemoryInfo( | ||
long allocatedBytes, | ||
long fragmentedBytes, | ||
long heapSizeBytes, | ||
long highMemoryLoadThresholdBytes, | ||
long totalAvailableMemoryBytes, | ||
long memoryLoadBytes) | ||
{ | ||
AllocatedBytes = allocatedBytes; | ||
FragmentedBytes = fragmentedBytes; | ||
HeapSizeBytes = heapSizeBytes; | ||
HighMemoryLoadThresholdBytes = highMemoryLoadThresholdBytes; | ||
TotalAvailableMemoryBytes = totalAvailableMemoryBytes; | ||
MemoryLoadBytes = memoryLoadBytes; | ||
} | ||
#endif | ||
public void WriteTo(Utf8JsonWriter writer, IDiagnosticLogger? logger) | ||
{ | ||
writer.WriteStartObject(); | ||
|
||
writer.WriteNumber("allocatedBytes", AllocatedBytes); | ||
writer.WriteNumber("fragmentedBytes", FragmentedBytes); | ||
writer.WriteNumber("heapSizeBytes", HeapSizeBytes); | ||
writer.WriteNumber("highMemoryLoadThresholdBytes", HighMemoryLoadThresholdBytes); | ||
writer.WriteNumber("totalAvailableMemoryBytes", TotalAvailableMemoryBytes); | ||
writer.WriteNumber("memoryLoadBytes", MemoryLoadBytes); | ||
|
||
#if NET5_0_OR_GREATER | ||
writer.WriteNumber("totalCommittedBytes", TotalCommittedBytes); | ||
writer.WriteNumber("promotedBytes", PromotedBytes); | ||
writer.WriteNumber("pinnedObjectsCount", PinnedObjectsCount); | ||
writer.WriteNumber("pauseTimePercentage", PauseTimePercentage); | ||
writer.WriteNumber("index", Index); | ||
writer.WriteNumber("generation", Generation); | ||
writer.WriteNumber("finalizationPendingCount", FinalizationPendingCount); | ||
writer.WriteBoolean("compacted", Compacted); | ||
writer.WriteBoolean("concurrent", Concurrent); | ||
writer.WritePropertyName("pauseDurations"); | ||
writer.WriteStartArray(); | ||
foreach (var duration in PauseDurations) | ||
{ | ||
writer.WriteNumberValue(duration.TotalMilliseconds); | ||
} | ||
writer.WriteEndArray(); | ||
#endif | ||
writer.WriteEndObject(); | ||
} | ||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#if NETCOREAPP3_1_OR_GREATER | ||
using System.Text.Json; | ||
|
||
public class MemoryInfoTests | ||
{ | ||
[Fact] | ||
public void WriteTo() | ||
{ | ||
#if NET5_0_OR_GREATER | ||
var info = new MemoryInfo(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, true, false, new[] { TimeSpan.FromSeconds(1) }); | ||
#else | ||
var info = new MemoryInfo(1, 2, 3, 4, 5, 6); | ||
#endif | ||
|
||
var stream = new MemoryStream(); | ||
var writer = new Utf8JsonWriter(stream, new JsonWriterOptions { Indented = true }); | ||
info.WriteTo(writer, null); | ||
writer.Flush(); | ||
var json = Encoding.UTF8.GetString(stream.ToArray()); | ||
Assert.NotNull(json); | ||
Assert.NotEmpty(json); | ||
//Validate json | ||
var serializer = new Newtonsoft.Json.JsonSerializer(); | ||
serializer.Deserialize(new Newtonsoft.Json.JsonTextReader(new StringReader(json))); | ||
} | ||
} | ||
#endif |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, we should've added this as feature. Rolled out as 3.12.3