Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support metrics from multiple component connections in the aggregation RPC #51

Open
stefan-brus-frequenz opened this issue Sep 17, 2024 · 0 comments
Labels
part:docs Affects the documentation part:proto Affects the protocol buffer definition files priority:low This should be addressed only if there is nothing else on the table type:enhancement New feature or enhancement visitble to users
Milestone

Comments

@stefan-brus-frequenz
Copy link
Collaborator

stefan-brus-frequenz commented Sep 17, 2024

What's needed?

To support specifying different connections for component metrics in the aggregation formulas, we'll need to extend the syntax to allow an optional source specification after the component ID.

Proposed solution

Example Formula:

(#4[source1] + #5[source2])

Proposed Additions:

 message AggregationConfig {
   // ID of the microgrid for which the formula is being specified.
   uint64 microgrid_id = 1;

   // The metric that is to be aggregated using the specified formula.
   //
   // !!! caution "Metric Compatibility"
   //     Ensure the chosen metric is supported by all relevant microgrid components.
   //     Failure to meet these conditions might result in an aggregation error.
   frequenz.api.common.v1.metrics.Metric metric = 2;

   // The formula used for aggregating the component metric for this microgrid.
   // 
   // ...
+  //     Specifying Sources for Component Metrics:
+  //
+  //     - Syntax:
+  //
+  //       `#ComponentID[connection_name]`
+  //
+  //     - Components:
+  //       - `ComponentID`: The ID of the component (e.g., `#4`)
+  //       - `connection_name`: The name of the connection (e.g., `dc_connection_1`), enclosed in square brackets `[]`
+  //
+  //     - Examples:
+  //
+  //       - `#4[dc_string_1]`: Refers to the metric from component `4` with connection `dc_string_1`
+  //       - `#4[dc_string_2]`: Refers to the metric from component `4` with connection `dc_string_2`
+  //
+  //     - Notes:
+  //       - Specifying a connection is optional. If omitted, the default connection is used.
// ...
   string aggregation_formula = 3;
 }

Use cases

One might have an inverter with multiple DC strings (connections), and you want to aggregate metrics from specific strings.

Alternatives and workarounds

Alternative Syntax Options

a. Using the @ Symbol

Syntax: #ComponentID@source_name (e.g., #4@source1)

Pros:
Unambiguous: The @ symbol is less commonly used in mathematical expressions, reducing the risk of parsing conflicts.
Clear Association: Clearly associates the source with the component ID.

Cons:
User Familiarity: Users might be less accustomed to this notation, but it's often used in email addresses and annotations, so it's not entirely unfamiliar.

b. Using a Dot .

Syntax: #ComponentID.source_name (e.g., #4.source1)

Pros:
Familiarity: Dots are commonly used for object property access in many programming languages.

Cons:
Parsing Issues: Dots are also used in floating-point numbers (e.g., 3.14), which might complicate parsing.
Potential Ambiguity: Could be confused with decimal points in numbers.

c. Using a Colon :

Syntax: #ComponentID:source_name (e.g., #4:source1)

Pros:
Distinct Separator: Colons are clear separators and not commonly used in mathematical expressions.

Cons:
Potential Conflicts: If the expression language uses colons for other purposes (e.g., ternary operators), this could cause issues.

Additional context

This is pending the following issue.

@stefan-brus-frequenz stefan-brus-frequenz added priority:high Address this as soon as possible type:enhancement New feature or enhancement visitble to users part:proto Affects the protocol buffer definition files labels Sep 17, 2024
@thomas-nicolai-frequenz thomas-nicolai-frequenz changed the title Support sourced metrics in the aggregation RPC Support metrics from multiple component connections in the aggregation RPC Sep 30, 2024
@stefan-brus-frequenz stefan-brus-frequenz added priority:low This should be addressed only if there is nothing else on the table and removed priority:high Address this as soon as possible labels Oct 1, 2024
@thomas-nicolai-frequenz thomas-nicolai-frequenz added the part:docs Affects the documentation label Oct 10, 2024
@cwasicki cwasicki added this to the v1.0.0 milestone Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
part:docs Affects the documentation part:proto Affects the protocol buffer definition files priority:low This should be addressed only if there is nothing else on the table type:enhancement New feature or enhancement visitble to users
Projects
None yet
Development

No branches or pull requests

3 participants