Skip to content

Commit

Permalink
Azure Metrics: fix getFirstMetricValue to return the first value (#648)
Browse files Browse the repository at this point in the history
* Make getFirstMetricValue to return the first value

This function was previously returning the last value instead of the
first value. This fix changes it and returns the value as soon as
reading it.

Co-authored-by: Maciek Sakrejda <[email protected]>
  • Loading branch information
keiko713 and msakrejda authored Dec 4, 2024
1 parent cb1c854 commit a32fd47
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions input/system/azure/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,8 @@ func GetSystemState(ctx context.Context, server *state.Server, logger *util.Logg

// getFirstMetricValue gets the first data from the time series metric and returns the value
func getFirstMetricValue(metric *azquery.Metric) (metricValue *azquery.MetricValue) {
for _, timeSeriesElement := range metric.TimeSeries {
for _, mValue := range timeSeriesElement.Data {
metricValue = mValue
}
if len(metric.TimeSeries) == 0 || len(metric.TimeSeries[0].Data) == 0 {
return
}
return
return metric.TimeSeries[0].Data[0]
}

0 comments on commit a32fd47

Please sign in to comment.