lib/prometheus/client/push.rb in prometheus-client-4.2.1 vs lib/prometheus/client/push.rb in prometheus-client-4.2.2
- old
+ new
@@ -85,19 +85,23 @@
rescue URI::InvalidURIError => e
raise ArgumentError, "#{url} is not a valid URL: #{e}"
end
def build_path(job, grouping_key)
+ job = job.to_s
+
# Job can't be empty, but it can contain `/`, so we need to base64
# encode it in that case
if job.include?('/')
encoded_job = Base64.urlsafe_encode64(job)
path = "#{PATH}/job@base64/#{encoded_job}"
else
path = "#{PATH}/job/#{ERB::Util::url_encode(job)}"
end
grouping_key.each do |label, value|
+ value = value.to_s
+
if value.include?('/')
encoded_value = Base64.urlsafe_encode64(value)
path += "/#{label}@base64/#{encoded_value}"
# While it's valid for the urlsafe_encode64 function to return an
# empty string when the input string is empty, it doesn't work for