diff --git a/sdk/monitor/azure-monitor-query/CHANGELOG.md b/sdk/monitor/azure-monitor-query/CHANGELOG.md index b594d3e8e8d9..520e648878bc 100644 --- a/sdk/monitor/azure-monitor-query/CHANGELOG.md +++ b/sdk/monitor/azure-monitor-query/CHANGELOG.md @@ -1,7 +1,10 @@ # Release History -## 1.0.0-beta.2 (Unreleased) +## 1.0.0-beta.2 (2021-07-08) +### Dependency Updates +- Upgraded `azure-core` from `1.17.0` to `1.18.0`. +- Upgraded `azure-core-http-netty` from `1.10.0` to `1.10.1`. ## 1.0.0-beta.1 (2021-06-09) Version 1.0.0-beta.1 is a preview of our efforts in creating a client library for querying Azure Monitor logs and @@ -9,5 +12,5 @@ metrics that is developer-friendly, idiomatic to the Java ecosystem, and as cons and platforms as possible. The principles that guide our efforts can be found in the [Azure SDK Design Guidelines for Java](https://azure.github.io/azure-sdk/java_introduction.html). -## Features Added +### Features Added - Initial release. Please see the README and wiki for information on using the new library. diff --git a/sdk/monitor/azure-monitor-query/README.md b/sdk/monitor/azure-monitor-query/README.md index 8f0f3edef91e..f57d20ab4c82 100644 --- a/sdk/monitor/azure-monitor-query/README.md +++ b/sdk/monitor/azure-monitor-query/README.md @@ -29,7 +29,7 @@ This client library provides access to query metrics and logs collected by Azure com.azure azure-monitor-query - 1.0.0-beta.1 + 1.0.0-beta.2 ``` diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/LogsQueryAsyncClient.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/LogsQueryAsyncClient.java index dade59355db2..47055513bd44 100644 --- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/LogsQueryAsyncClient.java +++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/LogsQueryAsyncClient.java @@ -30,6 +30,7 @@ import com.azure.monitor.query.models.LogsQueryOptions; import com.azure.monitor.query.models.LogsQueryResult; import com.azure.monitor.query.models.LogsQueryStatistics; +import com.azure.monitor.query.models.LogsQueryVisualization; import com.azure.monitor.query.models.LogsTable; import com.azure.monitor.query.models.LogsTableCell; import com.azure.monitor.query.models.LogsTableColumn; @@ -179,8 +180,11 @@ private Response convertToLogQueryBatchResult(Re for (BatchQueryResponse singleQueryResponse : batchResponse.getResponses()) { + BatchQueryResults queryResults = singleQueryResponse.getBody(); + LogsQueryResult logsQueryResult = getLogsQueryResult(queryResults.getTables(), + queryResults.getStatistics(), queryResults.getRender(), queryResults.getError()); LogsBatchQueryResult logsBatchQueryResult = new LogsBatchQueryResult(singleQueryResponse.getId(), - singleQueryResponse.getStatus(), getLogsQueryResult(singleQueryResponse.getBody())); + singleQueryResponse.getStatus(), logsQueryResult); batchResults.add(logsBatchQueryResult); } batchResults.sort(Comparator.comparingInt(o -> Integer.parseInt(o.getId()))); @@ -243,17 +247,19 @@ Mono> queryLogsWithResponse(LogsQueryOptions options, private Response convertToLogQueryResult(Response response) { QueryResults queryResults = response.getValue(); - LogsQueryResult logsQueryResult = getLogsQueryResult(queryResults); + LogsQueryResult logsQueryResult = getLogsQueryResult(queryResults.getTables(), queryResults.getStatistics(), + queryResults.getRender(), queryResults.getError()); return new SimpleResponse<>(response.getRequest(), response.getStatusCode(), response.getHeaders(), logsQueryResult); } - private LogsQueryResult getLogsQueryResult(QueryResults queryResults) { + private LogsQueryResult getLogsQueryResult(List innerTables, Object innerStats, + Object innerVisualization, ErrorInfo innerError) { List tables = null; - if (queryResults.getTables() != null) { + if (innerTables != null) { tables = new ArrayList<>(); - for (Table table : queryResults.getTables()) { + for (Table table : innerTables) { List tableCells = new ArrayList<>(); List tableRows = new ArrayList<>(); List tableColumns = new ArrayList<>(); @@ -275,52 +281,19 @@ private LogsQueryResult getLogsQueryResult(QueryResults queryResults) { } } - LogsQueryStatistics statistics = null; + LogsQueryStatistics queryStatistics = null; - if (queryResults.getStatistics() != null) { - statistics = new LogsQueryStatistics(queryResults.getStatistics()); + if (innerStats != null) { + queryStatistics = new LogsQueryStatistics(innerStats); } - LogsQueryResult logsQueryResult = new LogsQueryResult(tables, statistics, - mapLogsQueryError(queryResults.getError())); - return logsQueryResult; - } - - private LogsQueryResult getLogsQueryResult(BatchQueryResults queryResults) { - List tables = null; - - if (queryResults.getTables() != null) { - tables = new ArrayList<>(); - for (Table table : queryResults.getTables()) { - List tableCells = new ArrayList<>(); - List tableRows = new ArrayList<>(); - List tableColumns = new ArrayList<>(); - LogsTable logsTable = new LogsTable(tableCells, tableRows, tableColumns); - tables.add(logsTable); - List> rows = table.getRows(); - - for (int i = 0; i < rows.size(); i++) { - List row = rows.get(i); - LogsTableRow tableRow = new LogsTableRow(i, new ArrayList<>()); - tableRows.add(tableRow); - for (int j = 0; j < row.size(); j++) { - LogsTableCell cell = new LogsTableCell(table.getColumns().get(j).getName(), - table.getColumns().get(j).getType(), j, i, row.get(j)); - tableCells.add(cell); - tableRow.getTableRow().add(cell); - } - } - } - } - - LogsQueryStatistics statistics = null; - - if (queryResults.getStatistics() != null) { - statistics = new LogsQueryStatistics(queryResults.getStatistics()); + LogsQueryVisualization queryVisualization = null; + if (innerVisualization != null) { + queryVisualization = new LogsQueryVisualization(innerVisualization); } - LogsQueryResult logsQueryResult = new LogsQueryResult(tables, statistics, - mapLogsQueryError(queryResults.getError())); + LogsQueryResult logsQueryResult = new LogsQueryResult(tables, queryStatistics, queryVisualization, + mapLogsQueryError(innerError)); return logsQueryResult; } diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsQueryResult.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsQueryResult.java index f2d51d3efbba..806600f4a679 100644 --- a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsQueryResult.java +++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsQueryResult.java @@ -15,17 +15,21 @@ public final class LogsQueryResult { private final List logsTables; private final LogsQueryStatistics statistics; private final LogsQueryError error; + private final LogsQueryVisualization visualization; /** * Creates an instance {@link LogsQueryResult} with a list of {@link LogsTable}. * @param logsTables The list of {@link LogsTable} returned as query result. * @param statistics The query execution statistics. * @param error The error details if there was an error executing the query. + * @param visualization The visualization information for the logs query. */ - public LogsQueryResult(List logsTables, LogsQueryStatistics statistics, LogsQueryError error) { + public LogsQueryResult(List logsTables, LogsQueryStatistics statistics, + LogsQueryVisualization visualization, LogsQueryError error) { this.logsTables = logsTables; this.statistics = statistics; this.error = error; + this.visualization = visualization; } /** @@ -51,4 +55,12 @@ public LogsQueryStatistics getStatistics() { public LogsQueryError getError() { return error; } + + /** + * Returns the visualization information for the logs query. + * @return the visualization information for the logs query. + */ + public LogsQueryVisualization getVisualization() { + return visualization; + } } diff --git a/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsQueryVisualization.java b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsQueryVisualization.java new file mode 100644 index 000000000000..90d29b60110a --- /dev/null +++ b/sdk/monitor/azure-monitor-query/src/main/java/com/azure/monitor/query/models/LogsQueryVisualization.java @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. + +package com.azure.monitor.query.models; + +/** + * The visualization information related to query execution. + */ +public class LogsQueryVisualization { + private final Object rawVisualization; + + /** + * Creates an instance with the visualization information related to query execution. + * @param rawVisualization the visualization information related to query execution. + */ + public LogsQueryVisualization(Object rawVisualization) { + this.rawVisualization = rawVisualization; + } + + /** + * Returns the raw statistics information related to query execution as JSON object. + * @return the raw statistics information related to query execution as JSON object. + */ + public Object getRawVisualization() { + return rawVisualization; + } +}