v1alpha8
frequenz.client.common.metrics.proto.v1alpha8 ¤
Conversion of metrics enums from/to protobuf v1alpha8.
Functions:¤
frequenz.client.common.metrics.proto.v1alpha8.aggregated_metric_sample_from_proto ¤
aggregated_metric_sample_from_proto(
message: AggregatedMetricValue,
) -> AggregatedMetricValue
Convert a protobuf message to an AggregatedMetricValue object.
| PARAMETER | DESCRIPTION |
|---|---|
message
|
The protobuf message to convert.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
AggregatedMetricValue
|
The resulting |
Source code in src/frequenz/client/common/metrics/proto/v1alpha8/_sample.py
frequenz.client.common.metrics.proto.v1alpha8.bounds_from_proto ¤
Create a Bounds object from a protobuf message.
Deprecated
Use bounds_from_proto2 instead. The new
converter distinguishes well-formed from malformed data at the
type level (Bounds | InvalidBounds) rather than raising a
ValueError when the invariant fires.
| PARAMETER | DESCRIPTION |
|---|---|
message
|
The protobuf message to convert.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Bounds
|
The corresponding |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the message is not valid. |
Source code in src/frequenz/client/common/metrics/proto/v1alpha8/_bounds.py
frequenz.client.common.metrics.proto.v1alpha8.bounds_from_proto2 ¤
bounds_from_proto2(
message: Bounds,
) -> Bounds | InvalidBounds
Create bounds from a protobuf message, preserving malformed data.
| PARAMETER | DESCRIPTION |
|---|---|
message
|
The protobuf message to convert.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Bounds | InvalidBounds
|
A |
Source code in src/frequenz/client/common/metrics/proto/v1alpha8/_bounds.py
frequenz.client.common.metrics.proto.v1alpha8.bounds_from_proto_with_issues ¤
bounds_from_proto_with_issues(
message: Bounds,
*,
major_issues: list[str],
minor_issues: list[str]
) -> Bounds | None
Create a Bounds object from a protobuf message, collecting issues.
Deprecated
Use bounds_from_proto2 instead and
inspect the returned type. The new converter distinguishes
well-formed from malformed data at the type level
(Bounds | InvalidBounds) rather than routing invalid data
through a side-channel string list.
| PARAMETER | DESCRIPTION |
|---|---|
message
|
The protobuf message to convert.
TYPE:
|
major_issues
|
A list to append major issues to. |
minor_issues
|
A list to append minor issues to. |
| RETURNS | DESCRIPTION |
|---|---|
Bounds | None
|
The corresponding |
Source code in src/frequenz/client/common/metrics/proto/v1alpha8/_bounds.py
frequenz.client.common.metrics.proto.v1alpha8.bounds_set_from_proto ¤
bounds_set_from_proto(
messages: Sequence[Bounds],
) -> BoundsSet | InvalidBoundsSet
Convert a sequence of bounds messages into a single bounds set.
This is the multi-bound counterpart of
bounds_from_proto2: it converts each message and
combines the results.
| PARAMETER | DESCRIPTION |
|---|---|
messages
|
The bounds messages to convert. |
| RETURNS | DESCRIPTION |
|---|---|
BoundsSet | InvalidBoundsSet
|
A |
Source code in src/frequenz/client/common/metrics/proto/v1alpha8/_bounds.py
frequenz.client.common.metrics.proto.v1alpha8.metric_connection_category_from_proto ¤
metric_connection_category_from_proto(
message: ValueType,
) -> MetricConnectionCategory | int
Convert a protobuf MetricConnectionCategory value to an enum member.
| PARAMETER | DESCRIPTION |
|---|---|
message
|
The protobuf message to convert.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
MetricConnectionCategory | int
|
The corresponding
|
Source code in src/frequenz/client/common/metrics/proto/v1alpha8/_metric_connection_category.py
frequenz.client.common.metrics.proto.v1alpha8.metric_connection_category_to_proto ¤
metric_connection_category_to_proto(
category: MetricConnectionCategory,
) -> ValueType
Convert a MetricConnectionCategory enum member to a protobuf value.
| PARAMETER | DESCRIPTION |
|---|---|
category
|
The
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
ValueType
|
The corresponding protobuf |
Source code in src/frequenz/client/common/metrics/proto/v1alpha8/_metric_connection_category.py
frequenz.client.common.metrics.proto.v1alpha8.metric_connection_from_proto ¤
metric_connection_from_proto(
message: MetricConnection,
) -> MetricConnection
Convert a protobuf message to a MetricConnection object.
An unspecified category is preserved as the raw integer 0 and an
unrecognized one as its raw integer value in the category field (typed
MetricConnectionCategory | int), so malformed input is surfaced through
the returned type rather than a side channel.
| PARAMETER | DESCRIPTION |
|---|---|
message
|
The protobuf message to convert.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
MetricConnection
|
The resulting |
Source code in src/frequenz/client/common/metrics/proto/v1alpha8/_sample.py
frequenz.client.common.metrics.proto.v1alpha8.metric_connection_from_proto_with_issues ¤
metric_connection_from_proto_with_issues(
message: MetricConnection,
*,
major_issues: list[str],
minor_issues: list[str]
) -> MetricConnection
Convert a protobuf message to a MetricConnection object.
Deprecated
Use metric_connection_from_proto
instead and inspect the returned type. The new converter encodes an
unspecified or unrecognized category in the returned
MetricConnection.category field (MetricConnectionCategory | int)
rather than routing it through a side-channel string list.
| PARAMETER | DESCRIPTION |
|---|---|
message
|
The protobuf message to convert.
TYPE:
|
major_issues
|
A list to append major issues to. |
minor_issues
|
A list to append minor issues to. |
| RETURNS | DESCRIPTION |
|---|---|
MetricConnection
|
The resulting |
Source code in src/frequenz/client/common/metrics/proto/v1alpha8/_sample.py
frequenz.client.common.metrics.proto.v1alpha8.metric_from_proto ¤
Convert a protobuf Metric message to a Metric enum member.
| PARAMETER | DESCRIPTION |
|---|---|
message
|
The protobuf message to convert.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Metric | int
|
Source code in src/frequenz/client/common/metrics/proto/v1alpha8/_metric.py
frequenz.client.common.metrics.proto.v1alpha8.metric_sample_from_proto ¤
metric_sample_from_proto(
message: MetricSample,
) -> MetricSample
Convert a protobuf message to a MetricSample object.
Malformed or forward-incompatible input is surfaced through the returned
type rather than a side channel: an unspecified metric is preserved as the
raw integer 0 and an unrecognized one as its raw integer value in the
metric field (typed Metric | int), and malformed bounds as an
InvalidBoundsSet in bounds_set.
| PARAMETER | DESCRIPTION |
|---|---|
message
|
The protobuf message to convert.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
MetricSample
|
The resulting |
Source code in src/frequenz/client/common/metrics/proto/v1alpha8/_sample.py
frequenz.client.common.metrics.proto.v1alpha8.metric_sample_from_proto_with_issues ¤
metric_sample_from_proto_with_issues(
message: MetricSample,
*,
major_issues: list[str],
minor_issues: list[str]
) -> MetricSample
Convert a protobuf message to a MetricSample object.
Deprecated
Use metric_sample_from_proto instead
and inspect the returned type. The new converter encodes an
unspecified or unrecognized metric (Metric | int) and malformed
bounds (InvalidBoundsSet) in the returned MetricSample rather than
routing them through a side-channel string list.
| PARAMETER | DESCRIPTION |
|---|---|
message
|
The protobuf message to convert.
TYPE:
|
major_issues
|
A list to append major issues to. |
minor_issues
|
A list to append minor issues to. |
| RETURNS | DESCRIPTION |
|---|---|
MetricSample
|
The resulting |
Source code in src/frequenz/client/common/metrics/proto/v1alpha8/_sample.py
frequenz.client.common.metrics.proto.v1alpha8.metric_to_proto ¤
metric_to_proto(metric: Metric) -> ValueType