feat(kpi): K9 — SiteHealth sample source (per-site, from aggregator)

This commit is contained in:
Joseph Doherty
2026-06-17 20:20:18 -04:00
parent cb2a516187
commit 601cc6f594
3 changed files with 329 additions and 0 deletions
@@ -3,6 +3,7 @@ using Microsoft.Extensions.DependencyInjection.Extensions;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Kpi;
namespace ZB.MOM.WW.ScadaBridge.HealthMonitoring;
@@ -61,6 +62,14 @@ public static class ServiceCollectionExtensions
services.AddSingleton<ICentralHealthAggregator>(sp => sp.GetRequiredService<CentralHealthAggregator>());
services.AddHostedService(sp => sp.GetRequiredService<CentralHealthAggregator>());
services.AddHostedService<CentralHealthReportLoop>();
// M6 "KPI History & Trends" (K9): per-site Site Health KPI sample source.
// Reads the in-memory central aggregator (a singleton) rather than a
// repository; registered Scoped to match the recorder's per-tick scope
// and the other M6 sample sources (a scoped source over a singleton
// dependency is fine — no captive dependency).
services.TryAddEnumerable(
ServiceDescriptor.Scoped<IKpiSampleSource, Kpi.SiteHealthKpiSampleSource>());
return services;
}