feat: add per-account message/byte stats with Interlocked counters

This commit is contained in:
Joseph Doherty
2026-02-23 04:33:44 -05:00
parent 4836f7851e
commit a406832bfa
2 changed files with 71 additions and 0 deletions

View File

@@ -48,5 +48,28 @@ public sealed class Account : IDisposable
Interlocked.Decrement(ref _subscriptionCount);
}
// Per-account message/byte stats
private long _inMsgs;
private long _outMsgs;
private long _inBytes;
private long _outBytes;
public long InMsgs => Interlocked.Read(ref _inMsgs);
public long OutMsgs => Interlocked.Read(ref _outMsgs);
public long InBytes => Interlocked.Read(ref _inBytes);
public long OutBytes => Interlocked.Read(ref _outBytes);
public void IncrementInbound(long msgs, long bytes)
{
Interlocked.Add(ref _inMsgs, msgs);
Interlocked.Add(ref _inBytes, bytes);
}
public void IncrementOutbound(long msgs, long bytes)
{
Interlocked.Add(ref _outMsgs, msgs);
Interlocked.Add(ref _outBytes, bytes);
}
public void Dispose() => SubList.Dispose();
}