feat: add stale connection stats tracking and varz exposure

This commit is contained in:
Joseph Doherty
2026-02-23 00:38:43 -05:00
parent eb25d52ed5
commit cd4ae3cce6
5 changed files with 64 additions and 0 deletions

View File

@@ -75,6 +75,27 @@ public class ServerStatsTests : IAsyncLifetime
client.StartTime.ShouldNotBe(default);
}
[Fact]
public void StaleConnection_stats_incremented_on_mark_closed()
{
var stats = new ServerStats();
stats.StaleConnectionClients.ShouldBe(0);
Interlocked.Increment(ref stats.StaleConnectionClients);
stats.StaleConnectionClients.ShouldBe(1);
}
[Fact]
public void StaleConnection_stats_all_fields_default_to_zero()
{
var stats = new ServerStats();
stats.StaleConnections.ShouldBe(0);
stats.StaleConnectionClients.ShouldBe(0);
stats.StaleConnectionRoutes.ShouldBe(0);
stats.StaleConnectionLeafs.ShouldBe(0);
stats.StaleConnectionGateways.ShouldBe(0);
}
private static int GetFreePort()
{
using var sock = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);