feat(common.opcua): Add debug info for nodes not in server namespace (#14676)

This commit is contained in:
Christian Allinson 2024-02-06 13:10:42 -08:00 committed by GitHub
parent 3591546a1a
commit c981bb7819
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 2 deletions

View File

@ -391,7 +391,13 @@ func (o *OpcUAInputClient) initLastReceivedValues() {
func (o *OpcUAInputClient) UpdateNodeValue(nodeIdx int, d *ua.DataValue) {
o.LastReceivedData[nodeIdx].Quality = d.Status
if !o.StatusCodeOK(d.Status) {
o.Log.Errorf("status not OK for node %v: %v", o.NodeMetricMapping[nodeIdx].Tag.FieldName, d.Status)
// Verify NodeIDs array has been built before trying to get item; otherwise show '?' for node id
if len(o.NodeIDs) > nodeIdx {
o.Log.Errorf("status not OK for node %v (%v): %v", o.NodeMetricMapping[nodeIdx].Tag.FieldName, o.NodeIDs[nodeIdx].String(), d.Status)
} else {
o.Log.Errorf("status not OK for node %v (%v): %v", o.NodeMetricMapping[nodeIdx].Tag.FieldName, '?', d.Status)
}
return
}

View File

@ -172,8 +172,16 @@ func (o *SubscribeClient) StartStreamValues(ctx context.Context) (<-chan telegra
}
o.Log.Debug("Monitoring items")
for _, res := range resp.Results {
for idx, res := range resp.Results {
if !o.StatusCodeOK(res.StatusCode) {
// Verify NodeIDs array has been built before trying to get item; otherwise show '?' for node id
if len(o.OpcUAInputClient.NodeIDs) > idx {
o.Log.Debugf("Failed to create monitored item for node %v (%v)",
o.OpcUAInputClient.NodeMetricMapping[idx].Tag.FieldName, o.OpcUAInputClient.NodeIDs[idx].String())
} else {
o.Log.Debugf("Failed to create monitored item for node %v (%v)", o.OpcUAInputClient.NodeMetricMapping[idx].Tag.FieldName, '?')
}
return nil, fmt.Errorf("creating monitored item failed with status code: %w", res.StatusCode)
}
}