Skip to content

Commit

Permalink
Rename [Simple|Aggregated]MetricSample to `[Simple|Aggregated]Metri…
Browse files Browse the repository at this point in the history
…cValue` (#210)

Closes #141
  • Loading branch information
tiyash-basu-frequenz authored Mar 22, 2024
2 parents 3a396c0 + 9ccb5b6 commit af97c70
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 16 deletions.
12 changes: 12 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@
`METRIC_AC_THD_CURRENT` -> `METRIC_AC_TOTAL_HARMONIC_DISTORTION_CURRENT`
`METRIC_AC_THD_CURRENT_PHASE_[1|2|3]` -> `METRIC_AC_TOTAL_HARMONIC_DISTORTION_CURRENT_PHASE_[1|2|3]`

- Renamed `SimpleMetricSample` to `SimpleMetricValue`, because it does not
contain a timestamp, so it does not represent a sample but a value.

- Renamed `AggregatedMetricSample` to `AggregatedMetricValue`, because it does not
contain a timestamp, so it does not represent a sample but a value.

- Renamed `MetricSampleVariant` to `MetricValueVariant`.

- Rename `MetricSample.sample` to `MetricSample.value`.

- Rename `SensorMetricSample.sample` to `SensorMetricSample.value`.

## New Features

- Added a `Frequenz.api.common.v1.types.Decimal` type, compatible with
Expand Down
22 changes: 11 additions & 11 deletions proto/frequenz/api/common/v1/metrics/metric_sample.proto
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import "google/protobuf/timestamp.proto";

// Represents a single sample of a specific metric, the value of which is either
// measured or derived at a particular time.
message SimpleMetricSample {
message SimpleMetricValue {
// The value of the metric, which could be either measured or derived.
float value = 2;
}
Expand All @@ -31,7 +31,7 @@ message SimpleMetricSample {
// summaries—minimum, maximum, and average values. Individual measurements are
// are optional, accommodating scenarios where only subsets of this information
// are available.
message AggregatedMetricSample {
message AggregatedMetricValue {
// The derived average value of the metric.
float avg_value = 2;

Expand All @@ -45,20 +45,20 @@ message AggregatedMetricSample {
repeated float raw_values = 5;
}

// MetricSampleVariant serves as a union type that can encapsulate either a
// `SimpleMetricSample` or an `AggregatedMetricSample`.
// `MetricValueVariant` serves as a union type that can encapsulate either a
// `SimpleMetricValue` or an `AggregatedMetricValue`.
//
// This message is designed to offer flexibility in capturing different
// granularities of metric samples—either a simple single-point measurement
// or an aggregated set of measurements for a metric.
//
// A `MetricSampleVariant` can hold either a `SimpleMetricSample` or an
// `AggregatedMetricSample`, but not both simultaneously. Setting one will
// A `MetricValueVariant` can hold either a `SimpleMetricValue` or an
// `AggregatedMetricValue`, but not both simultaneously. Setting one will
// nullify the other.
message MetricSampleVariant {
oneof metric_sample_type {
SimpleMetricSample simple_metric = 1;
AggregatedMetricSample aggregated_metric = 2;
message MetricValueVariant {
oneof metric_value_variant {
SimpleMetricValue simple_metric = 1;
AggregatedMetricValue aggregated_metric = 2;
}
}

Expand Down Expand Up @@ -178,7 +178,7 @@ message MetricSample {
Metric metric = 2;

// The value of the sampled metric.
MetricSampleVariant sample = 3;
MetricValueVariant value = 3;

// List of bounds that apply to the metric sample.
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,13 @@ message ComponentConnection {
// {
// sampled_at: "2023-10-01T00:00:00Z",
// metric: "DC_VOLTAGE_V",
// sample: {},
// value: {},
// bounds: {},
// },
// {
// sampled_at: "2023-10-01T00:00:00Z",
// metric: "DC_VOLTAGE_V",
// sample: {},
// value: {},
// bounds: {},
// }
// ],
Expand Down
6 changes: 3 additions & 3 deletions proto/frequenz/api/common/v1/microgrid/sensors/sensors.proto
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ enum SensorMetric {
// {
// sampled_at: "2023-10-01T00:00:00Z",
// metric: "METRIC_SENSOR_TEMPERATURE",
// sample: metric_sample_type: {simple_metric: {value: 23.5},
// value: metric_value_variant: {simple_metric: {value: 23.5},
// },
// {
// sampled_at: "2023-10-01T00:00:00Z",
// metric: "METRIC_SENSOR_RELATIVE_HUMIDITY",
// sample: metric_sample_type: {simple_metric: {value: 23.5},
// value: metric_value_variant: {simple_metric: {value: 23.5},
// }
// ],
// states: [
Expand Down Expand Up @@ -209,5 +209,5 @@ message SensorMetricSample {
frequenz.api.common.v1.metrics.Metric metric = 2;

// The value of the sampled metric.
frequenz.api.common.v1.metrics.MetricSampleVariant sample = 3;
frequenz.api.common.v1.metrics.MetricValueVariant value = 3;
}

0 comments on commit af97c70

Please sign in to comment.