Skip to content

Commit

Permalink
fix: add back try catch for MissingDimensionException(removed due to …
Browse files Browse the repository at this point in the history
…bad merge) (#2356)
  • Loading branch information
hkfgo authored Aug 5, 2023
1 parent 2243e96 commit f47a6bd
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/Promitor.Integrations.AzureMonitor/AzureMonitorClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
using Promitor.Integrations.AzureMonitor.Logging;
using Promitor.Integrations.AzureMonitor.RequestHandlers;
using Promitor.Integrations.Azure.Authentication;
using Newtonsoft.Json;
using Promitor.Core.Metrics.Exceptions;

namespace Promitor.Integrations.AzureMonitor
{
Expand Down Expand Up @@ -108,11 +110,18 @@ public async Task<List<MeasuredMetric>> QueryMetricAsync(string metricName, List

// Get the metric value according to the requested aggregation type
var requestedMetricAggregate = InterpretMetricValue(aggregationType, mostRecentMetricValue);

var measuredMetric = metricDimensions.Any()
? MeasuredMetric.CreateForDimensions(requestedMetricAggregate, metricDimensions, timeseries)
: MeasuredMetric.CreateWithoutDimensions(requestedMetricAggregate);
measuredMetrics.Add(measuredMetric);
try
{
var measuredMetric = metricDimensions.Any()
? MeasuredMetric.CreateForDimensions(requestedMetricAggregate, metricDimensions, timeseries)
: MeasuredMetric.CreateWithoutDimensions(requestedMetricAggregate);
measuredMetrics.Add(measuredMetric);
}
catch (MissingDimensionException e)
{
_logger.LogWarning("{MetricName} has return a time series with empty value for {Dimension} and the measurements will be dropped", metricName, e.DimensionName);
_logger.LogDebug("The violating time series has content {Details}", JsonConvert.SerializeObject(e.TimeSeries));
}
}

return measuredMetrics;
Expand Down

0 comments on commit f47a6bd

Please sign in to comment.