From a55d9aa423c1ffa19934fc944e100ac40083c5e8 Mon Sep 17 00:00:00 2001 From: Jeremy Meng Date: Thu, 29 Oct 2020 15:47:07 -0700 Subject: [PATCH 1/3] [MetricsAdvisor] change timestamps type from Date to number This addresses one of the Arch Board review feedback. I still keep the timestamps in MetricSeriesData and MetricEnrichedSeriesData as Date type because their most common usage is plotting because keeping them as Date make it easier to use year/month/date in x-axis labels. --- .../review/ai-metrics-advisor.api.md | 21 ++++-- .../src/metricsAdvisorAdministrationClient.ts | 31 +++++--- .../src/metricsAdvisorClient.ts | 38 ++++++---- .../ai-metrics-advisor/src/models.ts | 73 +++++++++++++++++-- 4 files changed, 125 insertions(+), 38 deletions(-) diff --git a/sdk/metricsadvisor/ai-metrics-advisor/review/ai-metrics-advisor.api.md b/sdk/metricsadvisor/ai-metrics-advisor/review/ai-metrics-advisor.api.md index e55f6fae14d9..0c3b3b25e613 100644 --- a/sdk/metricsadvisor/ai-metrics-advisor/review/ai-metrics-advisor.api.md +++ b/sdk/metricsadvisor/ai-metrics-advisor/review/ai-metrics-advisor.api.md @@ -52,7 +52,7 @@ export interface AnomalyAlert { createdOn?: Date; id: string; modifiedOn?: Date; - timestamp?: Date; + timestamp?: number; } // @public @@ -335,7 +335,7 @@ export interface DataPointAnomaly { seriesKey: DimensionKey; severity: AnomalySeverity; status?: AnomalyStatus; - timestamp: Date; + timestamp: number; } // @public @@ -407,7 +407,7 @@ export type EmailNotificationHookPatch = { export interface EnrichmentStatus { readonly message?: string; readonly status?: string; - readonly timestamp?: Date; + readonly timestamp?: number; } // @public @@ -473,6 +473,17 @@ export type GetIncidentRootCauseResponse = { }; }; +// @public +export type GetIngestionProgressResponse = { + readonly latestSuccessTimestamp?: number; + readonly latestActiveTimestamp?: number; +} & { + _response: coreHttp.HttpResponse & { + bodyAsText: string; + parsedBody: any; + }; +}; + // @public export type GetMetricEnrichedSeriesDataOptions = {} & OperationOptions; @@ -571,7 +582,7 @@ export interface InfluxDBParameter { export interface IngestionStatus { readonly message?: string; readonly status?: IngestionStatusType; - readonly timestamp?: Date; + readonly timestamp?: number; } // @public @@ -810,7 +821,7 @@ export class MetricsAdvisorAdministrationClient { readonly endpointUrl: string; getAnomalyAlertConfiguration(id: string, options?: OperationOptions): Promise; getDataFeed(id: string, options?: OperationOptions): Promise; - getDataFeedIngestionProgress(dataFeedId: string, options?: {}): Promise; + getDataFeedIngestionProgress(dataFeedId: string, options?: {}): Promise; getHook(id: string, options?: OperationOptions): Promise; getMetricAnomalyDetectionConfiguration(id: string, options?: OperationOptions): Promise; listAnomalyAlertConfigurations(detectionConfigId: string, options?: OperationOptions): PagedAsyncIterableIterator; diff --git a/sdk/metricsadvisor/ai-metrics-advisor/src/metricsAdvisorAdministrationClient.ts b/sdk/metricsadvisor/ai-metrics-advisor/src/metricsAdvisorAdministrationClient.ts index 76a18e5390af..f285da19e2a3 100644 --- a/sdk/metricsadvisor/ai-metrics-advisor/src/metricsAdvisorAdministrationClient.ts +++ b/sdk/metricsadvisor/ai-metrics-advisor/src/metricsAdvisorAdministrationClient.ts @@ -44,11 +44,7 @@ import { HooksPageResponse, DataFeedStatus } from "./models"; -import { - DataSourceType, - GeneratedClientGetIngestionProgressResponse, - NeedRollupEnum -} from "./generated/models"; +import { DataSourceType, NeedRollupEnum } from "./generated/models"; import { fromServiceAnomalyDetectionConfiguration, fromServiceDataFeedDetailUnion, @@ -1295,7 +1291,7 @@ export class MetricsAdvisorAdministrationClient { public async getDataFeedIngestionProgress( dataFeedId: string, options = {} - ): Promise { + ): Promise { const { span, updatedOptions: finalOptions } = createSpan( "MetricsAdvisorAdministrationClient-getDataFeedIngestionProgress", options @@ -1303,7 +1299,12 @@ export class MetricsAdvisorAdministrationClient { try { const requestOptions = operationOptionsToRequestOptionsBase(finalOptions); - return await this.client.getIngestionProgress(dataFeedId, requestOptions); + const response = await this.client.getIngestionProgress(dataFeedId, requestOptions); + return { + latestActiveTimestamp: response.latestActiveTimestamp?.getTime(), + latestSuccessTimestamp: response.latestSuccessTimestamp?.getTime(), + _response: response._response + }; } catch (e) { span.setStatus({ code: CanonicalCode.UNKNOWN, @@ -1338,7 +1339,13 @@ export class MetricsAdvisorAdministrationClient { top: options?.maxPageSize } ); - const resultArray = Object.defineProperty(segmentResponse.value || [], "continuationToken", { + const resultArray = Object.defineProperty(segmentResponse.value?.map((s) => { + return { + timestamp: s.timestamp?.getTime(), + status: s.status, + message: s.message + }; + }) || [], "continuationToken", { enumerable: true, value: segmentResponse.nextLink }); @@ -1362,7 +1369,13 @@ export class MetricsAdvisorAdministrationClient { options ); - const resultArray = Object.defineProperty(segmentResponse.value || [], "continuationToken", { + const resultArray = Object.defineProperty(segmentResponse.value?.map((s) => { + return { + timestamp: s.timestamp?.getTime(), + status: s.status, + message: s.message + }; + }) || [], "continuationToken", { enumerable: true, value: segmentResponse.nextLink }); diff --git a/sdk/metricsadvisor/ai-metrics-advisor/src/metricsAdvisorClient.ts b/sdk/metricsadvisor/ai-metrics-advisor/src/metricsAdvisorClient.ts index 4a3068b436cd..01b446b9541f 100644 --- a/sdk/metricsadvisor/ai-metrics-advisor/src/metricsAdvisorClient.ts +++ b/sdk/metricsadvisor/ai-metrics-advisor/src/metricsAdvisorClient.ts @@ -32,16 +32,12 @@ import { MetricEnrichmentStatusPageResponse, MetricSeriesDefinition, DimensionKey, + EnrichmentStatus, GetMetricSeriesDataResponse, MetricFeedbackPageResponse, AlertQueryTimeMode } from "./models"; -import { - SeverityFilterCondition, - EnrichmentStatus, - FeedbackType, - FeedbackQueryTimeMode -} from "./generated/models"; +import { SeverityFilterCondition, FeedbackType, FeedbackQueryTimeMode } from "./generated/models"; import { toServiceMetricFeedbackUnion, fromServiceMetricFeedbackUnion } from "./transforms"; import { createClientPipeline } from "./createClientPipeline"; @@ -259,7 +255,7 @@ export class MetricsAdvisorClient { alertConfigId: alertConfigId, createdOn: a.createdTime, modifiedOn: a.modifiedTime, - timestamp: a.timestamp + timestamp: a.timestamp?.getTime() }; }); const resultArray = Object.defineProperty(alerts || [], "continuationToken", { @@ -287,7 +283,7 @@ export class MetricsAdvisorClient { alertConfigId: alertConfigId, createdOn: a.createdTime, modifiedOn: a.modifiedTime, - timestamp: a.timestamp + timestamp: a.timestamp?.getTime() }; }); const resultArray = Object.defineProperty(alerts || [], "continuationToken", { @@ -454,13 +450,12 @@ export class MetricsAdvisorClient { return { detectionConfigurationId: a.anomalyDetectionConfigurationId!, metricId: a.metricId, - timestampe: a.timestamp, createdOn: a.createdTime, modifiedOn: a.modifiedTime, seriesKey: a.dimension, severity: a.property.anomalySeverity, status: a.property.anomalyStatus, - timestamp: a.timestamp + timestamp: a.timestamp.getTime() }; }); const resultArray = Object.defineProperty(anomalies || [], "continuationToken", { @@ -490,13 +485,12 @@ export class MetricsAdvisorClient { return { detectionConfigurationId: a.anomalyDetectionConfigurationId!, metricId: a.metricId, - timestampe: a.timestamp, createdOn: a.createdTime, modifiedOn: a.modifiedTime, seriesKey: a.dimension, severity: a.property.anomalySeverity, status: a.property.anomalyStatus, - timestamp: a.timestamp + timestamp: a.timestamp.getTime() }; }); const resultArray = Object.defineProperty(anomalies || [], "continuationToken", { @@ -931,7 +925,7 @@ export class MetricsAdvisorClient { return { detectionConfigurationId: detectionConfigId, metricId: a.metricId, - timestamp: a.timestamp, + timestamp: a.timestamp.getTime(), createdOn: a.createdTime, modifiedOn: a.modifiedTime, seriesKey: a.dimension, @@ -963,7 +957,7 @@ export class MetricsAdvisorClient { return { detectionConfigurationId: detectionConfigId, metricId: a.metricId, - timestamp: a.timestamp, + timestamp: a.timestamp.getTime(), createdOn: a.createdTime, modifiedOn: a.modifiedTime, seriesKey: a.dimension, @@ -2180,7 +2174,13 @@ export class MetricsAdvisorClient { ...options, top: maxPageSize }); - const resultArray = Object.defineProperty(segmentResponse.value || [], "continuationToken", { + const resultArray = Object.defineProperty(segmentResponse.value?.map((s) => { + return { + timestamp: s.timestamp?.getTime(), + status: s.status, + message: s.message + }; + }) || [], "continuationToken", { enumerable: true, value: segmentResponse.nextLink }); @@ -2199,7 +2199,13 @@ export class MetricsAdvisorClient { optionsBody, options ); - const resultArray = Object.defineProperty(segmentResponse.value || [], "continuationToken", { + const resultArray = Object.defineProperty(segmentResponse.value?.map((s) => { + return { + timestamp: s.timestamp?.getTime(), + status: s.status, + message: s.message + }; + }) || [], "continuationToken", { enumerable: true, value: segmentResponse.nextLink }); diff --git a/sdk/metricsadvisor/ai-metrics-advisor/src/models.ts b/sdk/metricsadvisor/ai-metrics-advisor/src/models.ts index 1e1e3a173c63..9f4d5ecf0f7c 100644 --- a/sdk/metricsadvisor/ai-metrics-advisor/src/models.ts +++ b/sdk/metricsadvisor/ai-metrics-advisor/src/models.ts @@ -4,7 +4,6 @@ import * as coreHttp from "@azure/core-http"; import { - IngestionStatus, SqlSourceParameter, SuppressCondition, SmartDetectionCondition, @@ -22,8 +21,8 @@ import { TopNGroupScope, SeverityCondition, AlertSnoozeCondition, - EnrichmentStatus, - DataFeedDetailStatus + DataFeedDetailStatus, + IngestionStatusType } from "./generated/models"; export { @@ -31,8 +30,6 @@ export { AlertSnoozeCondition, SmartDetectionCondition, TopNGroupScope, - EnrichmentStatus, - IngestionStatus, AzureApplicationInsightsParameter, AzureBlobParameter, AzureCosmosDBParameter, @@ -897,7 +894,7 @@ export interface DataPointAnomaly { /** * anomaly time */ - timestamp: Date; + timestamp: number; /** * created time * @@ -941,7 +938,7 @@ export interface AnomalyAlert { /** * anomaly time */ - timestamp?: Date; // TODO: why optional? + timestamp?: number; // TODO: why optional? /** * created time */ @@ -1507,6 +1504,21 @@ export interface MetricSeriesPageResponse extends Array }; } +export interface EnrichmentStatus { + /** + * data slice timestamp. + */ + readonly timestamp?: number; + /** + * latest enrichment status for this data slice. + */ + readonly status?: string; + /** + * the trimmed message describes details of the enrichment status. + */ + readonly message?: string; +} + /** * Contains response data for the listMetricEnrichmentStatus operation. */ @@ -1579,6 +1591,20 @@ export interface GetMetricSeriesDataResponse extends Array { }; } +export interface IngestionStatus { + /** + * data slice timestamp. + */ + readonly timestamp?: number; + /** + * latest ingestion task status for this data slice. + */ + readonly status?: IngestionStatusType; + /** + * the trimmed message of last ingestion job. + */ + readonly message?: string; +} /** * Contains response data for the ListDataFeedIngestionStatus operation. */ @@ -1688,4 +1714,35 @@ export interface HooksPageResponse extends Array { */ parsedBody: any; }; -} +}; + +/** + * Contains response data for the getDataFeedIngestionProgress operation. + */ +export type GetIngestionProgressResponse = { + /** + * the timestamp of lastest success ingestion job. + * null indicates not available + */ + readonly latestSuccessTimestamp?: number; + /** + * the timestamp of lastest ingestion job with status update. + * null indicates not available + */ + readonly latestActiveTimestamp?: number; +} & { + /** + * The underlying HTTP response. + */ + _response: coreHttp.HttpResponse & { + /** + * The response body as text (string format) + */ + bodyAsText: string; + + /** + * The response body as parsed JSON or XML + */ + parsedBody: any; + }; +}; From 6d9b87f8a08c012dba8efca2f5a4d15d09546378 Mon Sep 17 00:00:00 2001 From: Jeremy Meng Date: Tue, 3 Nov 2020 20:06:45 +0000 Subject: [PATCH 2/3] Remove unused type --- .../review/ai-metrics-advisor.api.md | 8 --- .../src/metricsAdvisorAdministrationClient.ts | 51 +++++++++++-------- .../src/metricsAdvisorClient.ts | 48 +++++++++-------- .../ai-metrics-advisor/src/models.ts | 3 +- 4 files changed, 59 insertions(+), 51 deletions(-) diff --git a/sdk/metricsadvisor/ai-metrics-advisor/review/ai-metrics-advisor.api.md b/sdk/metricsadvisor/ai-metrics-advisor/review/ai-metrics-advisor.api.md index 0c3b3b25e613..92774be5ef63 100644 --- a/sdk/metricsadvisor/ai-metrics-advisor/review/ai-metrics-advisor.api.md +++ b/sdk/metricsadvisor/ai-metrics-advisor/review/ai-metrics-advisor.api.md @@ -416,14 +416,6 @@ export type FeedbackQueryTimeMode = "MetricTimestamp" | "FeedbackCreatedTime"; // @public export type FeedbackType = "Anomaly" | "ChangePoint" | "Period" | "Comment"; -// @public -export type GeneratedClientGetIngestionProgressResponse = DataFeedIngestionProgress & { - _response: coreHttp.HttpResponse & { - bodyAsText: string; - parsedBody: DataFeedIngestionProgress; - }; -}; - // @public export type GetAnomalyAlertConfigurationResponse = AnomalyAlertConfiguration & { _response: coreHttp.HttpResponse & { diff --git a/sdk/metricsadvisor/ai-metrics-advisor/src/metricsAdvisorAdministrationClient.ts b/sdk/metricsadvisor/ai-metrics-advisor/src/metricsAdvisorAdministrationClient.ts index f285da19e2a3..86caa3b8c6ef 100644 --- a/sdk/metricsadvisor/ai-metrics-advisor/src/metricsAdvisorAdministrationClient.ts +++ b/sdk/metricsadvisor/ai-metrics-advisor/src/metricsAdvisorAdministrationClient.ts @@ -42,7 +42,8 @@ import { AlertConfigurationsPageResponse, DetectionConfigurationsPageResponse, HooksPageResponse, - DataFeedStatus + DataFeedStatus, + GetIngestionProgressResponse } from "./models"; import { DataSourceType, NeedRollupEnum } from "./generated/models"; import { @@ -1339,16 +1340,20 @@ export class MetricsAdvisorAdministrationClient { top: options?.maxPageSize } ); - const resultArray = Object.defineProperty(segmentResponse.value?.map((s) => { - return { - timestamp: s.timestamp?.getTime(), - status: s.status, - message: s.message - }; - }) || [], "continuationToken", { - enumerable: true, - value: segmentResponse.nextLink - }); + const resultArray = Object.defineProperty( + segmentResponse.value?.map((s) => { + return { + timestamp: s.timestamp?.getTime(), + status: s.status, + message: s.message + }; + }) || [], + "continuationToken", + { + enumerable: true, + value: segmentResponse.nextLink + } + ); yield Object.defineProperty(resultArray, "_response", { enumerable: false, value: segmentResponse._response @@ -1369,16 +1374,20 @@ export class MetricsAdvisorAdministrationClient { options ); - const resultArray = Object.defineProperty(segmentResponse.value?.map((s) => { - return { - timestamp: s.timestamp?.getTime(), - status: s.status, - message: s.message - }; - }) || [], "continuationToken", { - enumerable: true, - value: segmentResponse.nextLink - }); + const resultArray = Object.defineProperty( + segmentResponse.value?.map((s) => { + return { + timestamp: s.timestamp?.getTime(), + status: s.status, + message: s.message + }; + }) || [], + "continuationToken", + { + enumerable: true, + value: segmentResponse.nextLink + } + ); yield Object.defineProperty(resultArray, "_response", { enumerable: false, value: segmentResponse._response diff --git a/sdk/metricsadvisor/ai-metrics-advisor/src/metricsAdvisorClient.ts b/sdk/metricsadvisor/ai-metrics-advisor/src/metricsAdvisorClient.ts index 01b446b9541f..77f7be5e60c5 100644 --- a/sdk/metricsadvisor/ai-metrics-advisor/src/metricsAdvisorClient.ts +++ b/sdk/metricsadvisor/ai-metrics-advisor/src/metricsAdvisorClient.ts @@ -2174,16 +2174,20 @@ export class MetricsAdvisorClient { ...options, top: maxPageSize }); - const resultArray = Object.defineProperty(segmentResponse.value?.map((s) => { - return { - timestamp: s.timestamp?.getTime(), - status: s.status, - message: s.message - }; - }) || [], "continuationToken", { - enumerable: true, - value: segmentResponse.nextLink - }); + const resultArray = Object.defineProperty( + segmentResponse.value?.map((s) => { + return { + timestamp: s.timestamp?.getTime(), + status: s.status, + message: s.message + }; + }) || [], + "continuationToken", + { + enumerable: true, + value: segmentResponse.nextLink + } + ); yield Object.defineProperty(resultArray, "_response", { enumerable: false, value: segmentResponse._response @@ -2199,16 +2203,20 @@ export class MetricsAdvisorClient { optionsBody, options ); - const resultArray = Object.defineProperty(segmentResponse.value?.map((s) => { - return { - timestamp: s.timestamp?.getTime(), - status: s.status, - message: s.message - }; - }) || [], "continuationToken", { - enumerable: true, - value: segmentResponse.nextLink - }); + const resultArray = Object.defineProperty( + segmentResponse.value?.map((s) => { + return { + timestamp: s.timestamp?.getTime(), + status: s.status, + message: s.message + }; + }) || [], + "continuationToken", + { + enumerable: true, + value: segmentResponse.nextLink + } + ); yield Object.defineProperty(resultArray, "_response", { enumerable: false, value: segmentResponse._response diff --git a/sdk/metricsadvisor/ai-metrics-advisor/src/models.ts b/sdk/metricsadvisor/ai-metrics-advisor/src/models.ts index 9f4d5ecf0f7c..379be2b1dc52 100644 --- a/sdk/metricsadvisor/ai-metrics-advisor/src/models.ts +++ b/sdk/metricsadvisor/ai-metrics-advisor/src/models.ts @@ -50,7 +50,6 @@ export { export { AnomalyValue, DataFeedIngestionProgress, - GeneratedClientGetIngestionProgressResponse, IngestionStatusType, DataSourceType, SeverityFilterCondition, @@ -1714,7 +1713,7 @@ export interface HooksPageResponse extends Array { */ parsedBody: any; }; -}; +} /** * Contains response data for the getDataFeedIngestionProgress operation. From 84aac0b26377c88f250f4cb45fe35d110792da89 Mon Sep 17 00:00:00 2001 From: Jeremy Meng Date: Tue, 3 Nov 2020 16:07:40 -0800 Subject: [PATCH 3/3] Update CHANGELOG --- sdk/metricsadvisor/ai-metrics-advisor/CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sdk/metricsadvisor/ai-metrics-advisor/CHANGELOG.md b/sdk/metricsadvisor/ai-metrics-advisor/CHANGELOG.md index 4582b19e46d7..f0d185a7a20b 100644 --- a/sdk/metricsadvisor/ai-metrics-advisor/CHANGELOG.md +++ b/sdk/metricsadvisor/ai-metrics-advisor/CHANGELOG.md @@ -21,6 +21,12 @@ - [Breaking] The `-List` suffix is removed from Array properties in `MetricSeriesData` and `MetricsEnrichedSeriesData`. Plural form is used instead. - [Breaking] `*PageResponse` types now extends from `Array` instead of wrapping an array of `ItemType`. Their types names are also shortened. - [Breaking] Data feed ingestion granularity now has `"PerMinute"` and `"PerSecond"` instead of `"Minutely"` and `"Secondly"`. +- [Breaking] Change the type of following timestamp properties from `Date` to `number` + - `AnomalyAlert.timestamp` + - `DataPointAnomaly.timestamp` + - `EnrichmentStatus.timestamp` + - `IngestionStatus.timestamp` + - `latestSuccessTimestamp` and `latestActiveTimestamp` in the return type of `getDataFeedIngestionProgress()`. - Parameters of `Date` type now also accept strings. No validation is done for the strings. The SDK calls `new Date()` to convert them to `Date`. ## 1.0.0-beta.1 (2020-10-07)