feat(health): oldest-parked-message age on the site health report (parked-retention aging signal)
This commit is contained in:
@@ -25,6 +25,10 @@ public class SiteHealthCollector : ISiteHealthCollector
|
||||
private IReadOnlyDictionary<string, int> _sfBufferDepths = new Dictionary<string, int>();
|
||||
private int _deployedInstanceCount, _enabledInstanceCount, _disabledInstanceCount;
|
||||
private int _parkedMessageCount;
|
||||
// Age (seconds) of the oldest parked message, stored as raw double bits so it can
|
||||
// be read/written atomically via Interlocked (double? is neither atomic nor
|
||||
// volatile-able). NaN is the "no parked rows" sentinel (ages are always >= 0).
|
||||
private long _oldestParkedAgeBits = BitConverter.DoubleToInt64Bits(double.NaN);
|
||||
private volatile string _nodeHostname = "";
|
||||
private volatile IReadOnlyList<Commons.Messages.Health.NodeStatus>? _clusterNodes;
|
||||
private volatile bool _isActiveNode;
|
||||
@@ -123,6 +127,20 @@ public class SiteHealthCollector : ISiteHealthCollector
|
||||
Interlocked.Exchange(ref _parkedMessageCount, count);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void SetOldestParkedMessageAgeSeconds(double? ageSeconds)
|
||||
{
|
||||
Interlocked.Exchange(ref _oldestParkedAgeBits,
|
||||
BitConverter.DoubleToInt64Bits(ageSeconds ?? double.NaN));
|
||||
}
|
||||
|
||||
/// <summary>Reads the atomically-stored oldest-parked age, mapping the NaN sentinel back to null.</summary>
|
||||
private double? ReadOldestParkedAgeSeconds()
|
||||
{
|
||||
var value = BitConverter.Int64BitsToDouble(Interlocked.Read(ref _oldestParkedAgeBits));
|
||||
return double.IsNaN(value) ? null : value;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public void SetNodeHostname(string hostname) => _nodeHostname = hostname;
|
||||
|
||||
@@ -214,6 +232,7 @@ public class SiteHealthCollector : ISiteHealthCollector
|
||||
SiteAuditWriteFailures: siteAuditWriteFailures,
|
||||
AuditRedactionFailure: auditRedactionFailures,
|
||||
SiteAuditBacklog: _siteAuditBacklog,
|
||||
SiteEventLogWriteFailures: Interlocked.Read(ref _siteEventLogWriteFailures));
|
||||
SiteEventLogWriteFailures: Interlocked.Read(ref _siteEventLogWriteFailures),
|
||||
OldestParkedMessageAgeSeconds: ReadOldestParkedAgeSeconds());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user