metrics(alarms): expose provider-switch count in snapshot, bound the reason tag

B1: add AlarmProviderSwitchCount to GatewayMetricsSnapshot so the switch total is
readable without scraping the OTEL counter.
B2: replace the free-text reason tag on mxgateway.alarms.provider_switches with a
bounded AlarmProviderSwitchReason enum (failover/failback/unknown); the human-readable
reason stays in the structured log.
This commit is contained in:
Joseph Doherty
2026-06-14 02:33:02 -04:00
parent 5b31e99ab6
commit 56abd64c6c
5 changed files with 47 additions and 8 deletions
@@ -111,12 +111,13 @@ public sealed class GatewayMetricsTests
});
listener.Start();
metrics.AlarmProviderSwitched(1, 2, "test");
metrics.AlarmProviderSwitched(1, 2, AlarmProviderSwitchReason.Failover);
Assert.Equal(1, capturedValue);
Assert.Equal("1", capturedFrom);
Assert.Equal("2", capturedTo);
Assert.Equal("test", capturedReason);
Assert.Equal("failover", capturedReason);
Assert.Equal(1, metrics.GetSnapshot().AlarmProviderSwitchCount);
}
/// <summary>
@@ -150,7 +151,7 @@ public sealed class GatewayMetricsTests
});
listener.Start();
metrics.AlarmProviderSwitched(1, 2, "test");
metrics.AlarmProviderSwitched(1, 2, AlarmProviderSwitchReason.Failover);
listener.RecordObservableInstruments();
Assert.Equal(2, capturedMode);