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] Updated DimensionKey implementation #21972

Merged
merged 3 commits into from
Jun 24, 2021

Conversation

kinelski
Copy link
Member

@kinelski kinelski commented Jun 18, 2021

Changing most of the DimensionKey implementation after architect feedback:

  • Not an IEquatable anymore. We don't have a strong user scenario in which we think this will be helpful, so removing it for the time being.
  • In case we decide to revert the change above in the future, we're making the type immutable. For this reason, it takes a constructor parameter now, and its Add and Remove methods have been removed.
  • It's an IEnumerable now, so users can enumerate dimension columns.
  • Added Contains and TryGetValue methods so users can check the contents of the instance without the use of the AsDictionary method.

Also, added tests for DimensionKey, updated other tests and some samples.

@kinelski kinelski added the Client This issue points to a problem in the data-plane of the library. label Jun 18, 2021
@kinelski kinelski self-assigned this Jun 18, 2021
@kinelski kinelski force-pushed the ma-dimensionKey branch 2 times, most recently from 2d7ce31 to 618fffd Compare June 22, 2021 22:27
@kinelski kinelski requested a review from maririos June 22, 2021 22:47
@kinelski kinelski marked this pull request as ready for review June 22, 2021 22:47
public MetricSeriesGroupDetectionCondition()
/// <param name="seriesGroupKey">The key that identifies the group of time series to which these conditions apply within a metric. A subset of the possible dimensions of the associated data feed must be set.</param>
/// <exception cref="ArgumentNullException"><paramref name="seriesGroupKey"/> is <c>null</c>.</exception>
public MetricSeriesGroupDetectionCondition(DimensionKey seriesGroupKey)
Copy link
Member

Choose a reason for hiding this comment

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

nit: do you have tests to check that we correctly assert when null?
Same for MetricSingleSeriesDetectionCondition

Copy link
Member Author

Choose a reason for hiding this comment

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

We don't, but I think it's common to not add constructor assertion tests to every single model, right? We don't do it in FR either. Let me know if you think otherwise.

@@ -2,14 +2,24 @@

## 1.0.0-beta.5 (Unreleased)

### New Features
- `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.
Copy link
Member

Choose a reason for hiding this comment

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

Do you think it is worth showing this in any sample? or the use of the TryGetValue? The names and docstrings are clear enough that I don't think it is needed, but asking just in case

Copy link
Member Author

Choose a reason for hiding this comment

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

To tell you the truth, I don't think these methods will be used that much. In general, customers will need to go through every element anyway, so they'll use the enumerator (kudos to KC who suggested making it an IEnumerable). I added these methods just in case someone wants to check a specific element without going through the whole set.

@kinelski kinelski merged commit 9bbe331 into Azure:main Jun 24, 2021
@kinelski kinelski deleted the ma-dimensionKey branch June 24, 2021 18:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Client This issue points to a problem in the data-plane of the library. Cognitive - Metrics Advisor
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants