Skip to content

Commit

Permalink
Fix Ruby Warnings
Browse files Browse the repository at this point in the history
Our tests are running without outputting warnings, so we don't see a number
of things Ruby was warning us about.

All these code changes are effectively a NOOP.
  • Loading branch information
dmagliola committed May 26, 2020
1 parent 204d8c9 commit 53259d8
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
1 change: 1 addition & 0 deletions lib/prometheus/client/data_stores/direct_file_store.rb
Expand Up @@ -74,6 +74,7 @@ def initialize(metric_name:, store_settings:, metric_settings:)
@metric_name = metric_name
@store_settings = store_settings
@values_aggregation_mode = metric_settings[:aggregation]
@store_opened_by_pid = nil

@lock = Monitor.new
end
Expand Down
6 changes: 3 additions & 3 deletions lib/prometheus/client/histogram.rb
Expand Up @@ -89,15 +89,15 @@ def get(labels: {})

# Returns all label sets with their values expressed as hashes with their buckets
def values
v = @store.all_values
values = @store.all_values

result = v.each_with_object({}) do |(label_set, v), acc|
result = values.each_with_object({}) do |(label_set, v), acc|
actual_label_set = label_set.reject{|l| l == :le }
acc[actual_label_set] ||= @buckets.map{|b| [b.to_s, 0.0]}.to_h
acc[actual_label_set][label_set[:le].to_s] = v
end

result.each do |(label_set, v)|
result.each do |(_label_set, v)|
accumulate_buckets(v)
end
end
Expand Down
11 changes: 6 additions & 5 deletions lib/prometheus/client/metric.rb
Expand Up @@ -29,16 +29,17 @@ def initialize(name,
@docstring = docstring
@preset_labels = stringify_values(preset_labels)

@all_labels_preset = false
if preset_labels.keys.length == labels.length
@validator.validate_labelset!(preset_labels)
@all_labels_preset = true
end

@store = Prometheus::Client.config.data_store.for_metric(
name,
metric_type: type,
metric_settings: store_settings
)

if preset_labels.keys.length == labels.length
@validator.validate_labelset!(preset_labels)
@all_labels_preset = true
end
end

# Returns the value for the given label set
Expand Down
4 changes: 2 additions & 2 deletions lib/prometheus/client/summary.rb
Expand Up @@ -36,9 +36,9 @@ def get(labels: {})

# Returns all label sets with their values expressed as hashes with their sum/count
def values
v = @store.all_values
values = @store.all_values

v.each_with_object({}) do |(label_set, v), acc|
values.each_with_object({}) do |(label_set, v), acc|
actual_label_set = label_set.reject{|l| l == :quantile }
acc[actual_label_set] ||= { "count" => 0.0, "sum" => 0.0 }
acc[actual_label_set][label_set[:quantile]] = v
Expand Down

0 comments on commit 53259d8

Please sign in to comment.