Skip to content
This repository has been archived by the owner on Apr 2, 2024. It is now read-only.

Fix metric names #17

Merged
merged 2 commits into from
Aug 2, 2023
Merged

Fix metric names #17

merged 2 commits into from
Aug 2, 2023

Conversation

AlexGodbehere
Copy link
Contributor

Metrics are now stored in the InfluxDB database as the metric name, not the fully qualified path. Before, Phases/1/Voltage and Phases/2/Voltage would be two measurements. Now, they're both Voltage and have a Path tag of Phases/1 and Phases/2 respectively.

The datatype has also been added on to the name of the metric. Not best practice (probably), but prevents errors from arising when a metric has the same name and a different type.

Modified mqttclient's method to separate full metric's name into actual metric name and path, improving logging clarity and metric registration in the writing stage. The changes were made while validating the metric's type and recording them - the name and path are now correctly logged and registered, enhancing the tracking and categoricity of the metrics.
Copy link

@amrc-benmorrow amrc-benmorrow left a comment

Choose a reason for hiding this comment

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

I don't like attaching the type information in a way that conflicts with possible metric names. Even as a quick hack to deal with mistyped data, it would be better to use :i or /Int instead of _i. There might be value in recording the full Sparkplug datatype here, rather than using the InfluxDB type?

I don't understand InfluxDB well enough to understand the consequences of the renaming. I would be concerned that we will end up linking metrics with different sematics together, just because they happen to have the same basename.

In the mqttclient.ts, the manner in which metrics were being named for writing points has been altered. Previously, an underscore was used to separate the core metric name and its associated type annotation (i.e `${metricName}_x`). This has been changed to use a colon instead (`${metricName}:x`.
@AlexGodbehere AlexGodbehere merged commit cf54c57 into main Aug 2, 2023
2 checks passed
@AlexGodbehere AlexGodbehere deleted the standardised-measurement-name branch August 2, 2023 07:59
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants