-
-
Notifications
You must be signed in to change notification settings - Fork 225
Automatically capture heap dumps #3667
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
Merged
Merged
Changes from 32 commits
Commits
Show all changes
85 commits
Select commit
Hold shift + click to select a range
44b7d65
POC
jamescrosswell 157a4a9
Configurable level
jamescrosswell 67a1c38
Changed dependency from net5.0 to net6.0
jamescrosswell 4f8f917
Format code
getsentry-bot 0d1aa2d
Update MemoryMonitor.cs
jamescrosswell 5ceff11
Exclude on Android and iOS
jamescrosswell ae55ae9
Bundle dotnet-gcdump in the Sentry nuget package
jamescrosswell c5b75ad
Merge branch 'auto-heap-dump' of github.com:getsentry/sentry-dotnet i…
jamescrosswell 60aeda0
Format code
getsentry-bot cc1a00e
Fixed Bindable tests
jamescrosswell b02fa28
Update CHANGELOG.md
jamescrosswell 0625662
Merge branch 'auto-heap-dump' of github.com:getsentry/sentry-dotnet i…
jamescrosswell 1d12b7c
Merge branch 'version-5.0.0' into auto-heap-dump
jamescrosswell ecfbce3
Update CHANGELOG.md
jamescrosswell 1e6d29b
Tweaked the demos
jamescrosswell 5b0f08e
Revert "Bundle dotnet-gcdump in the Sentry nuget package"
jamescrosswell ba4bcd9
Unbundled GCDump from NuGet package
jamescrosswell a357e9f
Switched to built in GC.RegisterForFullGCNotification events for garb…
jamescrosswell b6c3bff
Tweaked settings to expedite full GC in Heap Dump sample
jamescrosswell e36dfef
Added TryGetDumpLocation tests
jamescrosswell d35477b
Added CaptureMemoryDump tests
jamescrosswell 4c0ccc8
Refactored MemoryMonitor to use triggers and debouncers
jamescrosswell ffad135
Format code
getsentry-bot 265e397
Fixed tests
jamescrosswell 7a3b109
Merge branch 'auto-heap-dump' of github.com:getsentry/sentry-dotnet i…
jamescrosswell da07de2
Format code
getsentry-bot 975b9b1
Added CheckMemoryUsage tests
jamescrosswell 38ad7bc
Fixed remaining BindableOptions tests
jamescrosswell ef3a33f
Merge branch 'auto-heap-dump' of github.com:getsentry/sentry-dotnet i…
jamescrosswell 4b86619
Bundle dotnet-gcdump in Sentry.nupkg
jamescrosswell 08c9db4
Use bundled version of gcdump if it is present
jamescrosswell 169ef49
Delete buildlog.txt
jamescrosswell 2e6a0f1
Review feedback
jamescrosswell 87b76d8
Refactored error handling on garbage collection monitor to use a Cont…
jamescrosswell 3f15073
Comment in Dispose
jamescrosswell 2dfd4f4
Review feedback
jamescrosswell 99af671
Use _options.FileSystem
jamescrosswell acf93ab
Type
jamescrosswell 8708377
Merge branch 'version-5.0.0' into auto-heap-dump
jamescrosswell 3b62d53
Merge branch 'auto-heap-dump' of github.com:getsentry/sentry-dotnet i…
jamescrosswell 2a3d8b7
GCDump.props now downloads nuget directly, rather than installing dot…
jamescrosswell 3eb2f73
Created separate demo and tweaked the API
jamescrosswell 60f0b7e
Format code
getsentry-bot 70486da
Typo in transitive build file
jamescrosswell d2755db
Merge branch 'auto-heap-dump' of github.com:getsentry/sentry-dotnet i…
jamescrosswell 8133a63
Updated solution filters
jamescrosswell 58d9e55
Reverted to Continuation to handle errors in the gc monitor
jamescrosswell 7135767
Review feedback
jamescrosswell 22760c8
Update SentrySdk.cs
jamescrosswell f371304
Update Directory.Build.props
jamescrosswell 26c85b8
release: 14.12.1-dump1
getsentry-bot 0142d29
Workaround issue in release action
jamescrosswell 8a831fc
Revert "Workaround issue in release action"
jamescrosswell 056ec48
Merge branch 'release/14.12.1-dump1' into auto-heap-dump
29058f1
Revert "Merge branch 'release/14.12.1-dump1' into auto-heap-dump"
jamescrosswell 5469815
Review feedback
jamescrosswell f1c9e64
Merge branch 'version-5.0.0' into auto-heap-dump
jamescrosswell 8a49c01
Update ApiApprovalTests.Run.DotNet9_0.verified.txt
jamescrosswell dbe9f60
Update action.yml
jamescrosswell be63db4
Revert "Update action.yml"
jamescrosswell 36e4a2b
Update workaround for slow release builds for ios
jamescrosswell 076e9f9
Removed async void unit tests
jamescrosswell 506fba1
Drop net6.0 target from Sentry.Tests
jamescrosswell 298f57c
Add diagnostic logging for Windows tests
jamescrosswell a234ef2
Update build.yml
jamescrosswell f4fba3a
Merge branch 'version-5.0.0' into auto-heap-dump
jamescrosswell 4eafc16
Disabled diagnostics output on windows tests
jamescrosswell a09ffef
Update build.yml
jamescrosswell b8cffed
Use mock GC implementation for MemoryMonitorTests
jamescrosswell b216a3c
Update Sentry.Tests.csproj
jamescrosswell e1ba7c2
Try disabling heapdump tests on Windows in CI
jamescrosswell 2c79a4a
Reverse skip condition
jamescrosswell 72c90b5
Try re-enabling GarbageCollectionMonitorTests on Windows
jamescrosswell cadd0cf
Try reinstating MemoryMonitorTests (constructor test changed)
jamescrosswell 84c436f
Update MemoryMonitor.cs
jamescrosswell 3a9ba29
Refactored Constructor_NoHeapdumpsConfigured_Throws
jamescrosswell 9fea039
Try re-enabling remaining MemoryMonitorTests
jamescrosswell 845378c
Re-enable remaining MemoryMonitorTests
jamescrosswell 4245a75
Unbundled dotnet-gcdump
jamescrosswell 5865245
Disable CaptureMemoryDump and TryGetDumpLocation tests
jamescrosswell d9b9306
Re-enable CaptureMemoryDump tests
jamescrosswell 13bfe6f
Disable CaptureMemoryDump and enable TryGetDumpLocation
jamescrosswell d330c2c
Fixed CaptureMemoryDump_CapturesDump
jamescrosswell 8127bb5
Added remarks about dotnet-gcdump dependency to options
jamescrosswell e628bb3
Merge branch 'version-5.0.0' into auto-heap-dump
bruno-garcia 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
6 changes: 6 additions & 0 deletions
6
samples/Sentry.Samples.Console.Basic/runtimeconfig.template.json
This file contains hidden or 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,6 @@ | ||
| { | ||
| "configProperties": { | ||
jamescrosswell marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| "System.GC.ConserveMemory": 9, | ||
| "System.GC.HighMemoryPercent": 20 | ||
| } | ||
| } | ||
This file contains hidden or 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 hidden or 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,108 @@ | ||
| namespace Sentry; | ||
|
|
||
| /// <summary> | ||
| /// A debouncer that can be used to limit the number of occurrences of an event within a given interval and optionally, | ||
| /// enforce a minimum cooldown period between events. | ||
| /// </summary> | ||
| public class Debouncer | ||
| { | ||
| internal enum DebouncerInterval { Minute, Hour, Day, ApplicationLifetime } | ||
|
|
||
| internal DateTimeOffset _intervalStart = DateTimeOffset.MinValue; | ||
| internal DateTimeOffset _lastEvent = DateTimeOffset.MinValue; | ||
| internal int _occurrences; | ||
|
|
||
| internal readonly DebouncerInterval _intervalType; | ||
| internal readonly int _eventMaximum; | ||
| private readonly TimeSpan? _cooldown; | ||
|
|
||
| private Debouncer(DebouncerInterval intervalType, int eventMaximum = 1, TimeSpan? cooldown = null) | ||
| { | ||
| _intervalType = intervalType; | ||
| _cooldown = cooldown; | ||
| _eventMaximum = eventMaximum; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Creates a debouncer that limits the number of events per minute | ||
| /// </summary> | ||
| /// <param name="eventMaximum">The maximum number of events that will be processed per minute</param> | ||
| /// <param name="cooldown">An optional obligatory cooldown since the last event before any other events will be processed</param> | ||
| /// <returns></returns> | ||
| public static Debouncer PerMinute(int eventMaximum = 1, TimeSpan? cooldown = null) | ||
| => new(DebouncerInterval.Minute, eventMaximum, cooldown); | ||
|
|
||
| /// <summary> | ||
| /// Creates a debouncer that limits the number of events per hour | ||
| /// </summary> | ||
| /// <param name="eventMaximum">The maximum number of events that will be processed per hour</param> | ||
| /// <param name="cooldown">An optional obligatory cooldown since the last event before any other events will be processed</param> | ||
| /// <returns></returns> | ||
| public static Debouncer PerHour(int eventMaximum = 1, TimeSpan? cooldown = null) | ||
| => new(DebouncerInterval.Hour, eventMaximum, cooldown); | ||
|
|
||
| /// <summary> | ||
| /// Creates a debouncer that limits the number of events per day | ||
| /// </summary> | ||
| /// <param name="eventMaximum">The maximum number of events that will be processed per day</param> | ||
| /// <param name="cooldown">An optional obligatory cooldown since the last event before any other events will be processed</param> | ||
| /// <returns></returns> | ||
| public static Debouncer PerDay(int eventMaximum = 1, TimeSpan? cooldown = null) | ||
| => new(DebouncerInterval.Day, eventMaximum, cooldown); | ||
|
|
||
| /// <summary> | ||
| /// Creates a debouncer that limits the number of events that will be processed for the lifetime of the application | ||
| /// </summary> | ||
| /// <param name="eventMaximum">The maximum number of events that will be processed</param> | ||
| /// <param name="cooldown">An optional obligatory cooldown since the last event before any other events will be processed</param> | ||
| /// <returns></returns> | ||
| public static Debouncer PerApplicationLifetime(int eventMaximum = 1, TimeSpan? cooldown = null) | ||
| => new(DebouncerInterval.ApplicationLifetime, eventMaximum, cooldown); | ||
|
|
||
| private TimeSpan IntervalTimeSpan() | ||
| { | ||
| switch (_intervalType) | ||
| { | ||
| case DebouncerInterval.Minute: | ||
| return TimeSpan.FromMinutes(1); | ||
| case DebouncerInterval.Hour: | ||
| return TimeSpan.FromHours(1); | ||
| case DebouncerInterval.Day: | ||
| return TimeSpan.FromDays(1); | ||
| case DebouncerInterval.ApplicationLifetime: | ||
| return TimeSpan.MaxValue; | ||
| default: | ||
| throw new ArgumentOutOfRangeException(nameof(_intervalType)); | ||
jamescrosswell marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
|
|
||
| internal void RecordOccurence(DateTimeOffset? timestamp = null) | ||
| { | ||
| var eventTime = timestamp ?? DateTimeOffset.UtcNow; | ||
|
|
||
| if (eventTime - _intervalStart >= IntervalTimeSpan()) | ||
| { | ||
| _intervalStart = eventTime; | ||
| _occurrences = 0; | ||
| } | ||
|
|
||
| _occurrences++; | ||
| _lastEvent = eventTime; | ||
| } | ||
|
|
||
| internal bool CanProcess(DateTimeOffset? timestamp = null) | ||
| { | ||
| if (_occurrences >= _eventMaximum) | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| var eventTime = timestamp ?? DateTimeOffset.UtcNow; | ||
| if (_cooldown is { } cooldown && _lastEvent + cooldown > eventTime) | ||
| { | ||
| return false; | ||
| } | ||
|
|
||
| return true; | ||
jamescrosswell marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
This file contains hidden or 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,30 @@ | ||
| <Project> | ||
| <!-- Check if we're building for a target framework that supports dotnet-gcdump --> | ||
| <PropertyGroup> | ||
| <PlatformIsLegacy Condition="$(TargetFramework.StartsWith('net4')) or $(TargetFramework.StartsWith('netstandard'))">true</PlatformIsLegacy> | ||
| <PlatformIsMobile Condition="$(TargetFramework.EndsWith('android')) or $(TargetFramework.EndsWith('ios')) or $(TargetFramework.EndsWith('maccatalyst'))">true</PlatformIsMobile> | ||
| <PlatformSupportsGcDump Condition="!($(PlatformIsLegacy) == 'true' or $(PlatformIsMobile) == 'true')">true</PlatformSupportsGcDump> | ||
|
|
||
| <GCDumpVersion>8.0.547301</GCDumpVersion> | ||
bruno-garcia marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| <GCDumpRootDirectory>$([System.IO.Path]::GetFullPath('$(MSBuildThisFileDirectory)..\..\tools\gcdump\'))</GCDumpRootDirectory> | ||
| <GCDumpTempDirectory>$(GCDumpRootDirectory)$(GCDumpVersion)\</GCDumpTempDirectory> | ||
| <!-- This is just where the relevant files are stored in the dotnet-gcdump Nuget package --> | ||
| <GCDumpIncludeFiles>$(GCDumpTempDirectory).store\dotnet-gcdump\$(GCDumpVersion)\dotnet-gcdump\$(GCDumpVersion)\tools\net6.0\any\</GCDumpIncludeFiles> | ||
| </PropertyGroup> | ||
|
|
||
| <Target Name="DownloadGCDump" BeforeTargets="CollectPackageReferences" Condition="'$(PlatformSupportsGcDump)' == 'true'"> | ||
| <Message Importance="normal" Text="Found dotnet-gcdump - skipping download... " Condition="Exists('$(GCDumpIncludeFiles)')" /> | ||
| <Message Importance="normal" Text="dotnet-gcdump not found... downloading to $(GCDumpTempDirectory)" Condition="!Exists('$(GCDumpIncludeFiles)')" /> | ||
|
|
||
| <!-- NuGet doesn't have any "download" functionality, so we'll install it locally to a temporary folder --> | ||
jamescrosswell marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| <Exec Command="dotnet tool install dotnet-gcdump --version $(GCDumpVersion) --tool-path $(GCDumpTempDirectory)" Condition="!Exists('$(GCDumpIncludeFiles)')" IgnoreExitCode="true" /> | ||
jamescrosswell marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| <Message Importance="high" Text="Unable to locate dotnet-gcdump files after install : $(GCDumpIncludeFiles)" Condition="!Exists('$(GCDumpIncludeFiles)')" /> | ||
| </Target> | ||
|
|
||
| <!-- Include GCDump in the Sentry Nuget package. --> | ||
| <ItemGroup Condition="'$(PlatformSupportsGcDump)' == 'true'"> | ||
| <None Include="$(GCDumpIncludeFiles)**" Pack="true" PackagePath="tools\dotnet-gcdump\" /> | ||
| </ItemGroup> | ||
|
|
||
| </Project> | ||
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.