fix(opcua): #874 route the server's OPC UA SDK log output to the host logger
The host handed the SDK a provider-less telemetry context, so SDK-side refusals — identity-token decryption (the SDK 2 RsaEncryptedSecret clock window, #873), certificate validation, secure-channel faults — left no server log line (found on windev during the #800 Windows validation). The hosted service now creates one ServerSdkTelemetry context from its ILoggerFactory (Warning and above, SDK categories, rate-limited 20/min per category) and shares it between OtOpcUaSdkServer and the ApplicationInstance; released on dispose. Test: an untrusted client's rejection reaches the captured log. Claude-Session: https://claude.ai/code/session_01GT67AD99zQQqpLCVm3p7xk
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
using Opc.Ua;
|
||||
using Akka.Actor;
|
||||
using Akka.Cluster.Tools.PublishSubscribe;
|
||||
using Akka.Hosting;
|
||||
@@ -55,6 +56,12 @@ public sealed class OtOpcUaServerHostedService : IHostedService, IAsyncDisposabl
|
||||
private readonly DriverWriteBounds _writeBounds;
|
||||
|
||||
private OpcUaApplicationHost? _appHost;
|
||||
|
||||
/// <summary>
|
||||
/// The SDK's telemetry context: its Warning-and-above output reaches this host's logs (#874). Shared by the
|
||||
/// server and the application instance, released in <see cref="DisposeAsync"/> after both are gone.
|
||||
/// </summary>
|
||||
private ITelemetryContext? _sdkTelemetry;
|
||||
private OtOpcUaSdkServer? _server;
|
||||
private AclRevalidationTimer? _revalidationTimer;
|
||||
|
||||
@@ -179,11 +186,13 @@ public sealed class OtOpcUaServerHostedService : IHostedService, IAsyncDisposabl
|
||||
/// <returns>A task that represents the asynchronous operation.</returns>
|
||||
public async Task StartAsync(CancellationToken cancellationToken)
|
||||
{
|
||||
_server = new OtOpcUaSdkServer(_loggerFactory.CreateLogger<OtOpcUaNodeManager>());
|
||||
_sdkTelemetry ??= ServerSdkTelemetry.Create(_loggerFactory);
|
||||
_server = new OtOpcUaSdkServer(_loggerFactory.CreateLogger<OtOpcUaNodeManager>(), _sdkTelemetry);
|
||||
_appHost = new OpcUaApplicationHost(
|
||||
_options,
|
||||
_loggerFactory.CreateLogger<OpcUaApplicationHost>(),
|
||||
_userAuthenticator);
|
||||
_userAuthenticator,
|
||||
_sdkTelemetry);
|
||||
|
||||
try
|
||||
{
|
||||
@@ -594,5 +603,7 @@ public sealed class OtOpcUaServerHostedService : IHostedService, IAsyncDisposabl
|
||||
_appHost = null;
|
||||
_server = null;
|
||||
if (appHost is not null) await appHost.DisposeAsync();
|
||||
ServerSdkTelemetry.Release(_sdkTelemetry);
|
||||
_sdkTelemetry = null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user