Skip to content

Commit

Permalink
Refactor aggregation code for :all
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Sinjakli committed Jun 11, 2019
1 parent d2ebc02 commit cad0a4f
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions lib/prometheus/client/data_stores/direct_file_store.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,17 +133,9 @@ def all_values
end
end

if @values_aggregation_mode == ALL
stores_data.each do |label_set, values|
stores_data[label_set] = values.first
end

stores_data
else
# Aggregate all the different values for each label_set
stores_data.each_with_object({}) do |(label_set, values), acc|
acc[label_set] = aggregate_values(values)
end
# Aggregate all the different values for each label_set
stores_data.each_with_object({}) do |(label_set, values), acc|
acc[label_set] = aggregate_values(values)
end
end

Expand Down Expand Up @@ -182,6 +174,8 @@ def aggregate_values(values)
values.max
elsif @values_aggregation_mode == MIN
values.min
elsif @values_aggregation_mode == ALL
values.first
else
raise InvalidStoreSettingsError,
"Invalid Aggregation Mode: #{ @values_aggregation_mode }"
Expand Down

0 comments on commit cad0a4f

Please sign in to comment.