Skip to content

Commit 23418c2

Browse files
author
Daniel Magliola
authored
Merge pull request #191 from prometheus/fix_all_labels_preset_warning
Fix Ruby Warnings
2 parents 855befb + db572f6 commit 23418c2

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

lib/prometheus/client/data_stores/direct_file_store.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ def initialize(metric_name:, store_settings:, metric_settings:)
7979
@metric_name = metric_name
8080
@store_settings = store_settings
8181
@values_aggregation_mode = metric_settings[:aggregation]
82+
@store_opened_by_pid = nil
8283

8384
@lock = Monitor.new
8485
end

lib/prometheus/client/histogram.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,15 @@ def get(labels: {})
8989

9090
# Returns all label sets with their values expressed as hashes with their buckets
9191
def values
92-
v = @store.all_values
92+
values = @store.all_values
9393

94-
result = v.each_with_object({}) do |(label_set, v), acc|
94+
result = values.each_with_object({}) do |(label_set, v), acc|
9595
actual_label_set = label_set.reject{|l| l == :le }
9696
acc[actual_label_set] ||= @buckets.map{|b| [b.to_s, 0.0]}.to_h
9797
acc[actual_label_set][label_set[:le].to_s] = v
9898
end
9999

100-
result.each do |(label_set, v)|
100+
result.each do |(_label_set, v)|
101101
accumulate_buckets(v)
102102
end
103103
end

lib/prometheus/client/metric.rb

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,17 @@ def initialize(name,
2929
@docstring = docstring
3030
@preset_labels = stringify_values(preset_labels)
3131

32+
@all_labels_preset = false
33+
if preset_labels.keys.length == labels.length
34+
@validator.validate_labelset!(preset_labels)
35+
@all_labels_preset = true
36+
end
37+
3238
@store = Prometheus::Client.config.data_store.for_metric(
3339
name,
3440
metric_type: type,
3541
metric_settings: store_settings
3642
)
37-
38-
if preset_labels.keys.length == labels.length
39-
@validator.validate_labelset!(preset_labels)
40-
@all_labels_preset = true
41-
end
4243
end
4344

4445
# Returns the value for the given label set

lib/prometheus/client/summary.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ def get(labels: {})
3636

3737
# Returns all label sets with their values expressed as hashes with their sum/count
3838
def values
39-
v = @store.all_values
39+
values = @store.all_values
4040

41-
v.each_with_object({}) do |(label_set, v), acc|
41+
values.each_with_object({}) do |(label_set, v), acc|
4242
actual_label_set = label_set.reject{|l| l == :quantile }
4343
acc[actual_label_set] ||= { "count" => 0.0, "sum" => 0.0 }
4444
acc[actual_label_set][label_set[:quantile]] = v

0 commit comments

Comments
 (0)