diff --git a/src/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer/OtOpcUaNodeManager.cs b/src/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer/OtOpcUaNodeManager.cs
index e744e10a4..b2849e66c 100644
--- a/src/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer/OtOpcUaNodeManager.cs
+++ b/src/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer/OtOpcUaNodeManager.cs
@@ -10031,7 +10031,7 @@ public sealed partial class OtOpcUaNodeManager : CustomNodeManager2, INodeManage
{
// The backend cannot serve this Part 13 aggregate — the spec status for THIS node,
// not a logged server fault.
- _logger.LogDebug(ex, "OtOpcUaNodeManager: backend does not support aggregate for node {NodeId}", handle);
+ _logger.LogDebug(ex, "OtOpcUaNodeManager: backend does not support aggregate for node {NodeId}", handle.LogNodeId);
outcome.Error = StatusCodes.BadAggregateNotSupported;
outcome.Result = new SdkHistoryReadResult { StatusCode = StatusCodes.BadAggregateNotSupported };
}
@@ -10039,7 +10039,7 @@ public sealed partial class OtOpcUaNodeManager : CustomNodeManager2, INodeManage
{
// The read would exceed a backend size limit (the time-weighted raw-row cap) — refuse THIS node
// explicitly instead of a generic fault or a deadline-elapsed BadTimeout.
- _logger.LogWarning("OtOpcUaNodeManager: HistoryRead limit exceeded for node {NodeId}: {Message}", handle, ex.Message);
+ _logger.LogWarning("OtOpcUaNodeManager: HistoryRead limit exceeded for node {NodeId}: {Message}", handle.LogNodeId, ex.Message);
outcome.Error = StatusCodes.BadTooManyOperations;
outcome.Result = new SdkHistoryReadResult { StatusCode = StatusCodes.BadTooManyOperations };
}
@@ -10048,7 +10048,7 @@ public sealed partial class OtOpcUaNodeManager : CustomNodeManager2, INodeManage
// One node's backend failure (throw / timeout) must not throw out of the batch — surface a
// Bad status for THIS node only. Logged through the injected ILogger
// rather than swallowed silently.
- _logger.LogError(ex, "OtOpcUaNodeManager: HistoryRead failed for node {NodeId}", handle);
+ _logger.LogError(ex, "OtOpcUaNodeManager: HistoryRead failed for node {NodeId}", handle.LogNodeId);
outcome.Error = HistoryReadFailureStatus(ex);
outcome.Result = new SdkHistoryReadResult { StatusCode = HistoryReadFailureStatus(ex) };
}
@@ -10540,14 +10540,14 @@ public sealed partial class OtOpcUaNodeManager : CustomNodeManager2, INodeManage
{
// A request limit (a reverse read walked back from forward reads met a tie cluster over the row
// budget) — BadTooManyOperations for THIS node, as on the processed path; not a backend fault.
- _logger.LogWarning("OtOpcUaNodeManager: HistoryReadRaw limit exceeded for node {NodeId}: {Message}", handle, ex.Message);
+ _logger.LogWarning("OtOpcUaNodeManager: HistoryReadRaw limit exceeded for node {NodeId}: {Message}", handle.LogNodeId, ex.Message);
outcome.Error = StatusCodes.BadTooManyOperations;
outcome.Result = new SdkHistoryReadResult { StatusCode = StatusCodes.BadTooManyOperations };
}
catch (Exception ex)
{
// One node's backend failure must not throw out of the batch — Bad for THIS node only.
- _logger.LogError(ex, "OtOpcUaNodeManager: HistoryReadRaw (paged) failed for node {NodeId}", handle);
+ _logger.LogError(ex, "OtOpcUaNodeManager: HistoryReadRaw (paged) failed for node {NodeId}", handle.LogNodeId);
outcome.Error = HistoryReadFailureStatus(ex);
outcome.Result = new SdkHistoryReadResult { StatusCode = HistoryReadFailureStatus(ex) };
}
@@ -10648,13 +10648,13 @@ public sealed partial class OtOpcUaNodeManager : CustomNodeManager2, INodeManage
catch (NotSupportedException ex)
{
// The backend keeps no modification trail (Gateway / Null) — the spec status, not a server fault.
- _logger.LogDebug(ex, "OtOpcUaNodeManager: backend serves no modified-value history for node {NodeId}", handle);
+ _logger.LogDebug(ex, "OtOpcUaNodeManager: backend serves no modified-value history for node {NodeId}", handle.LogNodeId);
outcome.Error = StatusCodes.BadHistoryOperationUnsupported;
outcome.Result = new SdkHistoryReadResult { StatusCode = StatusCodes.BadHistoryOperationUnsupported };
}
catch (Exception ex)
{
- _logger.LogError(ex, "OtOpcUaNodeManager: HistoryRead (modified) failed for node {NodeId}", handle);
+ _logger.LogError(ex, "OtOpcUaNodeManager: HistoryRead (modified) failed for node {NodeId}", handle.LogNodeId);
outcome.Error = HistoryReadFailureStatus(ex);
outcome.Result = new SdkHistoryReadResult { StatusCode = HistoryReadFailureStatus(ex) };
}
diff --git a/tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.Tests/HistoryReadPortParityTests.cs b/tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.Tests/HistoryReadPortParityTests.cs
index e0ad26cfc..f7c930ec2 100644
--- a/tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.Tests/HistoryReadPortParityTests.cs
+++ b/tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.Tests/HistoryReadPortParityTests.cs
@@ -19,6 +19,9 @@ public sealed class HistoryReadPortServerFixture : IAsyncLifetime
/// The node manager under test.
public OtOpcUaNodeManager Nm { get; private set; } = null!;
+ /// Every node-manager log entry's structured properties.
+ public CapturingLogger Log { get; } = new();
+
/// Serialises the cases (they share the node manager's source and continuation store).
public SemaphoreSlim Gate { get; } = new(1, 1);
@@ -38,7 +41,7 @@ public sealed class HistoryReadPortServerFixture : IAsyncLifetime
PkiStoreRoot = _pkiRoot,
},
NullLogger.Instance),
- () => new OtOpcUaSdkServer(), CancellationToken.None);
+ () => new OtOpcUaSdkServer(Log), CancellationToken.None);
_host = started.Host;
Nm = started.Server.NodeManager!;
Nm.HistoryContinuationStore = new InMemoryHistoryContinuationStore();
@@ -71,6 +74,24 @@ public sealed class HistoryReadPortServerFixture : IAsyncLifetime
}
}
+/// Records each log entry's level and structured properties.
+public sealed class CapturingLogger : Microsoft.Extensions.Logging.ILogger
+{
+ private readonly System.Collections.Concurrent.ConcurrentQueue<(Microsoft.Extensions.Logging.LogLevel Level, IReadOnlyList> Properties)> _entries = new();
+
+ public IReadOnlyList<(Microsoft.Extensions.Logging.LogLevel Level, IReadOnlyList> Properties)> Entries => _entries.ToArray();
+
+ public void Clear() => _entries.Clear();
+
+ public IDisposable? BeginScope(TState state) where TState : notnull => null;
+
+ public bool IsEnabled(Microsoft.Extensions.Logging.LogLevel logLevel) => true;
+
+ public void Log(Microsoft.Extensions.Logging.LogLevel logLevel, Microsoft.Extensions.Logging.EventId eventId, TState state,
+ Exception? exception, Func formatter) =>
+ _entries.Enqueue((logLevel, state as IReadOnlyList> ?? []));
+}
+
///
/// H1 (gRPC data history plan §3.1): the override-level history port is the ONE pipeline the SDK overrides and a remote
/// peer's HistoryRead (H2) are served through. Every case runs the same request two ways against the same fake backend —
@@ -442,6 +463,38 @@ public sealed class HistoryReadPortParityTests(HistoryReadPortServerFixture fx)
});
}
+ [Fact]
+ public async Task A_backend_failure_logs_the_original_NodeId_on_the_local_path()
+ {
+ await RunAsync(async () =>
+ {
+ fx.Nm.HistorianDataSource = new ParitySource { Throw = true };
+ var nodeId = fx.Nodes["dbl"].NodeId;
+ static object? NodeIdProperty(CapturingLogger log) => log.Entries
+ .Where(e => e.Level == Microsoft.Extensions.Logging.LogLevel.Error)
+ .SelectMany(e => e.Properties).Single(p => p.Key == "NodeId").Value;
+
+ foreach (var details in new HistoryReadDetails[]
+ {
+ Raw(T(0), T(10), 5, bounds: false),
+ new ReadAtTimeDetails { ReqTimes = new[] { (DateTimeUtc)T(0) } },
+ })
+ {
+ fx.Log.Clear();
+ Override(details, "dbl").Single().Error.ShouldBe(StatusCodes.BadHistoryOperationUnsupported.Code);
+ NodeIdProperty(fx.Log).ShouldBe(nodeId, "the {NodeId} property keeps meaning a NodeId");
+
+ // A peer item carries no SDK NodeId: it logs as Realm:Identifier.
+ fx.Log.Clear();
+ fx.Nm.ReadHistory(HistoryReadVariant.From(details), [new HistoryReadPortItem(AddressSpaceRealm.Uns, "port/dbl")],
+ fx.Nm.SessionHistoryContinuationScope(session: null), CancellationToken.None);
+ NodeIdProperty(fx.Log).ShouldBe("Uns:port/dbl");
+ }
+
+ await Task.CompletedTask;
+ });
+ }
+
[Fact]
public async Task The_outcome_status_carries_GoodNoData_and_Bad_operation_statuses_verbatim()
{
@@ -604,6 +657,7 @@ public sealed class HistoryReadPortParityTests(HistoryReadPortServerFixture fx)
public IReadOnlyList AtTimeResult { get; set; } = [];
public bool NativeReverse { get; init; } = true;
public int Ceiling { get; init; }
+ public bool Throw { get; init; }
public int ProcessedCalls;
public int ReverseOnForwardOnly;
public bool RefusedAggregateAsked { get; private set; }
@@ -628,6 +682,7 @@ public sealed class HistoryReadPortParityTests(HistoryReadPortServerFixture fx)
string fullReference, DateTime startUtc, DateTime endUtc, uint maxValuesPerNode, CancellationToken cancellationToken)
{
static DateTime Ts(DataValueSnapshot s) => s.SourceTimestampUtc ?? DateTime.MinValue;
+ if (Throw) throw new InvalidOperationException("backend down");
var series = Series.TryGetValue(fullReference, out var s) ? s : [];
List window;
if (startUtc > endUtc)
@@ -665,6 +720,7 @@ public sealed class HistoryReadPortParityTests(HistoryReadPortServerFixture fx)
string fullReference, IReadOnlyList timestampsUtc, TypeCode? valueType, CancellationToken cancellationToken)
{
LastAtTimeType = valueType;
+ if (Throw) throw new InvalidOperationException("backend down");
return Task.FromResult(new HistorianRead(AtTimeResult, null));
}