Skip to content

Commit

Permalink
[MetricsAdvisor] Minor API changes (#21949)
Browse files Browse the repository at this point in the history
  • Loading branch information
kinelski authored Jun 18, 2021
1 parent 6c2d700 commit 60a3daf
Show file tree
Hide file tree
Showing 8 changed files with 52 additions and 38 deletions.
2 changes: 2 additions & 0 deletions sdk/metricsadvisor/Azure.AI.MetricsAdvisor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@
- `DataFeedMissingDataPointFillSettings` constructor now takes the required `fillType` parameter. For this reason, the property `FillType` is not nullable anymore.
- `EmailNotificationHook` constructor now takes the required `name` parameter.
- `WebNotificationHook` constructor now takes the required `name` and `endpoint` parameters.
- In `MetricSeriesData`, removed the `Definition` property. Now, properties `MetricId` and `SeriesKey` can be accessed directly from `MetricSeriesData`.
- In `DataPointAnomaly`, renamed property `AnomalyDetectionConfigurationId` to `DetectionConfigurationId`.
- In `DataFeedMetric`, renamed constructor parameter `metricName` to `name` only.
- In `DataFeedDimension`, renamed constructor parameter `dimensionName` to `name` only.
- Moved `GetAlertConfigurationsOptions`, `GetDatasourceCredentialsOptions`, and `GetDetectionConfigurationsOptions` to the `Azure.AI.MetricsAdvisor.Administration` namespace.
- Moved `DatasourceCredential`, `DataFeedSource`, `NotificationHook`, and all of their concrete child types to the `Azure.AI.MetricsAdvisor.Administration` namespace.
- Moved `MetricFeedback` and all of its concrete child types to the `Azure.AI.MetricsAdvisor` namespace.
- Changed order of parameters of `MetricsAdvisorClient.GetMetricEnrichedSeriesData`. Now, `detectionConfigurationId` appears first.

## 1.0.0-beta.4 (2021-06-07)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,8 +203,8 @@ public MetricsAdvisorClient(System.Uri endpoint, Azure.Core.TokenCredential cred
public virtual Azure.AsyncPageable<Azure.AI.MetricsAdvisor.Models.AnomalyIncident> GetIncidentsAsync(string alertConfigurationId, string alertId, Azure.AI.MetricsAdvisor.GetIncidentsForAlertOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Pageable<string> GetMetricDimensionValues(string metricId, string dimensionName, Azure.AI.MetricsAdvisor.GetMetricDimensionValuesOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.AsyncPageable<string> GetMetricDimensionValuesAsync(string metricId, string dimensionName, Azure.AI.MetricsAdvisor.GetMetricDimensionValuesOptions options = null, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Pageable<Azure.AI.MetricsAdvisor.Models.MetricEnrichedSeriesData> GetMetricEnrichedSeriesData(System.Collections.Generic.IEnumerable<Azure.AI.MetricsAdvisor.Models.DimensionKey> seriesKeys, string detectionConfigurationId, System.DateTimeOffset startTime, System.DateTimeOffset endTime, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.AsyncPageable<Azure.AI.MetricsAdvisor.Models.MetricEnrichedSeriesData> GetMetricEnrichedSeriesDataAsync(System.Collections.Generic.IEnumerable<Azure.AI.MetricsAdvisor.Models.DimensionKey> seriesKeys, string detectionConfigurationId, System.DateTimeOffset startTime, System.DateTimeOffset endTime, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Pageable<Azure.AI.MetricsAdvisor.Models.MetricEnrichedSeriesData> GetMetricEnrichedSeriesData(string detectionConfigurationId, System.Collections.Generic.IEnumerable<Azure.AI.MetricsAdvisor.Models.DimensionKey> seriesKeys, System.DateTimeOffset startTime, System.DateTimeOffset endTime, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.AsyncPageable<Azure.AI.MetricsAdvisor.Models.MetricEnrichedSeriesData> GetMetricEnrichedSeriesDataAsync(string detectionConfigurationId, System.Collections.Generic.IEnumerable<Azure.AI.MetricsAdvisor.Models.DimensionKey> seriesKeys, System.DateTimeOffset startTime, System.DateTimeOffset endTime, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Pageable<Azure.AI.MetricsAdvisor.Models.EnrichmentStatus> GetMetricEnrichmentStatuses(string metricId, Azure.AI.MetricsAdvisor.GetMetricEnrichmentStatusesOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.AsyncPageable<Azure.AI.MetricsAdvisor.Models.EnrichmentStatus> GetMetricEnrichmentStatusesAsync(string metricId, Azure.AI.MetricsAdvisor.GetMetricEnrichmentStatusesOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
public virtual Azure.Pageable<Azure.AI.MetricsAdvisor.Models.MetricSeriesData> GetMetricSeriesData(string metricId, Azure.AI.MetricsAdvisor.GetMetricSeriesDataOptions options, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) { throw null; }
Expand Down Expand Up @@ -1169,8 +1169,9 @@ internal MetricEnrichedSeriesData() { }
public partial class MetricSeriesData
{
internal MetricSeriesData() { }
public Azure.AI.MetricsAdvisor.Models.MetricSeriesDefinition Definition { get { throw null; } }
public string MetricId { get { throw null; } }
public System.Collections.Generic.IReadOnlyList<double> MetricValues { get { throw null; } }
public Azure.AI.MetricsAdvisor.Models.DimensionKey SeriesKey { get { throw null; } }
public System.Collections.Generic.IReadOnlyList<System.DateTimeOffset> Timestamps { get { throw null; } }
}
public partial class MetricSeriesDefinition
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1309,18 +1309,18 @@ Page<string> NextPageFunc(string nextLink, int? pageSizeHint)
/// <summary>
/// Query series enriched by anomaly detection.
/// </summary>
/// <param name="seriesKeys">The detection series keys.</param>
/// <param name="detectionConfigurationId">The unique identifier of the <see cref="MetricAnomalyAlertConfiguration"/>.</param>
/// <param name="seriesKeys">The detection series keys.</param>
/// <param name="startTime">Filters the result. Only data points after this point in time, in UTC, will be returned.</param>
/// <param name="endTime">Filters the result. Only data points after this point in time, in UTC, will be returned.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
/// <returns>An <see cref="AsyncPageable{T}"/> containing the collection of <see cref="MetricEnrichedSeriesData"/>s.</returns>
/// <exception cref="ArgumentNullException"><paramref name="seriesKeys"/> or <paramref name="detectionConfigurationId"/> is null.</exception>
/// <exception cref="ArgumentException"><paramref name="seriesKeys"/> or <paramref name="detectionConfigurationId"/> is empty; or <paramref name="detectionConfigurationId"/> is not a valid GUID.</exception>
public virtual AsyncPageable<MetricEnrichedSeriesData> GetMetricEnrichedSeriesDataAsync(IEnumerable<DimensionKey> seriesKeys, string detectionConfigurationId, DateTimeOffset startTime, DateTimeOffset endTime, CancellationToken cancellationToken = default)
/// <exception cref="ArgumentNullException"><paramref name="detectionConfigurationId"/> or <paramref name="seriesKeys"/> is null.</exception>
/// <exception cref="ArgumentException"><paramref name="detectionConfigurationId"/> or <paramref name="seriesKeys"/> is empty; or <paramref name="detectionConfigurationId"/> is not a valid GUID.</exception>
public virtual AsyncPageable<MetricEnrichedSeriesData> GetMetricEnrichedSeriesDataAsync(string detectionConfigurationId, IEnumerable<DimensionKey> seriesKeys, DateTimeOffset startTime, DateTimeOffset endTime, CancellationToken cancellationToken = default)
{
Argument.AssertNotNullOrEmpty(seriesKeys, nameof(seriesKeys)); // TODO: add validation for seriesKeys.Dimension?
Argument.AssertNotNullOrEmpty(detectionConfigurationId, nameof(detectionConfigurationId));
Argument.AssertNotNullOrEmpty(seriesKeys, nameof(seriesKeys)); // TODO: add validation for seriesKeys.Dimension?

Guid detectionConfigurationGuid = ClientCommon.ValidateGuid(detectionConfigurationId, nameof(detectionConfigurationId));
IEnumerable<SeriesIdentity> seriesIdentities = seriesKeys.Select(key => key.ConvertToSeriesIdentity());
Expand Down Expand Up @@ -1349,18 +1349,18 @@ async Task<Page<MetricEnrichedSeriesData>> FirstPageFunc(int? pageSizeHint)
/// <summary>
/// Query series enriched by anomaly detection.
/// </summary>
/// <param name="seriesKeys">The detection series keys.</param>
/// <param name="detectionConfigurationId">The unique identifier of the <see cref="MetricAnomalyAlertConfiguration"/>.</param>
/// <param name="seriesKeys">The detection series keys.</param>
/// <param name="startTime">Filters the result. Only data points after this point in time, in UTC, will be returned.</param>
/// <param name="endTime">Filters the result. Only data points after this point in time, in UTC, will be returned.</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/> controlling the request lifetime.</param>
/// <returns>A <see cref="Pageable{T}"/> containing the collection of <see cref="MetricEnrichedSeriesData"/>s.</returns>
/// <exception cref="ArgumentNullException"><paramref name="seriesKeys"/> or <paramref name="detectionConfigurationId"/> is null.</exception>
/// <exception cref="ArgumentException"><paramref name="seriesKeys"/> or <paramref name="detectionConfigurationId"/> is empty; or <paramref name="detectionConfigurationId"/> is not a valid GUID.</exception>
public virtual Pageable<MetricEnrichedSeriesData> GetMetricEnrichedSeriesData(IEnumerable<DimensionKey> seriesKeys, string detectionConfigurationId, DateTimeOffset startTime, DateTimeOffset endTime, CancellationToken cancellationToken = default)
/// <returns>An <see cref="Pageable{T}"/> containing the collection of <see cref="MetricEnrichedSeriesData"/>s.</returns>
/// <exception cref="ArgumentNullException"><paramref name="detectionConfigurationId"/> or <paramref name="seriesKeys"/> is null.</exception>
/// <exception cref="ArgumentException"><paramref name="detectionConfigurationId"/> or <paramref name="seriesKeys"/> is empty; or <paramref name="detectionConfigurationId"/> is not a valid GUID.</exception>
public virtual Pageable<MetricEnrichedSeriesData> GetMetricEnrichedSeriesData(string detectionConfigurationId, IEnumerable<DimensionKey> seriesKeys, DateTimeOffset startTime, DateTimeOffset endTime, CancellationToken cancellationToken = default)
{
Argument.AssertNotNullOrEmpty(seriesKeys, nameof(seriesKeys)); // TODO: add validation for seriesKeys.Dimension?
Argument.AssertNotNullOrEmpty(detectionConfigurationId, nameof(detectionConfigurationId));
Argument.AssertNotNullOrEmpty(seriesKeys, nameof(seriesKeys)); // TODO: add validation for seriesKeys.Dimension?

Guid detectionConfigurationGuid = ClientCommon.ValidateGuid(detectionConfigurationId, nameof(detectionConfigurationId));
IEnumerable<SeriesIdentity> seriesIdentities = seriesKeys.Select(key => key.ConvertToSeriesIdentity());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,16 @@ namespace Azure.AI.MetricsAdvisor.Models
public partial class MetricSeriesData
{
/// <summary>
/// Uniquely defines a time series within a <see cref="DataFeed"/>.
/// The unique identifier of the <see cref="DataFeedMetric"/> associated with this
/// time series.
/// </summary>
[CodeGenMember("Id")]
public MetricSeriesDefinition Definition { get; }
public string MetricId => Definition.MetricId;

/// <summary>
/// The key that, within a metric, uniquely identifies a time series. Every dimension
/// contained in the associated <see cref="DataFeed"/> has been assigned a value.
/// </summary>
public DimensionKey SeriesKey => Definition.SeriesKey;

/// <summary>
/// The timestamps, in UTC, of the data points present in this time series.
Expand All @@ -32,5 +38,11 @@ public partial class MetricSeriesData
/// </summary>
[CodeGenMember("ValueList")]
public IReadOnlyList<double> MetricValues { get; }

/// <summary>
/// Uniquely defines a time series within a <see cref="DataFeed"/>.
/// </summary>
[CodeGenMember("Id")]
internal MetricSeriesDefinition Definition { get; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ public async Task GetMetricEnrichedSeriesData(bool useTokenCredential)
var seriesKeys = new List<DimensionKey>() { seriesKey1, seriesKey2 };
var returnedKeys = new List<DimensionKey>();

await foreach (MetricEnrichedSeriesData seriesData in client.GetMetricEnrichedSeriesDataAsync(seriesKeys, DetectionConfigurationId, SamplingStartTime, SamplingEndTime))
await foreach (MetricEnrichedSeriesData seriesData in client.GetMetricEnrichedSeriesDataAsync(DetectionConfigurationId, seriesKeys, SamplingStartTime, SamplingEndTime))
{
Assert.That(seriesData, Is.Not.Null);
Assert.That(seriesData.SeriesKey, Is.Not.Null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -200,17 +200,17 @@ public void GetMetricEnrichedSeriesDataValidatesArguments()
var emptyList = new List<DimensionKey>();
var seriesKeys = new List<DimensionKey>() { new DimensionKey() };

Assert.That(() => client.GetMetricEnrichedSeriesDataAsync(null, FakeGuid, default, default), Throws.InstanceOf<ArgumentNullException>());
Assert.That(() => client.GetMetricEnrichedSeriesDataAsync(emptyList, FakeGuid, default, default), Throws.InstanceOf<ArgumentException>());
Assert.That(() => client.GetMetricEnrichedSeriesDataAsync(seriesKeys, null, default, default), Throws.InstanceOf<ArgumentNullException>());
Assert.That(() => client.GetMetricEnrichedSeriesDataAsync(seriesKeys, "", default, default), Throws.InstanceOf<ArgumentException>());
Assert.That(() => client.GetMetricEnrichedSeriesDataAsync(seriesKeys, "configId", default, default), Throws.InstanceOf<ArgumentException>().With.InnerException.TypeOf(typeof(FormatException)));

Assert.That(() => client.GetMetricEnrichedSeriesData(null, FakeGuid, default, default), Throws.InstanceOf<ArgumentNullException>());
Assert.That(() => client.GetMetricEnrichedSeriesData(emptyList, FakeGuid, default, default), Throws.InstanceOf<ArgumentException>());
Assert.That(() => client.GetMetricEnrichedSeriesData(seriesKeys, null, default, default), Throws.InstanceOf<ArgumentNullException>());
Assert.That(() => client.GetMetricEnrichedSeriesData(seriesKeys, "", default, default), Throws.InstanceOf<ArgumentException>());
Assert.That(() => client.GetMetricEnrichedSeriesData(seriesKeys, "configId", default, default), Throws.InstanceOf<ArgumentException>().With.InnerException.TypeOf(typeof(FormatException)));
Assert.That(() => client.GetMetricEnrichedSeriesDataAsync(FakeGuid, null, default, default), Throws.InstanceOf<ArgumentNullException>());
Assert.That(() => client.GetMetricEnrichedSeriesDataAsync(FakeGuid, emptyList, default, default), Throws.InstanceOf<ArgumentException>());
Assert.That(() => client.GetMetricEnrichedSeriesDataAsync(null, seriesKeys, default, default), Throws.InstanceOf<ArgumentNullException>());
Assert.That(() => client.GetMetricEnrichedSeriesDataAsync("", seriesKeys, default, default), Throws.InstanceOf<ArgumentException>());
Assert.That(() => client.GetMetricEnrichedSeriesDataAsync("configId", seriesKeys, default, default), Throws.InstanceOf<ArgumentException>().With.InnerException.TypeOf(typeof(FormatException)));

Assert.That(() => client.GetMetricEnrichedSeriesData(FakeGuid, null, default, default), Throws.InstanceOf<ArgumentNullException>());
Assert.That(() => client.GetMetricEnrichedSeriesData(FakeGuid, emptyList, default, default), Throws.InstanceOf<ArgumentException>());
Assert.That(() => client.GetMetricEnrichedSeriesData(null, seriesKeys, default, default), Throws.InstanceOf<ArgumentNullException>());
Assert.That(() => client.GetMetricEnrichedSeriesData("", seriesKeys, default, default), Throws.InstanceOf<ArgumentException>());
Assert.That(() => client.GetMetricEnrichedSeriesData("configId", seriesKeys, default, default), Throws.InstanceOf<ArgumentException>().With.InnerException.TypeOf(typeof(FormatException)));
}

[Test]
Expand All @@ -224,10 +224,10 @@ public void GetMetricEnrichedSeriesDataRespectsTheCancellationToken()
using var cancellationSource = new CancellationTokenSource();
cancellationSource.Cancel();

IAsyncEnumerator<MetricEnrichedSeriesData> asyncEnumerator = client.GetMetricEnrichedSeriesDataAsync(seriesKeys, FakeGuid, default, default, cancellationSource.Token).GetAsyncEnumerator();
IAsyncEnumerator<MetricEnrichedSeriesData> asyncEnumerator = client.GetMetricEnrichedSeriesDataAsync(FakeGuid, seriesKeys, default, default, cancellationSource.Token).GetAsyncEnumerator();
Assert.That(async () => await asyncEnumerator.MoveNextAsync(), Throws.InstanceOf<OperationCanceledException>());

IEnumerator<MetricEnrichedSeriesData> enumerator = client.GetMetricEnrichedSeriesData(seriesKeys, FakeGuid, default, default, cancellationSource.Token).GetEnumerator();
IEnumerator<MetricEnrichedSeriesData> enumerator = client.GetMetricEnrichedSeriesData(FakeGuid, seriesKeys, default, default, cancellationSource.Token).GetEnumerator();
Assert.That(() => enumerator.MoveNext(), Throws.InstanceOf<OperationCanceledException>());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,11 @@ public async Task GetMetricSeriesData(bool useTokenCredential)
await foreach (MetricSeriesData seriesData in client.GetMetricSeriesDataAsync(MetricId, options))
{
Assert.That(seriesData, Is.Not.Null);
Assert.That(seriesData.Definition, Is.Not.Null);
Assert.That(seriesData.Definition.SeriesKey, Is.Not.Null);
Assert.That(seriesData.SeriesKey, Is.Not.Null);
Assert.That(seriesData.Timestamps, Is.Not.Null);
Assert.That(seriesData.MetricValues, Is.Not.Null);

Assert.That(seriesData.Definition.MetricId, Is.EqualTo(MetricId));
Assert.That(seriesData.MetricId, Is.EqualTo(MetricId));

Assert.That(seriesData.Timestamps.Count, Is.EqualTo(seriesData.MetricValues.Count));

Expand All @@ -174,7 +173,7 @@ public async Task GetMetricSeriesData(bool useTokenCredential)
Assert.That(timestamp, Is.InRange(SamplingStartTime, SamplingEndTime));
}

returnedKeys.Add(seriesData.Definition.SeriesKey);
returnedKeys.Add(seriesData.SeriesKey);
}

Assert.That(returnedKeys.Count, Is.EqualTo(2));
Expand Down
Loading

0 comments on commit 60a3daf

Please sign in to comment.