@@ -7,23 +7,22 @@ namespace ServiceControl.Audit.Persistence.RavenDB.CustomChecks;
77using NServiceBus . CustomChecks ;
88using NServiceBus . Logging ;
99
10- class CheckDirtyMemory ( DatabaseConfiguration databaseConfiguration ) : CustomCheck ( "ServiceControl.Audit database" , "Dirty memory trends" , TimeSpan . FromMinutes ( 5 ) )
10+ class CheckDirtyMemory ( MemoryInformationRetriever memoryInformationRetriever ) : CustomCheck ( "ServiceControl.Audit database" , "Dirty memory trends" , TimeSpan . FromMinutes ( 5 ) )
1111{
1212 readonly List < int > lastDirtyMemoryReads = [ ] ;
1313 public override async Task < CheckResult > PerformCheck ( CancellationToken cancellationToken = default )
1414 {
15- var retriever = GetMemoryRetriever ( ) ;
16- var ( isHighDirty , dirtyMemory ) = await retriever . GetMemoryInformation ( cancellationToken ) ;
15+ var ( isHighDirty , dirtyMemoryKb ) = await memoryInformationRetriever . GetMemoryInformation ( cancellationToken ) ;
1716
1817 if ( isHighDirty )
1918 {
20- var message = $ "There is a high level of dirty memory ({ dirtyMemory } kb). Check the ServiceControl " +
19+ var message = $ "There is a high level of dirty memory ({ dirtyMemoryKb } kb). Check the ServiceControl " +
2120 "troubleshooting guide for guidance on how to mitigate the issue." ;
2221 Log . Warn ( message ) ;
2322 return CheckResult . Failed ( message ) ;
2423 }
2524
26- lastDirtyMemoryReads . Add ( dirtyMemory ) ;
25+ lastDirtyMemoryReads . Add ( dirtyMemoryKb ) ;
2726 if ( lastDirtyMemoryReads . Count > 20 )
2827 {
2928 //cap the list at 20 which means we're keeping about 1 hour and 40 minutes of data
@@ -39,7 +38,7 @@ public override async Task<CheckResult> PerformCheck(CancellationToken cancellat
3938 // Three means we'll be observing for 15 minutes before calculating the trend
4039 case >= 3 when AnalyzeTrendUsingRegression ( lastDirtyMemoryReads ) == TrendDirection . Increasing :
4140 {
42- var message = $ "Dirty memory is increasing. Last available value is { dirtyMemory } kb. " +
41+ var message = $ "Dirty memory is increasing. Last available value is { dirtyMemoryKb } kb. " +
4342 $ "Check the ServiceControl troubleshooting guide for guidance on how to mitigate the issue.";
4443 Log . Warn ( message ) ;
4544 return CheckResult . Failed ( message ) ;
@@ -53,9 +52,6 @@ public override async Task<CheckResult> PerformCheck(CancellationToken cancellat
5352 return CheckResult . Pass ;
5453 }
5554
56- MemoryInformationRetriever _retriever ;
57- MemoryInformationRetriever GetMemoryRetriever ( ) => _retriever ??= new MemoryInformationRetriever ( databaseConfiguration . ServerConfiguration . ServerUrl ) ;
58-
5955 static TrendDirection AnalyzeTrendUsingRegression ( List < int > values )
6056 {
6157 if ( values is not { Count : > 1 } )
0 commit comments