Skip to content

Commit

Permalink
[MetricsAdvisor] Implemented BoundaryMeasureType (#22297)
Browse files Browse the repository at this point in the history
  • Loading branch information
kinelski authored Jun 30, 2021
1 parent 22a5250 commit 9d3f7d3
Show file tree
Hide file tree
Showing 14 changed files with 872 additions and 661 deletions.
1 change: 1 addition & 0 deletions sdk/metricsadvisor/Azure.AI.MetricsAdvisor/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- `DimensionKey` now implements the `IEnumerable<KeyValuePair<string, string>>` interface. Dimension columns can now be enumerated.
- Added method `Contains` to `DimensionKey` to check whether or not a dimension column is present.
- Added a property setter to `MetricSeriesGroupDetectionCondition.SeriesGroupKey` and to `MetricSingleSeriesDetectionCondition.SeriesKey`.
- Added property `MeasureType` to `MetricBoundaryCondition` to control which measure should be used when checking boundaries for alert triggering. Current supported types are `Value` and `Mean`.

### Breaking Changes
- Removed methods `AddDimensionColumn` and `RemoveDimensionColumn` from `DimensionKey`. In order to access elements, the new method `TryGetValue` must be used. Once the instance has been created, the columns can't be modified anymore.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,24 @@ internal AnomalyIncident() { }
public override string ToString() { throw null; }
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public readonly partial struct BoundaryMeasureType : System.IEquatable<Azure.AI.MetricsAdvisor.Models.BoundaryMeasureType>
{
private readonly object _dummy;
private readonly int _dummyPrimitive;
public BoundaryMeasureType(string value) { throw null; }
public static Azure.AI.MetricsAdvisor.Models.BoundaryMeasureType Mean { get { throw null; } }
public static Azure.AI.MetricsAdvisor.Models.BoundaryMeasureType Value { get { throw null; } }
public bool Equals(Azure.AI.MetricsAdvisor.Models.BoundaryMeasureType other) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override bool Equals(object obj) { throw null; }
[System.ComponentModel.EditorBrowsableAttribute(System.ComponentModel.EditorBrowsableState.Never)]
public override int GetHashCode() { throw null; }
public static bool operator ==(Azure.AI.MetricsAdvisor.Models.BoundaryMeasureType left, Azure.AI.MetricsAdvisor.Models.BoundaryMeasureType right) { throw null; }
public static implicit operator Azure.AI.MetricsAdvisor.Models.BoundaryMeasureType (string value) { throw null; }
public static bool operator !=(Azure.AI.MetricsAdvisor.Models.BoundaryMeasureType left, Azure.AI.MetricsAdvisor.Models.BoundaryMeasureType right) { throw null; }
public override string ToString() { throw null; }
}
[System.Runtime.InteropServices.StructLayoutAttribute(System.Runtime.InteropServices.LayoutKind.Sequential)]
public readonly partial struct ChangePointValue : System.IEquatable<Azure.AI.MetricsAdvisor.Models.ChangePointValue>
{
private readonly object _dummy;
Expand Down Expand Up @@ -1124,6 +1142,7 @@ public MetricBoundaryCondition(Azure.AI.MetricsAdvisor.Models.BoundaryDirection
public string CompanionMetricId { get { throw null; } set { } }
public Azure.AI.MetricsAdvisor.Models.BoundaryDirection Direction { get { throw null; } set { } }
public double? LowerBound { get { throw null; } set { } }
public Azure.AI.MetricsAdvisor.Models.BoundaryMeasureType? MeasureType { get { throw null; } set { } }
public bool? ShouldAlertIfDataPointMissing { get { throw null; } set { } }
public double? UpperBound { get { throw null; } set { } }
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using Azure.Core;

namespace Azure.AI.MetricsAdvisor.Models
{
/// <summary>
/// Used as part of a <see cref="MetricBoundaryCondition"/>. Specifies which measure type should be
/// used when checking boundaries. Defaults to <see cref="BoundaryMeasureType.Value"/>.
/// </summary>
[CodeGenModel("ValueType")]
public readonly partial struct BoundaryMeasureType
{
/// <summary>
/// The value of the metric is used as it is.
/// </summary>
public static BoundaryMeasureType Value { get; } = new BoundaryMeasureType(ValueValue);

/// <summary>
/// The mean of the latest metric values in the time series is used.
/// </summary>
public static BoundaryMeasureType Mean { get; } = new BoundaryMeasureType(MeanValue);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ public MetricBoundaryCondition(BoundaryDirection direction)
[CodeGenMember("TriggerForMissing")]
public bool? ShouldAlertIfDataPointMissing { get; set; }

// TODO: expose it as part of 1.0.0-beta.4
internal ValueType? Type { get; set; }
/// <summary>
/// Specifies which measure type should be used when checking boundaries. Defaults to
/// <see cref="BoundaryMeasureType.Value"/>.
/// </summary>
[CodeGenMember("Type")]
public BoundaryMeasureType? MeasureType { get; set; }
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ public async Task CreateAndGetAlertConfigurationWithOptionalSingleMetricConfigur
UpperBound = 20.0,
LowerBound = 10.0,
CompanionMetricId = metricId,
ShouldAlertIfDataPointMissing = true
ShouldAlertIfDataPointMissing = true,
MeasureType = BoundaryMeasureType.Mean
},
SeverityCondition = new SeverityCondition(AnomalySeverity.Low, AnomalySeverity.Medium)
}
Expand Down Expand Up @@ -251,6 +252,7 @@ public async Task CreateAndGetAlertConfigurationWithOptionalSingleMetricConfigur
Assert.That(createdMetricAlertConfig.AlertConditions.MetricBoundaryCondition.LowerBound, Is.EqualTo(10.0));
Assert.That(createdMetricAlertConfig.AlertConditions.MetricBoundaryCondition.CompanionMetricId, Is.EqualTo(metricId));
Assert.That(createdMetricAlertConfig.AlertConditions.MetricBoundaryCondition.ShouldAlertIfDataPointMissing, Is.True);
Assert.That(createdMetricAlertConfig.AlertConditions.MetricBoundaryCondition.MeasureType, Is.EqualTo(BoundaryMeasureType.Mean));
Assert.That(createdMetricAlertConfig.AlertConditions.SeverityCondition, Is.Not.Null);
Assert.That(createdMetricAlertConfig.AlertConditions.SeverityCondition.MinimumAlertSeverity, Is.EqualTo(AnomalySeverity.Low));
Assert.That(createdMetricAlertConfig.AlertConditions.SeverityCondition.MaximumAlertSeverity, Is.EqualTo(AnomalySeverity.Medium));
Expand Down Expand Up @@ -334,6 +336,7 @@ public async Task CreateAndGetAlertConfigurationWithMultipleMetricConfigurations
Assert.That(createdMetricAlertConfig0.AlertConditions.MetricBoundaryCondition.LowerBound, Is.Null);
Assert.That(createdMetricAlertConfig0.AlertConditions.MetricBoundaryCondition.CompanionMetricId, Is.Null);
Assert.That(createdMetricAlertConfig0.AlertConditions.MetricBoundaryCondition.ShouldAlertIfDataPointMissing, Is.False);
Assert.That(createdMetricAlertConfig0.AlertConditions.MetricBoundaryCondition.MeasureType, Is.EqualTo(BoundaryMeasureType.Value));
Assert.That(createdMetricAlertConfig0.AlertConditions.SeverityCondition, Is.Null);

Assert.That(createdMetricAlertConfig0.AlertSnoozeCondition, Is.Null);
Expand All @@ -357,6 +360,7 @@ public async Task CreateAndGetAlertConfigurationWithMultipleMetricConfigurations
Assert.That(createdMetricAlertConfig1.AlertConditions.MetricBoundaryCondition.LowerBound, Is.EqualTo(10.0));
Assert.That(createdMetricAlertConfig1.AlertConditions.MetricBoundaryCondition.CompanionMetricId, Is.Null);
Assert.That(createdMetricAlertConfig1.AlertConditions.MetricBoundaryCondition.ShouldAlertIfDataPointMissing, Is.False);
Assert.That(createdMetricAlertConfig1.AlertConditions.MetricBoundaryCondition.MeasureType, Is.EqualTo(BoundaryMeasureType.Value));
Assert.That(createdMetricAlertConfig1.AlertConditions.SeverityCondition, Is.Null);

Assert.That(createdMetricAlertConfig1.AlertSnoozeCondition, Is.Null);
Expand Down Expand Up @@ -453,6 +457,7 @@ public async Task UpdateAlertConfigurationWithMinimumSetup(bool useTokenCrendent
Assert.That(updatedMetricAlertConfig0.AlertConditions.MetricBoundaryCondition.LowerBound, Is.EqualTo(10.0));
Assert.That(updatedMetricAlertConfig0.AlertConditions.MetricBoundaryCondition.CompanionMetricId, Is.EqualTo(metricId));
Assert.That(updatedMetricAlertConfig0.AlertConditions.MetricBoundaryCondition.ShouldAlertIfDataPointMissing, Is.True);
Assert.That(updatedMetricAlertConfig0.AlertConditions.MetricBoundaryCondition.MeasureType, Is.EqualTo(BoundaryMeasureType.Value));
Assert.That(updatedMetricAlertConfig0.AlertConditions.SeverityCondition, Is.Not.Null);
Assert.That(updatedMetricAlertConfig0.AlertConditions.SeverityCondition.MinimumAlertSeverity, Is.EqualTo(AnomalySeverity.Low));
Assert.That(updatedMetricAlertConfig0.AlertConditions.SeverityCondition.MaximumAlertSeverity, Is.EqualTo(AnomalySeverity.Medium));
Expand Down Expand Up @@ -559,6 +564,7 @@ public async Task UpdateAlertConfigurationWithEveryMember()
metricAlertConfigToUpdate.AlertConditions.MetricBoundaryCondition.LowerBound = 5.0;
metricAlertConfigToUpdate.AlertConditions.MetricBoundaryCondition.CompanionMetricId = null;
metricAlertConfigToUpdate.AlertConditions.MetricBoundaryCondition.ShouldAlertIfDataPointMissing = false;
metricAlertConfigToUpdate.AlertConditions.MetricBoundaryCondition.MeasureType = BoundaryMeasureType.Mean;

metricAlertConfigToUpdate.AlertConditions.SeverityCondition = new SeverityCondition(AnomalySeverity.Medium, AnomalySeverity.High);

Expand Down Expand Up @@ -593,6 +599,7 @@ public async Task UpdateAlertConfigurationWithEveryMember()
Assert.That(updatedMetricAlertConfig0.AlertConditions.MetricBoundaryCondition.LowerBound, Is.EqualTo(5.0));
Assert.That(updatedMetricAlertConfig0.AlertConditions.MetricBoundaryCondition.CompanionMetricId, Is.Null);
Assert.That(updatedMetricAlertConfig0.AlertConditions.MetricBoundaryCondition.ShouldAlertIfDataPointMissing, Is.False);
Assert.That(updatedMetricAlertConfig0.AlertConditions.MetricBoundaryCondition.MeasureType, Is.EqualTo(BoundaryMeasureType.Mean));
Assert.That(updatedMetricAlertConfig0.AlertConditions.SeverityCondition, Is.Not.Null);
Assert.That(updatedMetricAlertConfig0.AlertConditions.SeverityCondition.MinimumAlertSeverity, Is.EqualTo(AnomalySeverity.Medium));
Assert.That(updatedMetricAlertConfig0.AlertConditions.SeverityCondition.MaximumAlertSeverity, Is.EqualTo(AnomalySeverity.High));
Expand Down
Loading

0 comments on commit 9d3f7d3

Please sign in to comment.