diff --git a/src/ServiceControl.Audit.Persistence.RavenDB/CustomChecks/CheckDirtyMemory.cs b/src/ServiceControl.Audit.Persistence.RavenDB/CustomChecks/CheckDirtyMemory.cs index cedca079c4..37731858d8 100644 --- a/src/ServiceControl.Audit.Persistence.RavenDB/CustomChecks/CheckDirtyMemory.cs +++ b/src/ServiceControl.Audit.Persistence.RavenDB/CustomChecks/CheckDirtyMemory.cs @@ -10,11 +10,13 @@ class CheckDirtyMemory(MemoryInformationRetriever memoryInformationRetriever) : { public override async Task PerformCheck(CancellationToken cancellationToken = default) { - var (isHighDirty, dirtyMemoryKb) = await memoryInformationRetriever.GetMemoryInformation(cancellationToken); + var (isHighDirty, dirtyMemory) = await memoryInformationRetriever.GetMemoryInformation(cancellationToken); + + Log.Debug($"RavenDB dirty memory value: {dirtyMemory}."); if (isHighDirty) { - var message = $"There is a high level of RavenDB dirty memory ({dirtyMemoryKb}kb). See https://docs.particular.net/servicecontrol/troubleshooting#ravendb-dirty-memory for guidance on how to mitigate the issue."; + var message = $"There is a high level of RavenDB dirty memory ({dirtyMemory}). See https://docs.particular.net/servicecontrol/troubleshooting#ravendb-dirty-memory for guidance on how to mitigate the issue."; Log.Warn(message); return CheckResult.Failed(message); } diff --git a/src/ServiceControl.Audit.Persistence.RavenDB/MemoryInformationRetriever.cs b/src/ServiceControl.Audit.Persistence.RavenDB/MemoryInformationRetriever.cs index eea7d87865..452546521d 100644 --- a/src/ServiceControl.Audit.Persistence.RavenDB/MemoryInformationRetriever.cs +++ b/src/ServiceControl.Audit.Persistence.RavenDB/MemoryInformationRetriever.cs @@ -26,16 +26,11 @@ record MemoryInformation public string DirtyMemory { get; set; } } - public async Task<(bool IsHighDirty, int DirtyMemoryKb)> GetMemoryInformation(CancellationToken cancellationToken = default) + public async Task<(bool IsHighDirty, string DirtyMemory)> GetMemoryInformation(CancellationToken cancellationToken = default) { var httpResponse = await client.GetAsync("/admin/debug/memory/stats?includeThreads=false&includeMappings=false", cancellationToken); var responseDto = JsonSerializer.Deserialize(await httpResponse.Content.ReadAsStringAsync(cancellationToken)); - var values = responseDto.MemoryInformation.DirtyMemory.Split(' '); - if (!string.Equals(values[1], "KBytes", StringComparison.OrdinalIgnoreCase)) - { - throw new InvalidOperationException($"Unexpected response. Was expecting memory details in KBytes, instead received: {responseDto.MemoryInformation.DirtyMemory}"); - } - return (responseDto.MemoryInformation.IsHighDirty, int.Parse(values[0])); + return (responseDto.MemoryInformation.IsHighDirty, responseDto.MemoryInformation.DirtyMemory); } } \ No newline at end of file diff --git a/src/ServiceControl.Persistence.RavenDB/CustomChecks/CheckDirtyMemory.cs b/src/ServiceControl.Persistence.RavenDB/CustomChecks/CheckDirtyMemory.cs index fb0ec20c96..8eee53911a 100644 --- a/src/ServiceControl.Persistence.RavenDB/CustomChecks/CheckDirtyMemory.cs +++ b/src/ServiceControl.Persistence.RavenDB/CustomChecks/CheckDirtyMemory.cs @@ -10,11 +10,13 @@ class CheckDirtyMemory(MemoryInformationRetriever memoryInformationRetriever) : { public override async Task PerformCheck(CancellationToken cancellationToken = default) { - var (isHighDirty, dirtyMemoryKb) = await memoryInformationRetriever.GetMemoryInformation(cancellationToken); + var (isHighDirty, dirtyMemory) = await memoryInformationRetriever.GetMemoryInformation(cancellationToken); + + Log.Debug($"RavenDB dirty memory value: {dirtyMemory}."); if (isHighDirty) { - var message = $"There is a high level of RavenDB dirty memory ({dirtyMemoryKb}kb). See https://docs.particular.net/servicecontrol/troubleshooting#ravendb-dirty-memory for guidance on how to mitigate the issue."; + var message = $"There is a high level of RavenDB dirty memory ({dirtyMemory}). See https://docs.particular.net/servicecontrol/troubleshooting#ravendb-dirty-memory for guidance on how to mitigate the issue."; Log.Warn(message); return CheckResult.Failed(message); } diff --git a/src/ServiceControl.Persistence.RavenDB/MemoryInformationRetriever.cs b/src/ServiceControl.Persistence.RavenDB/MemoryInformationRetriever.cs index 485c6b6640..0b5e0d626d 100644 --- a/src/ServiceControl.Persistence.RavenDB/MemoryInformationRetriever.cs +++ b/src/ServiceControl.Persistence.RavenDB/MemoryInformationRetriever.cs @@ -25,16 +25,11 @@ record MemoryInformation public string DirtyMemory { get; set; } } - public async Task<(bool IsHighDirty, int DirtyMemoryKb)> GetMemoryInformation(CancellationToken cancellationToken = default) + public async Task<(bool IsHighDirty, string DirtyMemory)> GetMemoryInformation(CancellationToken cancellationToken = default) { var httpResponse = await client.GetAsync("/admin/debug/memory/stats?includeThreads=false&includeMappings=false", cancellationToken); var responseDto = JsonSerializer.Deserialize(await httpResponse.Content.ReadAsStringAsync(cancellationToken)); - var values = responseDto.MemoryInformation.DirtyMemory.Split(' '); - if (!string.Equals(values[1], "KBytes", StringComparison.OrdinalIgnoreCase)) - { - throw new InvalidOperationException($"Unexpected response. Was expecting memory details in KBytes, instead received: {responseDto.MemoryInformation.DirtyMemory}"); - } - return (responseDto.MemoryInformation.IsHighDirty, int.Parse(values[0])); + return (responseDto.MemoryInformation.IsHighDirty, responseDto.MemoryInformation.DirtyMemory); } } \ No newline at end of file