Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ class CheckDirtyMemory(MemoryInformationRetriever memoryInformationRetriever) :
{
public override async Task<CheckResult> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ResponseDto>(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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ class CheckDirtyMemory(MemoryInformationRetriever memoryInformationRetriever) :
{
public override async Task<CheckResult> 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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<ResponseDto>(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);
}
}