Skip to content

Commit

Permalink
Improve rebrowse logging (#361)
Browse files Browse the repository at this point in the history
* Slightly expand rebrowse logging

It is being a little inconsistent, so we need a bit more logging.

* Update manifest
  • Loading branch information
einarmo authored Feb 22, 2023
1 parent 01ce51e commit 98da09e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 10 deletions.
36 changes: 26 additions & 10 deletions Extractor/RebrowseTriggerManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

using Opc.Ua;
using Opc.Ua.Client;
using System;

namespace Cognite.OpcUa
{
Expand Down Expand Up @@ -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();

Expand All @@ -117,15 +118,30 @@ private async Task CreateSubscriptions(List<ServerItemSubscriptionState> nodes,
nodes, SubscriptionName,
(MonitoredItem item, MonitoredItemNotificationEventArgs _) =>
{
var values = item.DequeueValues();
var value = values.Count > 0
? values[0].GetValue<System.DateTime>(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
{
Expand All @@ -137,7 +153,7 @@ private async Task CreateSubscriptions(List<ServerItemSubscriptionState> nodes,
AttributeId = Attributes.Value,
NodeClass = NodeClass.Variable,
CacheQueueSize = 1
}, token, "namespaces "
}, token, "namespaces"
);
}
}
Expand Down
5 changes: 5 additions & 0 deletions manifest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 98da09e

Please sign in to comment.