refactor(kpi): K2/K6/K7 review fixups — empty-batch guard + sealed repo + uniform TryAddEnumerable + KPI-age doc fidelity + coverage

This commit is contained in:
Joseph Doherty
2026-06-17 20:00:43 -04:00
parent 456e61dff3
commit e6c15250ce
7 changed files with 46 additions and 8 deletions
@@ -20,9 +20,12 @@ namespace ZB.MOM.WW.ScadaBridge.SiteCallAudit.Kpi;
/// The cutoffs are derived from <see cref="SiteCallAuditOptions"/> exactly as the
/// live <c>SiteCallAuditActor</c> KPI handlers derive them
/// (<c>stuckCutoff = capturedAtUtc - StuckAgeThreshold</c>,
/// <c>intervalSince = capturedAtUtc - KpiInterval</c>) so a sampled value equals
/// the live tile computed at the same instant. The recorder's
/// <c>capturedAtUtc</c> is the single anchor for both cutoffs.
/// <c>intervalSince = capturedAtUtc - KpiInterval</c>). The COUNT metrics
/// (buffered, parked, failedLastInterval, deliveredLastInterval, stuck) equal the
/// live tile at the same instant; the <c>oldestPendingAgeSeconds</c> metric is
/// computed against the repository's internal clock and may differ from the live
/// tile by the query-execution latency. The recorder's <c>capturedAtUtc</c> is
/// the single anchor for both cutoffs.
/// </para>
/// <para>
/// Registered DI-scoped (next to the rest of the Site Call Audit composition) so
@@ -33,12 +36,13 @@ namespace ZB.MOM.WW.ScadaBridge.SiteCallAudit.Kpi;
public sealed class SiteCallAuditKpiSampleSource : IKpiSampleSource
{
// ── Metric catalog (the M6-agreed metric-name strings for this source) ──
// Declaration order matches the emission order in AddSnapshot.
private const string MetricBuffered = "buffered";
private const string MetricParked = "parked";
private const string MetricFailedLastInterval = "failedLastInterval";
private const string MetricDeliveredLastInterval = "deliveredLastInterval";
private const string MetricOldestPendingAgeSeconds = "oldestPendingAgeSeconds";
private const string MetricStuck = "stuck";
private const string MetricOldestPendingAgeSeconds = "oldestPendingAgeSeconds";
private readonly ISiteCallAuditRepository _repository;
private readonly SiteCallAuditOptions _options;