From 0f59ea852352dcb048c7e0ead81daaac54c06c0f Mon Sep 17 00:00:00 2001 From: Tom Kerkhove Date: Wed, 3 Mar 2021 21:28:42 +0100 Subject: [PATCH] fix: Exception thrown when metric is not found (#1546) * fix: Exception thrown when metric is not found Signed-off-by: Tom Kerkhove * Revert Signed-off-by: Tom Kerkhove * Update changelog Signed-off-by: Tom Kerkhove * Align expectation with Azure subscription Signed-off-by: Tom Kerkhove --- changelog/content/released/v2.1.1-scraper.md | 10 ++++++++++ .../AzureMonitorClient.cs | 2 +- .../ResourceDiscovery/ResourceDiscoveryTests.cs | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) create mode 100644 changelog/content/released/v2.1.1-scraper.md diff --git a/changelog/content/released/v2.1.1-scraper.md b/changelog/content/released/v2.1.1-scraper.md new file mode 100644 index 000000000..43eee2871 --- /dev/null +++ b/changelog/content/released/v2.1.1-scraper.md @@ -0,0 +1,10 @@ +--- +subtitle: "released on 2021-03-03" +date: 2021-03-03T10:38:47+02:00 +weight: 211-scraper +version: Scraper - v2.1.1 +--- + +- {{% tag fixed %}} Issue when metric (values) where not found causing exceptions to be thrown ([#1545](https://github.com/tomkerkhove/promitor/issues/1545)) + +Full release notes can be found [here](https://github.com/tomkerkhove/promitor/releases/tag/2.1.1-scraper). diff --git a/src/Promitor.Integrations.AzureMonitor/AzureMonitorClient.cs b/src/Promitor.Integrations.AzureMonitor/AzureMonitorClient.cs index 3d9d5db98..9141211ef 100644 --- a/src/Promitor.Integrations.AzureMonitor/AzureMonitorClient.cs +++ b/src/Promitor.Integrations.AzureMonitor/AzureMonitorClient.cs @@ -82,7 +82,7 @@ public async Task> QueryMetricAsync(string metricName, stri var relevantMetric = await GetRelevantMetric(metricName, aggregationType, closestAggregationInterval, metricFilter, metricDimension, metricDefinition, startQueryingTime); if (relevantMetric.Timeseries.Count < 1) { - throw new MetricInformationNotFoundException(metricName,metricDimension, "No time series was found"); + throw new MetricInformationNotFoundException(metricName,"No time series was found", metricDimension); } var measuredMetrics = new List(); diff --git a/src/Promitor.Tests.Integration/Services/ResourceDiscovery/ResourceDiscoveryTests.cs b/src/Promitor.Tests.Integration/Services/ResourceDiscovery/ResourceDiscoveryTests.cs index 618d0d8bf..433c5843f 100644 --- a/src/Promitor.Tests.Integration/Services/ResourceDiscovery/ResourceDiscoveryTests.cs +++ b/src/Promitor.Tests.Integration/Services/ResourceDiscovery/ResourceDiscoveryTests.cs @@ -138,7 +138,7 @@ public async Task ResourceDiscovery_GetWithFilterOnOneSubscription_ReturnsExpect { // Arrange const string resourceDiscoveryGroupName = "one-subscriptions-scenario"; - const int expectedResourceCount = 2; + const int expectedResourceCount = 1; var resourceDiscoveryClient = new ResourceDiscoveryClient(Configuration, Logger); // Act