feat(grpc-data): H4 remote-history diagnostics and metrics

Consumer and origin history evidence for data connections (plan §6):
- DataConnectionHistoryDiagnostics: otopcua.dataconn.history.reads{variant,status_class,side} and
  otopcua.dataconn.history.continuations.active{side} on the exported OtOpcUa meter (the H2 origin
  counter sat on a private meter the host never exported); the plan's unknown-bits counter is the
  existing X0 otopcua.dataconnection.unknown_operations_dropped, reused
- per-connection projected answers by status class and open consumer continuations (settled on
  resume claim or release); origin sessions, open continuations and answers by status class
- negotiated features and advertised history variants/aggregates per connection
- AdminUI data-connections page renders them plus the dropped unknown-operation bits (#919)
- H4 unit-phase manifest key
This commit is contained in:
Joseph Doherty
2026-11-24 08:01:57 -05:00
parent b1973d6fdd
commit e3f21cb86c
19 changed files with 687 additions and 30 deletions
@@ -1,4 +1,6 @@
using ZB.MOM.WW.OtOpcUa.Commons.Interfaces;
using ZB.MOM.WW.OtOpcUa.Configuration.Entities;
using ZB.MOM.WW.OtOpcUa.Core.Abstractions.DataConnections;
namespace ZB.MOM.WW.OtOpcUa.AdminUI.DataConnections;
@@ -23,6 +25,41 @@ public static class DataConnectionDiagnostics
"disabled" => "Disabled", "connecting" => "Connecting", "ready" => "Ready", "degraded" => "Degraded",
"auth-failed" => "Authentication failed", "backoff" => "Backoff", _ => "Unavailable"
};
/// <summary>H4: the features the last handshake negotiated; "none (v1)" when the peer negotiated nothing optional.</summary>
public static string Features(DataFeatures? features) => features switch
{
null => "unavailable",
DataFeatures.None => "none (v1 behaviour)",
{ } f => string.Join(", ", Enum.GetValues<DataFeatures>().Where(x => x != DataFeatures.None && f.HasFlag(x)).Select(x => x.ToString())
.DefaultIfEmpty($"0x{(int)f:X}")),
};
/// <summary>H4: the history variants and aggregate count the origin advertised to this caller.</summary>
public static string HistoryServed(DataConnectionDiagnosticsSnapshot row) =>
row.HistoryVariants is not { } variants ? "not advertised"
: variants.Count == 0 ? "advertised, no variant granted"
: string.Join(", ", variants) + (row.HistoryAggregateCount is { } n ? $" ({n} aggregates)" : "");
/// <summary>H4: history results by status class, "unavailable" from a node built before H4.</summary>
public static string HistoryCounts(long? good, long? uncertain, long? bad) =>
good is null && uncertain is null && bad is null ? "unavailable"
: $"good {good ?? 0} · uncertain {uncertain ?? 0} · bad {bad ?? 0}";
/// <summary>
/// #919: operation bits a node dropped because its build does not implement them. Named when this AdminUI knows the
/// bit, hex otherwise; "unavailable" from a node built before X0.
/// </summary>
public static string DroppedBits(DataOperations? bits) => bits switch
{
null => "unavailable",
DataOperations.None => "none",
{ } b => string.Join(", ", Enumerable.Range(0, 31).Select(i => (DataOperations)(1 << i)).Where(x => b.HasFlag(x))
.Select(x => Enum.IsDefined(x) ? DataOperationAuthoring.Label(x) : $"0x{(int)x:X}")),
};
/// <summary>#919: true when the drop deserves the "node build is older than the authored feature" hint.</summary>
public static bool HasDrops(DataOperations? bits, int? mappings = null) => bits is { } b && b != DataOperations.None || mappings is > 0;
public static string Endpoint(string? value) => Uri.TryCreate(value, UriKind.Absolute, out var uri)
&& uri.Scheme == Uri.UriSchemeHttps ? (uri.HostNameType == UriHostNameType.IPv6 ? $"https://[{uri.Host}]{(uri.IsDefaultPort ? "" : $":{uri.Port}")}" : $"https://{uri.IdnHost}{(uri.IsDefaultPort ? "" : $":{uri.Port}")}") : "Unavailable";
}