sprints enhancements
This commit is contained in:
@@ -59,6 +59,7 @@ public sealed class WriteBehindQueue : BackgroundService, IWriteBehindQueue
|
||||
|
||||
Interlocked.Increment(ref _totalEnqueued);
|
||||
Interlocked.Increment(ref _currentQueueDepth);
|
||||
ProvcacheTelemetry.SetWriteBehindQueueSize((int)Interlocked.Read(ref _currentQueueDepth));
|
||||
|
||||
return _channel.Writer.WriteAsync(item, cancellationToken);
|
||||
}
|
||||
@@ -143,6 +144,7 @@ public sealed class WriteBehindQueue : BackgroundService, IWriteBehindQueue
|
||||
private async Task ProcessBatchAsync(List<WriteBehindItem> batch, CancellationToken cancellationToken)
|
||||
{
|
||||
var entries = batch.Select(b => b.Entry).ToList();
|
||||
using var activity = ProvcacheTelemetry.StartWriteBehindFlushActivity(batch.Count);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -150,6 +152,8 @@ public sealed class WriteBehindQueue : BackgroundService, IWriteBehindQueue
|
||||
|
||||
Interlocked.Add(ref _totalPersisted, batch.Count);
|
||||
Interlocked.Increment(ref _totalBatches);
|
||||
ProvcacheTelemetry.RecordWriteBehind("ok", batch.Count);
|
||||
ProvcacheTelemetry.SetWriteBehindQueueSize((int)Interlocked.Read(ref _currentQueueDepth));
|
||||
|
||||
_logger.LogDebug(
|
||||
"Write-behind batch persisted {Count} entries",
|
||||
@@ -157,6 +161,7 @@ public sealed class WriteBehindQueue : BackgroundService, IWriteBehindQueue
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ProvcacheTelemetry.MarkError(activity, ex.Message);
|
||||
_logger.LogWarning(
|
||||
ex,
|
||||
"Write-behind batch failed for {Count} entries, scheduling retries",
|
||||
@@ -169,14 +174,17 @@ public sealed class WriteBehindQueue : BackgroundService, IWriteBehindQueue
|
||||
{
|
||||
var retryItem = item with { RetryCount = item.RetryCount + 1 };
|
||||
Interlocked.Increment(ref _totalRetries);
|
||||
ProvcacheTelemetry.RecordWriteBehind("retry", 1);
|
||||
|
||||
if (_channel.Writer.TryWrite(retryItem))
|
||||
{
|
||||
Interlocked.Increment(ref _currentQueueDepth);
|
||||
ProvcacheTelemetry.SetWriteBehindQueueSize((int)Interlocked.Read(ref _currentQueueDepth));
|
||||
}
|
||||
else
|
||||
{
|
||||
Interlocked.Increment(ref _totalFailed);
|
||||
ProvcacheTelemetry.RecordWriteBehind("failed", 1);
|
||||
_logger.LogError(
|
||||
"Write-behind queue full, dropping entry for VeriKey {VeriKey}",
|
||||
item.Entry.VeriKey);
|
||||
@@ -185,6 +193,7 @@ public sealed class WriteBehindQueue : BackgroundService, IWriteBehindQueue
|
||||
else
|
||||
{
|
||||
Interlocked.Increment(ref _totalFailed);
|
||||
ProvcacheTelemetry.RecordWriteBehind("failed", 1);
|
||||
_logger.LogError(
|
||||
"Write-behind max retries exceeded for VeriKey {VeriKey}",
|
||||
item.Entry.VeriKey);
|
||||
|
||||
Reference in New Issue
Block a user