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

[MetricsAdvisor] change timestamps type from Date to number #12162

Merged
merged 3 commits into from
Nov 4, 2020
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
6 changes: 6 additions & 0 deletions sdk/metricsadvisor/ai-metrics-advisor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<ItemType>` 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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export interface AnomalyAlert {
createdOn?: Date;
id: string;
modifiedOn?: Date;
timestamp?: Date;
timestamp?: number;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this decision meant for all the packages?
(Asking for service-bus, I was hoping I'd change a "number" to "Date", but that doesn't seem like it?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bterlson suggested that a timestamp should be a number or string

}

// @public
Expand Down Expand Up @@ -335,7 +335,7 @@ export interface DataPointAnomaly {
seriesKey: DimensionKey;
severity: AnomalySeverity;
status?: AnomalyStatus;
timestamp: Date;
timestamp: number;
}

// @public
Expand Down Expand Up @@ -407,7 +407,7 @@ export type EmailNotificationHookPatch = {
export interface EnrichmentStatus {
readonly message?: string;
readonly status?: string;
readonly timestamp?: Date;
readonly timestamp?: number;
}

// @public
Expand All @@ -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 & {
Expand Down Expand Up @@ -473,6 +465,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;

Expand Down Expand Up @@ -571,7 +574,7 @@ export interface InfluxDBParameter {
export interface IngestionStatus {
readonly message?: string;
readonly status?: IngestionStatusType;
readonly timestamp?: Date;
readonly timestamp?: number;
}

// @public
Expand Down Expand Up @@ -810,7 +813,7 @@ export class MetricsAdvisorAdministrationClient {
readonly endpointUrl: string;
getAnomalyAlertConfiguration(id: string, options?: OperationOptions): Promise<GetAnomalyAlertConfigurationResponse>;
getDataFeed(id: string, options?: OperationOptions): Promise<GetDataFeedResponse>;
getDataFeedIngestionProgress(dataFeedId: string, options?: {}): Promise<GeneratedClientGetIngestionProgressResponse>;
getDataFeedIngestionProgress(dataFeedId: string, options?: {}): Promise<GetIngestionProgressResponse>;
getHook(id: string, options?: OperationOptions): Promise<GetHookResponse>;
getMetricAnomalyDetectionConfiguration(id: string, options?: OperationOptions): Promise<GetAnomalyDetectionConfigurationResponse>;
listAnomalyAlertConfigurations(detectionConfigId: string, options?: OperationOptions): PagedAsyncIterableIterator<AnomalyAlertConfiguration, AlertConfigurationsPageResponse, undefined>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,10 @@ import {
AlertConfigurationsPageResponse,
DetectionConfigurationsPageResponse,
HooksPageResponse,
DataFeedStatus
DataFeedStatus,
GetIngestionProgressResponse
} from "./models";
import {
DataSourceType,
GeneratedClientGetIngestionProgressResponse,
NeedRollupEnum
} from "./generated/models";
import { DataSourceType, NeedRollupEnum } from "./generated/models";
import {
fromServiceAnomalyDetectionConfiguration,
fromServiceDataFeedDetailUnion,
Expand Down Expand Up @@ -1295,15 +1292,20 @@ export class MetricsAdvisorAdministrationClient {
public async getDataFeedIngestionProgress(
dataFeedId: string,
options = {}
): Promise<GeneratedClientGetIngestionProgressResponse> {
): Promise<GetIngestionProgressResponse> {
const { span, updatedOptions: finalOptions } = createSpan(
"MetricsAdvisorAdministrationClient-getDataFeedIngestionProgress",
options
);

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,
Expand Down Expand Up @@ -1338,10 +1340,20 @@ export class MetricsAdvisorAdministrationClient {
top: options?.maxPageSize
}
);
const resultArray = Object.defineProperty(segmentResponse.value || [], "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
Expand All @@ -1362,10 +1374,20 @@ export class MetricsAdvisorAdministrationClient {
options
);

const resultArray = Object.defineProperty(segmentResponse.value || [], "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
Expand Down
58 changes: 36 additions & 22 deletions sdk/metricsadvisor/ai-metrics-advisor/src/metricsAdvisorClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -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", {
Expand Down Expand Up @@ -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", {
Expand Down Expand Up @@ -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", {
Expand Down Expand Up @@ -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", {
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -2180,10 +2174,20 @@ export class MetricsAdvisorClient {
...options,
top: maxPageSize
});
const resultArray = Object.defineProperty(segmentResponse.value || [], "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
Expand All @@ -2199,10 +2203,20 @@ export class MetricsAdvisorClient {
optionsBody,
options
);
const resultArray = Object.defineProperty(segmentResponse.value || [], "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
Expand Down
Loading