Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions lib/prometheus/client/data_stores/direct_file_store.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require 'fileutils'
require "cgi"
require "uri"

module Prometheus
module Client
Expand Down Expand Up @@ -133,12 +133,9 @@ def all_values
begin
store = FileMappedDict.new(file_path, true)
store.all_values.each do |(labelset_qs, v, ts)|
# Labels come as a query string, and CGI::parse returns arrays for each key
# "foo=bar&x=y" => { "foo" => ["bar"], "x" => ["y"] }
# Turn the keys back into symbols, and remove the arrays
label_set = CGI::parse(labelset_qs).map do |k, vs|
[k.to_sym, vs.first]
end.to_h
# Labels come as a query string
# "foo=bar&x=y" => { foo: "bar", x: "y" }
label_set = URI.decode_www_form(labelset_qs).to_h.transform_keys(&:to_sym)

stores_data[label_set] << [v, ts]
end
Expand All @@ -165,7 +162,7 @@ def store_key(labels)
labels[:pid] = process_id
end

labels.to_a.sort.map{|k,v| "#{CGI::escape(k.to_s)}=#{CGI::escape(v.to_s)}"}.join('&')
URI.encode_www_form(labels.to_a.sort)
end

def internal_store
Expand Down