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

Rename metrics result to metrics query result #21036

Merged
merged 1 commit into from
Oct 4, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion sdk/monitor/azure-monitor-query/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
- Added `status` attribute to `LogsQueryResult`.
- Added `LogsQueryStatus` Enum to describe the status of a result.
- Added a new `LogsTableRow` type that represents a single row in a table.
- Items in `metrics` list in `MetricsResult` can now be accessed by metric names.
- Items in `metrics` list in `MetricsQueryResult` can now be accessed by metric names.
- Added `audience` keyword to support providing credential scope when creating clients.

### Breaking Changes
Expand All @@ -19,6 +19,7 @@
- `query_workspace` API now returns a union of `LogsQueryPartialResult` and `LogsQueryResult`.
- `query_batch` API now returns a union of `LogsQueryPartialResult`, `LogsQueryError` and `LogsQueryResult`.
- `metric_namespace` is renamed to `namespace` and is a keyword-only argument in `list_metric_definitions` API.
- `MetricsResult` is renamed to `MetricsQueryResult`.

## 1.0.0b4 (2021-09-09)

Expand Down
4 changes: 2 additions & 2 deletions sdk/monitor/azure-monitor-query/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -337,10 +337,10 @@ for metric in response.metrics:

#### Handle metrics query response

The metrics query API returns a `MetricsResult` object. The `MetricsResult` object contains properties such as a list of `Metric`-typed objects, `granularity`, `namespace`, and `timespan`. The `Metric` objects list can be accessed using the `metrics` param. Each `Metric` object in this list contains a list of `TimeSeriesElement` objects. Each `TimeSeriesElement` object contains `data` and `metadata_values` properties. In visual form, the object hierarchy of the response resembles the following structure:
The metrics query API returns a `MetricsQueryResult` object. The `MetricsQueryResult` object contains properties such as a list of `Metric`-typed objects, `granularity`, `namespace`, and `timespan`. The `Metric` objects list can be accessed using the `metrics` param. Each `Metric` object in this list contains a list of `TimeSeriesElement` objects. Each `TimeSeriesElement` object contains `data` and `metadata_values` properties. In visual form, the object hierarchy of the response resembles the following structure:

```
MetricsResult
MetricsQueryResult
|---granularity
|---timespan
|---cost
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
LogsQueryPartialResult,
LogsQueryStatus,
LogsTableRow,
MetricsResult,
MetricsQueryResult,
LogsBatchQuery,
MetricNamespace,
MetricNamespaceClassification,
Expand Down Expand Up @@ -46,7 +46,7 @@
"MetricNamespaceClassification",
"MetricDefinition",
"MetricUnit",
"MetricsResult",
"MetricsQueryResult",
"TimeSeriesElement",
"Metric",
"MetricValue",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
MonitorQueryClient,
)

from ._models import MetricsResult, MetricDefinition, MetricNamespace
from ._models import MetricsQueryResult, MetricDefinition, MetricNamespace
from ._helpers import get_metrics_authentication_policy, construct_iso8601

if TYPE_CHECKING:
Expand Down Expand Up @@ -67,7 +67,7 @@ def __init__(self, credential, **kwargs):

@distributed_trace
def query_resource(self, resource_uri, metric_names, **kwargs):
# type: (str, List[str], Any) -> MetricsResult
# type: (str, List[str], Any) -> MetricsQueryResult
"""Lists the metric values for a resource.

:param resource_uri: The identifier of the resource.
Expand Down Expand Up @@ -104,8 +104,8 @@ def query_resource(self, resource_uri, metric_names, **kwargs):
:paramtype filter: str
:keyword metric_namespace: Metric namespace to query metric definitions for.
:paramtype metric_namespace: str
:return: A MetricsResult object.
:rtype: ~azure.monitor.query.MetricsResult
:return: A MetricsQueryResult object.
:rtype: ~azure.monitor.query.MetricsQueryResult
:raises: ~azure.core.exceptions.HttpResponseError

.. admonition:: Example:
Expand All @@ -130,7 +130,7 @@ def query_resource(self, resource_uri, metric_names, **kwargs):
generated = self._metrics_op.list(
resource_uri, connection_verify=False, **kwargs
)
return MetricsResult._from_generated( # pylint: disable=protected-access
return MetricsQueryResult._from_generated( # pylint: disable=protected-access
generated
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def __getitem__(self, column):
return self._row[column]


class MetricsResult(object):
class MetricsQueryResult(object):
"""The response to a metrics query.

:ivar cost: The integer value representing the cost of the query, for data case.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from .._generated.aio._monitor_query_client import (
MonitorQueryClient,
)
from .._models import MetricsResult, MetricDefinition, MetricNamespace
from .._models import MetricsQueryResult, MetricDefinition, MetricNamespace
from ._helpers_asyc import get_metrics_authentication_policy
from .._helpers import construct_iso8601

Expand Down Expand Up @@ -55,7 +55,7 @@ def __init__(self, credential: "AsyncTokenCredential", **kwargs: Any) -> None:
@distributed_trace_async
async def query_resource(
self, resource_uri: str, metric_names: List[str], **kwargs: Any
) -> MetricsResult:
) -> MetricsQueryResult:
"""Lists the metric values for a resource.

**Note**: Although the start_time, end_time, duration are optional parameters, it is highly
Expand Down Expand Up @@ -95,8 +95,8 @@ async def query_resource(
:paramtype filter: str
:keyword metric_namespace: Metric namespace to query metric definitions for.
:paramtype metric_namespace: str
:return: A MetricsResult object.
:rtype: ~azure.monitor.query.MetricsResult
:return: A MetricsQueryResult object.
:rtype: ~azure.monitor.query.MetricsQueryResult
:raises: ~azure.core.exceptions.HttpResponseError
"""
timespan = construct_iso8601(kwargs.pop("timespan", None))
Expand All @@ -111,7 +111,7 @@ async def query_resource(
generated = await self._metrics_op.list(
resource_uri, connection_verify=False, **kwargs
)
return MetricsResult._from_generated( # pylint: disable=protected-access
return MetricsQueryResult._from_generated( # pylint: disable=protected-access
generated
)

Expand Down