Skip to content

feat(common.opcua): Add support for datetime arrays#18411

Merged
skartikey merged 2 commits intoinfluxdata:masterfrom
jprandelliberief:fix-opcua-time-array
Mar 2, 2026
Merged

feat(common.opcua): Add support for datetime arrays#18411
skartikey merged 2 commits intoinfluxdata:masterfrom
jprandelliberief:fix-opcua-time-array

Conversation

@jprandelliberief
Copy link
Copy Markdown
Contributor

Summary

OPC UA nodes with a DateTime[] value type are decoded by gopcua as []time.Time.
Telegraf's array-unpacking type-switch in the shared OPC UA input code did not handle this type, causing it to fall through to the default case and log:
could not unpack variant array of type: []time.Time
This change adds a case []time.Time: branch to the switch in plugins/common/opcua/input/input_client.go. Each element is formatted as an RFC3339Nano UTC string and the resulting []string is passed to the existing unpack() helper, producing indexed fields (e.g. field[0]="2024-01-01T00:00:00Z", field[1]=...) consistent with how all other array types are handled.

A unit test case (datetime array metric build correctly) is added to TestMetricForNode to cover this path.

Checklist

Related issues

resolves #18410

@telegraf-tiger telegraf-tiger bot added area/opcua feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins labels Feb 24, 2026
@telegraf-tiger
Copy link
Copy Markdown
Contributor

@srebhan srebhan changed the title feat(inputs.opcua): Add support for datetime array metrics in MetricForNode feat(inputs.opcua): Add support for datetime arrays Feb 25, 2026
@srebhan srebhan changed the title feat(inputs.opcua): Add support for datetime arrays feat(common.opcua): Add support for datetime arrays Feb 25, 2026
Copy link
Copy Markdown
Member

@srebhan srebhan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution @jprandelliberief!

@srebhan srebhan added the ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review. label Feb 25, 2026
Copy link
Copy Markdown
Contributor

@skartikey skartikey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jprandelliberief Thanks for the contribution!

@skartikey skartikey merged commit 519ff7b into influxdata:master Mar 2, 2026
30 of 31 checks passed
@github-actions github-actions bot added this to the v1.38.0 milestone Mar 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/opcua feat Improvement on an existing feature such as adding a new setting/mode to an existing plugin plugin/input 1. Request for new input plugins 2. Issues/PRs that are related to input plugins ready for final review This pull request has been reviewed and/or tested by multiple users and is ready for a final review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[inputs.opcua] Add support for DateTime[] array unpacking

3 participants