Skip to content

Commit 31f568c

Browse files
Rename MetricSample.source to MetricSample.connection (#347)
This commit renames the `source` field in the `MetricSample` message to `connection`. This change is made to clarify the purpose of the field, as it specifically refers to the connection point from which the metric was obtained, rather than a generic source. closes #260
2 parents ebf585f + cf9c939 commit 31f568c

File tree

4 files changed

+28
-13
lines changed

4 files changed

+28
-13
lines changed

RELEASE_NOTES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
- Renamed `sampled_at` timestamps for metric samples to `sample_time`.
3838
- Remove `SensorMetricSample` in favour of using `MetricSample` for sensors.
3939
- Remove `SensorMetric` enum, since it was unused and redundant.
40+
- Renamed `MetricSample.source` to `MetricSample.connection` to make it more specific as to what it refers to.
4041

4142
## Bug Fixes
4243

proto/frequenz/api/common/v1/metrics/metrics.proto

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -222,19 +222,27 @@ message MetricSample {
222222
// ==== values here are allowed and will be accepted
223223
repeated Bounds bounds = 4;
224224

225-
// An optional string that can be used to identify the source of the metric.
225+
// An optional string that can be used to identify the specific connection
226+
// from which the metric was obtained.
226227
//
227228
// This is expected to be populated when the same `Metric` variant can be
228-
// obtained from multiple sensors in the component. Knowing the source of the
229-
// metric can help in certain control and monitoring applications.
229+
// obtained from multiple distinct inputs or connection points on the
230+
// component. Knowing the connection for the metric can help in certain
231+
// control and monitoring applications.
230232
//
231-
// E.g., a hybrid inverter can have a DC string for a battery and another DC
232-
// string for a PV array. The source names could resemble, say,
233-
// `dc_battery_0` and ``dc_pv_0`. A metric like DC voltage can be obtained
234-
// from both sources. For an application to determine the SoC of the battery
235-
// using the battery voltage, the source of the voltage metric is important.
233+
// E.g.,
234+
// - A PV inverter might have multiple PV strings connected (e.g.,
235+
// `pv_string_1`, `pv_string_2`).
236+
// - A hybrid inverter can have a DC connection for a battery (e.g.,
237+
// `dc_battery_0`) and another for a PV array (e.g., `dc_pv_0`). A metric
238+
// like DC voltage can be obtained from both connections. For an application
239+
// to determine the SoC of the battery using its voltage, identifying the
240+
// `dc_battery_0` connection is important.
241+
// - A sensor unit might report temperature from different connected probes
242+
// (e.g., `temp_sensor_outdoor`, `temp_sensor_indoor`).
236243
//
237-
// In cases where the component has just one source for a metric, then this
238-
// field is not expected to be present, because the source is implicit.
239-
optional string source = 5;
244+
// In cases where the component has just one such connection for a metric,
245+
// or the context is otherwise unambiguous, this field is not expected to
246+
// be present, because the connection is implicit.
247+
optional string connection = 5;
240248
}

proto/frequenz/api/common/v1/microgrid/electrical_components/electrical_components.proto

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -528,12 +528,14 @@ message ElectricalComponentStateSnapshot {
528528
// metric: "DC_VOLTAGE_V",
529529
// value: {},
530530
// bounds: {},
531+
// connection: "battery_0"
531532
// },
532533
// {
533534
// sample_time: "2023-10-01T00:00:00Z",
534535
// metric: "DC_VOLTAGE_V",
535536
// value: {},
536537
// bounds: {},
538+
// connection: "pv_0"
537539
// }
538540
// ],
539541
// states: [

proto/frequenz/api/common/v1/microgrid/sensors/sensors.proto

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,14 @@ message SensorStateSnapshot {
182182
// metric: "METRIC_SENSOR_TEMPERATURE",
183183
// value: metric_value_variant: {simple_metric: {value: 23.5},
184184
// bounds: {}
185-
// source: {}
185+
// connection: {}
186186
// },
187187
// {
188188
// sample_time: "2023-10-01T00:00:00Z",
189189
// metric: "METRIC_SENSOR_RELATIVE_HUMIDITY",
190190
// value: metric_value_variant: {simple_metric: {value: 23.5},
191191
// bounds: {}
192-
// source: "humidity_sensor_1"
192+
// connection: "humidity_sensor_1"
193193
// }
194194
// ],
195195
// states: [
@@ -206,6 +206,10 @@ message SensorData {
206206
uint64 sensor_id = 1;
207207

208208
// List of measurements for a metric of the specific microgrid sensor.
209+
//
210+
// Note that these metric samples will not necessarily contain bounds, since
211+
// bounds are required for control operations, which are not applicable to
212+
// sensors.
209213
repeated frequenz.api.common.v1.metrics.MetricSample metric_samples = 2;
210214

211215
// List of states of a specific microgrid sensor.

0 commit comments

Comments
 (0)