D1: surface AlarmProviderSwitchCount on dashboard metric list

This commit is contained in:
Joseph Doherty
2026-06-14 23:49:02 -04:00
parent 371ce53409
commit 4af24b9518
2 changed files with 19 additions and 0 deletions
@@ -195,6 +195,7 @@ public sealed class DashboardSnapshotService : IDashboardSnapshotService
new("mxgateway.workers.exited", snapshot.WorkerExits),
new("mxgateway.heartbeats.failed", snapshot.HeartbeatFailures),
new("mxgateway.grpc.streams.disconnected", snapshot.StreamDisconnects),
new("mxgateway.alarms.provider_switches", snapshot.AlarmProviderSwitchCount),
];
metrics.AddRange(snapshot.CommandFailuresByMethod
@@ -94,6 +94,24 @@ public sealed class DashboardSnapshotServiceTests
Assert.Equal("worker pipe disconnected", fault.Message);
}
/// <summary>
/// Verifies snapshot metrics include the cumulative alarm provider switch count.
/// </summary>
[Fact]
public void GetSnapshot_IncludesAlarmProviderSwitchCountMetric()
{
SessionRegistry registry = new();
using GatewayMetrics metrics = new();
metrics.AlarmProviderSwitched(1, 2, AlarmProviderSwitchReason.Failover);
DashboardSnapshotService service = CreateService(registry, metrics);
DashboardSnapshot snapshot = service.GetSnapshot();
Assert.Contains(
snapshot.Metrics,
metric => metric.Name == "mxgateway.alarms.provider_switches" && metric.Value == 1);
}
/// <summary>
/// Verifies snapshot redacts sensitive values from client identity, session name, and fault messages.
/// </summary>