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

[MA]: Applying limit to listing APIs (to avoid rate limit-err) #22793

Merged
merged 2 commits into from
Jul 6, 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
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,16 @@ void testListDataFeedTop3(HttpClient httpClient, MetricsAdvisorServiceVersion se
client = getMetricsAdvisorAdministrationBuilder(httpClient, serviceVersion).buildClient();

// Act & Assert
int pageCount = 0;
for (PagedResponse<DataFeed> dataFeedPagedResponse : client.listDataFeeds(new ListDataFeedOptions().setMaxPageSize(3),
Context.NONE)
.iterableByPage()) {
assertTrue(3 >= dataFeedPagedResponse.getValue().size());
pageCount++;
if (pageCount > 4) {
// Stop after 4 pages since there can be large number of feeds.
break;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,16 +117,19 @@ void testListMetricFeedbackFilterByDimensionFilter(HttpClient httpClient, Metric
// Arrange
client = getMetricsAdvisorBuilder(httpClient, serviceVersion).buildAsyncClient();
creatMetricFeedbackRunner(inputMetricFeedback -> {
final MetricFeedback feedbackAdded = client.addFeedback(METRIC_ID, inputMetricFeedback).block();
final OffsetDateTime firstFeedbackCreatedTime = feedbackAdded.getCreatedTime();
final MetricFeedback feedbackAdded = client.addFeedback(METRIC_ID, inputMetricFeedback
.setDimensionFilter(new DimensionKey(DIMENSION_FILTER)))
.block();
final OffsetDateTime feedbackCreatedTime = feedbackAdded.getCreatedTime();

// Act & Assert
StepVerifier.create(client.listFeedback(METRIC_ID,
new ListMetricFeedbackOptions().setFilter(new ListMetricFeedbackFilter()
.setTimeMode(FeedbackQueryTimeMode.FEEDBACK_CREATED_TIME)
.setStartTime(firstFeedbackCreatedTime.minusDays(1))
.setEndTime(firstFeedbackCreatedTime.plusDays(1))
.setDimensionFilter(new DimensionKey(DIMENSION_FILTER))).setMaxPageSize(10)))
.setStartTime(feedbackCreatedTime.minusDays(1))
.setEndTime(feedbackCreatedTime.plusDays(1))
.setDimensionFilter(new DimensionKey(DIMENSION_FILTER)))
.setMaxPageSize(10)))
.thenConsumeWhile(metricFeedback ->
metricFeedback.getDimensionFilter().asMap().keySet().stream().anyMatch(DIMENSION_FILTER::containsKey))
.verifyComplete();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,14 @@ void testListMetricFeedbackFilterByDimensionFilter(HttpClient httpClient,
creatMetricFeedbackRunner(inputMetricFeedback -> {
MetricFeedback createdFeedback = client.addFeedback(METRIC_ID, inputMetricFeedback
.setDimensionFilter(new DimensionKey(DIMENSION_FILTER)));
final OffsetDateTime feedbackCreatedTime = createdFeedback.getCreatedTime();

// Act & Assert
Assertions.assertNotNull(createdFeedback.getId());
client.listFeedback(METRIC_ID, new ListMetricFeedbackOptions().setFilter(new ListMetricFeedbackFilter()
.setTimeMode(FeedbackQueryTimeMode.FEEDBACK_CREATED_TIME)
.setStartTime(feedbackCreatedTime.minusDays(1))
.setEndTime(feedbackCreatedTime.plusDays(1))
.setDimensionFilter(new DimensionKey(DIMENSION_FILTER)))
.setMaxPageSize(10),
Context.NONE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
"Uri" : "https://REDACTED.cognitiveservices.azure.com/metricsadvisor/v1.0/alert/anomaly/configurations/204a211a-c5f4-45f3-a30e-512fb25d1d2c/alerts/query?$maxpagesize=10",
"Headers" : {
"User-Agent" : "azsdk-java-azure-ai-metricsadvisor/1.0.0-beta.5 (11.0.11; Mac OS X; 11.4)",
"x-ms-client-request-id" : "d804f74d-ca95-4671-831b-c6d4313c1699",
"x-ms-client-request-id" : "deb3e2eb-4164-49b0-9b73-7a3dd93cc90e",
"Content-Type" : "application/json"
},
"Response" : {
"x-request-id" : "de352a76-57eb-44e2-9b05-a8939b146905",
"x-request-id" : "286468f2-b0ea-4f35-9b84-7459e53c4058",
"content-length" : "587",
"x-envoy-upstream-service-time" : "38",
"x-envoy-upstream-service-time" : "107",
"Strict-Transport-Security" : "max-age=31536000; includeSubDomains; preload",
"x-content-type-options" : "nosniff",
"apim-request-id" : "de352a76-57eb-44e2-9b05-a8939b146905",
"apim-request-id" : "286468f2-b0ea-4f35-9b84-7459e53c4058",
"retry-after" : "0",
"StatusCode" : "200",
"Body" : "{\"value\":[{\"alertId\":\"175434e3400\",\"timestamp\":\"2020-10-20T00:00:00Z\",\"createdTime\":\"2020-10-21T15:54:37.687Z\",\"modifiedTime\":\"2020-10-22T00:03:26.275Z\"},{\"alertId\":\"1753e27d800\",\"timestamp\":\"2020-10-19T00:00:00Z\",\"createdTime\":\"2020-10-21T15:54:37.468Z\",\"modifiedTime\":\"2020-10-21T15:54:37.522Z\"},{\"alertId\":\"17539017c00\",\"timestamp\":\"2020-10-18T00:00:00Z\",\"createdTime\":\"2020-10-21T15:54:37.213Z\",\"modifiedTime\":\"2020-10-21T15:54:37.286Z\"},{\"alertId\":\"17533db2000\",\"timestamp\":\"2020-10-17T00:00:00Z\",\"createdTime\":\"2020-10-21T15:54:36.975Z\",\"modifiedTime\":\"2020-10-21T15:54:37.037Z\"}]}",
"Date" : "Mon, 21 Jun 2021 23:23:19 GMT",
"Date" : "Tue, 06 Jul 2021 19:51:24 GMT",
"Content-Type" : "application/json; charset=utf-8"
},
"Exception" : null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@
"Uri" : "https://REDACTED.cognitiveservices.azure.com/metricsadvisor/v1.0/alert/anomaly/configurations/204a211a-c5f4-45f3-a30e-512fb25d1d2c/alerts/query?$maxpagesize=10",
"Headers" : {
"User-Agent" : "azsdk-java-azure-ai-metricsadvisor/1.0.0-beta.5 (11.0.11; Mac OS X; 11.4)",
"x-ms-client-request-id" : "388d8d51-86d9-45a9-8946-3f433046fa5b",
"x-ms-client-request-id" : "140f8c24-8936-40ad-9c4d-51093da2a60f",
"Content-Type" : "application/json"
},
"Response" : {
"x-request-id" : "3542ac84-989e-40a3-96b6-7839d7f951d5",
"x-request-id" : "4aaaff33-ed60-408c-96dc-fc7def479362",
"content-length" : "587",
"x-envoy-upstream-service-time" : "276",
"x-envoy-upstream-service-time" : "10271",
"Strict-Transport-Security" : "max-age=31536000; includeSubDomains; preload",
"x-content-type-options" : "nosniff",
"apim-request-id" : "3542ac84-989e-40a3-96b6-7839d7f951d5",
"apim-request-id" : "4aaaff33-ed60-408c-96dc-fc7def479362",
"retry-after" : "0",
"StatusCode" : "200",
"Body" : "{\"value\":[{\"alertId\":\"175434e3400\",\"timestamp\":\"2020-10-20T00:00:00Z\",\"createdTime\":\"2020-10-21T15:54:37.687Z\",\"modifiedTime\":\"2020-10-22T00:03:26.275Z\"},{\"alertId\":\"1753e27d800\",\"timestamp\":\"2020-10-19T00:00:00Z\",\"createdTime\":\"2020-10-21T15:54:37.468Z\",\"modifiedTime\":\"2020-10-21T15:54:37.522Z\"},{\"alertId\":\"17539017c00\",\"timestamp\":\"2020-10-18T00:00:00Z\",\"createdTime\":\"2020-10-21T15:54:37.213Z\",\"modifiedTime\":\"2020-10-21T15:54:37.286Z\"},{\"alertId\":\"17533db2000\",\"timestamp\":\"2020-10-17T00:00:00Z\",\"createdTime\":\"2020-10-21T15:54:36.975Z\",\"modifiedTime\":\"2020-10-21T15:54:37.037Z\"}]}",
"Date" : "Mon, 21 Jun 2021 23:22:46 GMT",
"Date" : "Tue, 06 Jul 2021 19:51:05 GMT",
"Content-Type" : "application/json; charset=utf-8"
},
"Exception" : null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,60 +4,60 @@
"Uri" : "https://REDACTED.cognitiveservices.azure.com/metricsadvisor/v1.0/alert/anomaly/configurations",
"Headers" : {
"User-Agent" : "azsdk-java-azure-ai-metricsadvisor/1.0.0-beta.5 (11.0.11; Mac OS X; 11.4)",
"x-ms-client-request-id" : "418ae99c-0af0-477f-9e8d-a3abfb596e7f",
"x-ms-client-request-id" : "0ed80e9a-e417-47db-9996-e64737b771eb",
"Content-Type" : "application/json"
},
"Response" : {
"x-request-id" : "0bd3e443-8d85-421c-9f98-41f717ac20f0",
"x-request-id" : "33cde621-d9a6-4f3c-812f-5465585b1563",
"content-length" : "0",
"x-envoy-upstream-service-time" : "85",
"x-envoy-upstream-service-time" : "230",
"Strict-Transport-Security" : "max-age=31536000; includeSubDomains; preload",
"x-content-type-options" : "nosniff",
"apim-request-id" : "0bd3e443-8d85-421c-9f98-41f717ac20f0",
"apim-request-id" : "33cde621-d9a6-4f3c-812f-5465585b1563",
"retry-after" : "0",
"StatusCode" : "201",
"Date" : "Mon, 21 Jun 2021 23:23:18 GMT",
"Location" : "https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/alert/anomaly/configurations/60aee64a-50d5-4f96-8d97-13d9ccb7f10e"
"Date" : "Tue, 06 Jul 2021 19:51:25 GMT",
"Location" : "https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/alert/anomaly/configurations/058e8bc9-3bf8-4c29-ae55-bb3a14c43592"
},
"Exception" : null
}, {
"Method" : "GET",
"Uri" : "https://REDACTED.cognitiveservices.azure.com/metricsadvisor/v1.0/alert/anomaly/configurations/60aee64a-50d5-4f96-8d97-13d9ccb7f10e",
"Uri" : "https://REDACTED.cognitiveservices.azure.com/metricsadvisor/v1.0/alert/anomaly/configurations/058e8bc9-3bf8-4c29-ae55-bb3a14c43592",
"Headers" : {
"User-Agent" : "azsdk-java-azure-ai-metricsadvisor/1.0.0-beta.5 (11.0.11; Mac OS X; 11.4)",
"x-ms-client-request-id" : "e8687f49-f132-4819-b163-06985255105f"
"x-ms-client-request-id" : "68fb4154-72bc-4062-9e05-5951decd76cc"
},
"Response" : {
"x-request-id" : "8416e618-7528-4027-a878-91c181846d8a",
"x-request-id" : "5f82a358-d66a-463b-a9c4-865156b0a39f",
"content-length" : "401",
"x-envoy-upstream-service-time" : "46",
"x-envoy-upstream-service-time" : "94",
"Strict-Transport-Security" : "max-age=31536000; includeSubDomains; preload",
"x-content-type-options" : "nosniff",
"apim-request-id" : "8416e618-7528-4027-a878-91c181846d8a",
"apim-request-id" : "5f82a358-d66a-463b-a9c4-865156b0a39f",
"retry-after" : "0",
"StatusCode" : "200",
"Body" : "{\"anomalyAlertingConfigurationId\":\"60aee64a-50d5-4f96-8d97-13d9ccb7f10e\",\"name\":\"test_alert_configuration\",\"description\":\"testing_alert_configuration_description\",\"splitAlertByDimensions\":[],\"hookIds\":[\"dd3bfc43-c461-440d-9fcd-f6326d8e7fae\"],\"metricAlertingConfigurations\":[{\"anomalyDetectionConfigurationId\":\"fb5a6ed6-2b9e-4b72-8b0c-0046ead1c15c\",\"anomalyScopeType\":\"All\",\"negationOperation\":false}]}",
"Date" : "Mon, 21 Jun 2021 23:23:18 GMT",
"Body" : "{\"anomalyAlertingConfigurationId\":\"058e8bc9-3bf8-4c29-ae55-bb3a14c43592\",\"name\":\"test_alert_configuration\",\"description\":\"testing_alert_configuration_description\",\"splitAlertByDimensions\":[],\"hookIds\":[\"dd3bfc43-c461-440d-9fcd-f6326d8e7fae\"],\"metricAlertingConfigurations\":[{\"anomalyDetectionConfigurationId\":\"fb5a6ed6-2b9e-4b72-8b0c-0046ead1c15c\",\"anomalyScopeType\":\"All\",\"negationOperation\":false}]}",
"Date" : "Tue, 06 Jul 2021 19:51:25 GMT",
"Content-Type" : "application/json; charset=utf-8"
},
"Exception" : null
}, {
"Method" : "DELETE",
"Uri" : "https://REDACTED.cognitiveservices.azure.com/metricsadvisor/v1.0/alert/anomaly/configurations/60aee64a-50d5-4f96-8d97-13d9ccb7f10e",
"Uri" : "https://REDACTED.cognitiveservices.azure.com/metricsadvisor/v1.0/alert/anomaly/configurations/058e8bc9-3bf8-4c29-ae55-bb3a14c43592",
"Headers" : {
"User-Agent" : "azsdk-java-azure-ai-metricsadvisor/1.0.0-beta.5 (11.0.11; Mac OS X; 11.4)",
"x-ms-client-request-id" : "4f9a6413-e175-459e-9bea-8356681cb790"
"x-ms-client-request-id" : "4ea1c7f7-7125-4d94-abfa-651a60a59a50"
},
"Response" : {
"x-request-id" : "f3fc0d40-6bb5-4f09-8142-bd96b6797d50",
"x-request-id" : "6e27eca7-99dd-4d29-99b1-fa71f36da766",
"content-length" : "0",
"x-envoy-upstream-service-time" : "67",
"x-envoy-upstream-service-time" : "133",
"Strict-Transport-Security" : "max-age=31536000; includeSubDomains; preload",
"x-content-type-options" : "nosniff",
"apim-request-id" : "f3fc0d40-6bb5-4f09-8142-bd96b6797d50",
"apim-request-id" : "6e27eca7-99dd-4d29-99b1-fa71f36da766",
"retry-after" : "0",
"StatusCode" : "204",
"Date" : "Mon, 21 Jun 2021 23:23:19 GMT"
"Date" : "Tue, 06 Jul 2021 19:51:26 GMT"
},
"Exception" : null
} ],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,80 +4,80 @@
"Uri" : "https://REDACTED.cognitiveservices.azure.com/metricsadvisor/v1.0/alert/anomaly/configurations",
"Headers" : {
"User-Agent" : "azsdk-java-azure-ai-metricsadvisor/1.0.0-beta.5 (11.0.11; Mac OS X; 11.4)",
"x-ms-client-request-id" : "4e40d3cb-fa6f-4137-9757-cf5714551a27",
"x-ms-client-request-id" : "eac03718-360c-455d-aafc-b38236409832",
"Content-Type" : "application/json"
},
"Response" : {
"x-request-id" : "a525eb39-d654-405d-9fe1-ab6753d84649",
"x-request-id" : "d9e2b236-aee5-49ed-8173-5e3da899ad21",
"content-length" : "0",
"x-envoy-upstream-service-time" : "86",
"x-envoy-upstream-service-time" : "225",
"Strict-Transport-Security" : "max-age=31536000; includeSubDomains; preload",
"x-content-type-options" : "nosniff",
"apim-request-id" : "a525eb39-d654-405d-9fe1-ab6753d84649",
"apim-request-id" : "d9e2b236-aee5-49ed-8173-5e3da899ad21",
"retry-after" : "0",
"StatusCode" : "201",
"Date" : "Mon, 21 Jun 2021 23:23:14 GMT",
"Location" : "https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/alert/anomaly/configurations/abdd452b-65b8-435f-8dc2-7224bd12dd5d"
"Date" : "Tue, 06 Jul 2021 19:51:20 GMT",
"Location" : "https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/alert/anomaly/configurations/8a2da443-78d3-4e8d-af6e-739dc422154d"
},
"Exception" : null
}, {
"Method" : "GET",
"Uri" : "https://REDACTED.cognitiveservices.azure.com/metricsadvisor/v1.0/alert/anomaly/configurations/abdd452b-65b8-435f-8dc2-7224bd12dd5d",
"Uri" : "https://REDACTED.cognitiveservices.azure.com/metricsadvisor/v1.0/alert/anomaly/configurations/8a2da443-78d3-4e8d-af6e-739dc422154d",
"Headers" : {
"User-Agent" : "azsdk-java-azure-ai-metricsadvisor/1.0.0-beta.5 (11.0.11; Mac OS X; 11.4)",
"x-ms-client-request-id" : "ccaa842f-aa8b-4289-b2d3-b8516f2b7880"
"x-ms-client-request-id" : "54b7c97f-1d7d-4aed-a338-53063e29c48a"
},
"Response" : {
"x-request-id" : "e67add8f-0846-4b67-8867-951bb3af1586",
"x-request-id" : "87d68be8-5803-47c0-8a0f-be7581851b2d",
"content-length" : "401",
"x-envoy-upstream-service-time" : "40",
"x-envoy-upstream-service-time" : "103",
"Strict-Transport-Security" : "max-age=31536000; includeSubDomains; preload",
"x-content-type-options" : "nosniff",
"apim-request-id" : "e67add8f-0846-4b67-8867-951bb3af1586",
"apim-request-id" : "87d68be8-5803-47c0-8a0f-be7581851b2d",
"retry-after" : "0",
"StatusCode" : "200",
"Body" : "{\"anomalyAlertingConfigurationId\":\"abdd452b-65b8-435f-8dc2-7224bd12dd5d\",\"name\":\"test_alert_configuration\",\"description\":\"testing_alert_configuration_description\",\"splitAlertByDimensions\":[],\"hookIds\":[\"dd3bfc43-c461-440d-9fcd-f6326d8e7fae\"],\"metricAlertingConfigurations\":[{\"anomalyDetectionConfigurationId\":\"fb5a6ed6-2b9e-4b72-8b0c-0046ead1c15c\",\"anomalyScopeType\":\"All\",\"negationOperation\":false}]}",
"Date" : "Mon, 21 Jun 2021 23:23:14 GMT",
"Body" : "{\"anomalyAlertingConfigurationId\":\"8a2da443-78d3-4e8d-af6e-739dc422154d\",\"name\":\"test_alert_configuration\",\"description\":\"testing_alert_configuration_description\",\"splitAlertByDimensions\":[],\"hookIds\":[\"dd3bfc43-c461-440d-9fcd-f6326d8e7fae\"],\"metricAlertingConfigurations\":[{\"anomalyDetectionConfigurationId\":\"fb5a6ed6-2b9e-4b72-8b0c-0046ead1c15c\",\"anomalyScopeType\":\"All\",\"negationOperation\":false}]}",
"Date" : "Tue, 06 Jul 2021 19:51:21 GMT",
"Content-Type" : "application/json; charset=utf-8"
},
"Exception" : null
}, {
"Method" : "DELETE",
"Uri" : "https://REDACTED.cognitiveservices.azure.com/metricsadvisor/v1.0/alert/anomaly/configurations/abdd452b-65b8-435f-8dc2-7224bd12dd5d",
"Uri" : "https://REDACTED.cognitiveservices.azure.com/metricsadvisor/v1.0/alert/anomaly/configurations/8a2da443-78d3-4e8d-af6e-739dc422154d",
"Headers" : {
"User-Agent" : "azsdk-java-azure-ai-metricsadvisor/1.0.0-beta.5 (11.0.11; Mac OS X; 11.4)",
"x-ms-client-request-id" : "fa4cd489-984e-493b-b0a8-9d1e62486d88"
"x-ms-client-request-id" : "3f0ea4a0-ab9b-44e7-8595-c655a890cdaa"
},
"Response" : {
"x-request-id" : "d2910284-77e8-4a4a-903e-9b219241475f",
"x-request-id" : "e1d07af8-d645-42e6-8e22-bbb7e760551c",
"content-length" : "0",
"x-envoy-upstream-service-time" : "61",
"x-envoy-upstream-service-time" : "141",
"Strict-Transport-Security" : "max-age=31536000; includeSubDomains; preload",
"x-content-type-options" : "nosniff",
"apim-request-id" : "d2910284-77e8-4a4a-903e-9b219241475f",
"apim-request-id" : "e1d07af8-d645-42e6-8e22-bbb7e760551c",
"retry-after" : "0",
"StatusCode" : "204",
"Date" : "Mon, 21 Jun 2021 23:23:14 GMT"
"Date" : "Tue, 06 Jul 2021 19:51:20 GMT"
},
"Exception" : null
}, {
"Method" : "GET",
"Uri" : "https://REDACTED.cognitiveservices.azure.com/metricsadvisor/v1.0/alert/anomaly/configurations/abdd452b-65b8-435f-8dc2-7224bd12dd5d",
"Uri" : "https://REDACTED.cognitiveservices.azure.com/metricsadvisor/v1.0/alert/anomaly/configurations/8a2da443-78d3-4e8d-af6e-739dc422154d",
"Headers" : {
"User-Agent" : "azsdk-java-azure-ai-metricsadvisor/1.0.0-beta.5 (11.0.11; Mac OS X; 11.4)",
"x-ms-client-request-id" : "19a3a1c6-4ea7-4d9a-8a81-20c8a37adfc9"
"x-ms-client-request-id" : "c5703e1a-9c91-47a3-b359-c92bb8646fb3"
},
"Response" : {
"x-request-id" : "fd00006c-89bc-416c-af58-5fe0835dccd8",
"x-request-id" : "01397527-b648-4448-8ab1-dab50b918651",
"content-length" : "123",
"x-envoy-upstream-service-time" : "21",
"x-envoy-upstream-service-time" : "64",
"Strict-Transport-Security" : "max-age=31536000; includeSubDomains; preload",
"x-content-type-options" : "nosniff",
"apim-request-id" : "fd00006c-89bc-416c-af58-5fe0835dccd8",
"apim-request-id" : "01397527-b648-4448-8ab1-dab50b918651",
"retry-after" : "0",
"StatusCode" : "404",
"Body" : "{\"code\":\"Not Found\",\"message\":\"Not found this AnomalyAlertingConfiguration. TraceId: 444523f0-c38b-4245-9a07-a2fe4ba99c4e\"}",
"Date" : "Mon, 21 Jun 2021 23:23:14 GMT",
"Body" : "{\"code\":\"Not Found\",\"message\":\"Not found this AnomalyAlertingConfiguration. TraceId: 471a471e-ac86-449b-801a-b1606affd538\"}",
"Date" : "Tue, 06 Jul 2021 19:51:21 GMT",
"Content-Type" : "application/json; charset=utf-8"
},
"Exception" : null
Expand Down
Loading