From 98da09ef263c527706eaa1666b9386e2beb3f6f3 Mon Sep 17 00:00:00 2001 From: Einar Date: Wed, 22 Feb 2023 09:33:03 +0100 Subject: [PATCH] Improve rebrowse logging (#361) * Slightly expand rebrowse logging It is being a little inconsistent, so we need a bit more logging. * Update manifest --- Extractor/RebrowseTriggerManager.cs | 36 +++++++++++++++++++++-------- manifest.yml | 5 ++++ 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/Extractor/RebrowseTriggerManager.cs b/Extractor/RebrowseTriggerManager.cs index 9c8a8729..24cff3e9 100644 --- a/Extractor/RebrowseTriggerManager.cs +++ b/Extractor/RebrowseTriggerManager.cs @@ -8,6 +8,7 @@ using Opc.Ua; using Opc.Ua.Client; +using System; namespace Cognite.OpcUa { @@ -104,7 +105,7 @@ await _uaClient.Browser.BrowseDirectory( }; if (nodeIds.Count > 0) - logger.LogInformation("The following nodes will be subscribed to a rebrowse: {Nodes}", nodeIds); + logger.LogInformation("The following nodes will be subscribed to for rebrowse triggers: {Nodes}", nodeIds); var nodes = nodeIds.Select(node => new ServerItemSubscriptionState(_uaClient, node)).ToList(); @@ -117,15 +118,30 @@ private async Task CreateSubscriptions(List nodes, nodes, SubscriptionName, (MonitoredItem item, MonitoredItemNotificationEventArgs _) => { - var values = item.DequeueValues(); - var value = values.Count > 0 - ? values[0].GetValue(UAExtractor.StartTime) - : UAExtractor.StartTime; - - if (UAExtractor.StartTime < value) { - logger.LogInformation("Triggering a rebrowse due to a change in the value of {NodeId}", item.ResolvedNodeId); - _extractor.Looper.QueueRebrowse(); + try + { + var values = item.DequeueValues(); + var value = values.Count > 0 + ? values[0].GetValue(UAExtractor.StartTime) + : UAExtractor.StartTime; + + if (UAExtractor.StartTime < value) + { + logger.LogInformation("Triggering a rebrowse due to a change in the value of {NodeId} to {Value}", item.ResolvedNodeId, value); + _extractor.Looper.QueueRebrowse(); + } + else + { + logger.LogDebug("Received a rebrowse trigger notification with time {Time}, which is not greater than extractor start time {StartTime}", + value, + UAExtractor.StartTime); + } + } + catch (Exception ex) + { + logger.LogError(ex, "Unexpected error handling rebrowse trigger"); } + }, state => new MonitoredItem { @@ -137,7 +153,7 @@ private async Task CreateSubscriptions(List nodes, AttributeId = Attributes.Value, NodeClass = NodeClass.Variable, CacheQueueSize = 1 - }, token, "namespaces " + }, token, "namespaces" ); } } diff --git a/manifest.yml b/manifest.yml index 8c242168..5333cc0c 100644 --- a/manifest.yml +++ b/manifest.yml @@ -60,6 +60,11 @@ schema: - "https://raw.githubusercontent.com/" versions: + "2.13.2": + description: Improve logging in rebrowse manager + changelog: + changed: + - "Improve logging in rebrowse manager" "2.13.1": description: Minor improvements to the service manager changelog: