using ZB.MOM.WW.ScadaBridge.Commons.Types.Kpi;
namespace ZB.MOM.WW.ScadaBridge.Commons.Tests.Kpi;
///
/// Tests for — the gauge-vs-rate
/// classification the hourly rollup fold consults. Covers totality over every
/// metric the four IKpiSampleSource implementations actually emit, the
/// specific Rate set, a gauge sampling, and the unknown-metric default.
///
public class KpiMetricAggregationTests
{
// Every (source, metric) pair emitted by the four sample sources, transcribed
// from the source code. The catalog must classify all of them (totality).
public static readonly (string Source, string Metric)[] AllEmittedMetrics =
{
// NotificationOutboxKpiSampleSource
(KpiSources.NotificationOutbox, "queueDepth"),
(KpiSources.NotificationOutbox, "stuckCount"),
(KpiSources.NotificationOutbox, "parkedCount"),
(KpiSources.NotificationOutbox, "deliveredLastInterval"),
(KpiSources.NotificationOutbox, "oldestPendingAgeSeconds"),
// SiteCallAuditKpiSampleSource
(KpiSources.SiteCallAudit, "buffered"),
(KpiSources.SiteCallAudit, "parked"),
(KpiSources.SiteCallAudit, "failedLastInterval"),
(KpiSources.SiteCallAudit, "deliveredLastInterval"),
(KpiSources.SiteCallAudit, "stuck"),
(KpiSources.SiteCallAudit, "oldestPendingAgeSeconds"),
// AuditLogKpiSampleSource
(KpiSources.AuditLog, "totalEventsLastHour"),
(KpiSources.AuditLog, "errorEventsLastHour"),
(KpiSources.AuditLog, "backlogTotal"),
// SiteHealthKpiSampleSource
(KpiSources.SiteHealth, "connectionsUp"),
(KpiSources.SiteHealth, "connectionsDown"),
(KpiSources.SiteHealth, "scriptErrors"),
(KpiSources.SiteHealth, "alarmEvalErrors"),
(KpiSources.SiteHealth, "sfBufferDepth"),
(KpiSources.SiteHealth, "deadLetters"),
(KpiSources.SiteHealth, "parkedMessages"),
(KpiSources.SiteHealth, "deployedInstances"),
(KpiSources.SiteHealth, "enabledInstances"),
(KpiSources.SiteHealth, "disabledInstances"),
(KpiSources.SiteHealth, "auditBacklogPending"),
(KpiSources.SiteHealth, "eventLogWriteFailures"),
};
// The (source, metric) pairs that must fold as Rate (sum-per-hour).
public static readonly (string Source, string Metric)[] RateMetrics =
{
(KpiSources.NotificationOutbox, "deliveredLastInterval"),
(KpiSources.SiteCallAudit, "failedLastInterval"),
(KpiSources.SiteCallAudit, "deliveredLastInterval"),
(KpiSources.SiteHealth, "scriptErrors"),
(KpiSources.SiteHealth, "alarmEvalErrors"),
(KpiSources.SiteHealth, "deadLetters"),
(KpiSources.SiteHealth, "eventLogWriteFailures"),
};
// A representative sampling of gauges — including the two *LastHour audit
// metrics that are rolling last-hour gauges, NOT rates (deliberate override).
public static readonly (string Source, string Metric)[] GaugeSampling =
{
(KpiSources.NotificationOutbox, "queueDepth"),
(KpiSources.NotificationOutbox, "oldestPendingAgeSeconds"),
(KpiSources.SiteCallAudit, "buffered"),
(KpiSources.SiteCallAudit, "stuck"),
(KpiSources.AuditLog, "backlogTotal"),
(KpiSources.AuditLog, "totalEventsLastHour"),
(KpiSources.AuditLog, "errorEventsLastHour"),
(KpiSources.SiteHealth, "connectionsUp"),
(KpiSources.SiteHealth, "connectionsDown"),
(KpiSources.SiteHealth, "sfBufferDepth"),
(KpiSources.SiteHealth, "deployedInstances"),
};
public static IEnumerable