File tree Expand file tree Collapse file tree 3 files changed +14
-0
lines changed
Expand file tree Collapse file tree 3 files changed +14
-0
lines changed Original file line number Diff line number Diff line change 99 Previously, an error would be raised if you passed a symbol as the job name, which
1010 is inconsistent with how we handle label values in the rest of the client. This
1111 change converts the job name to a string before trying to use it.
12+ - [ #297 ] ( https://github.com/prometheus/client_ruby/pull/297 ) Stringify grouping key
13+ values in push client:
14+ Same thing as #296 , but for grouping key values.
1215
1316# 4.2.1 / 2023-08-04
1417
Original file line number Diff line number Diff line change @@ -99,6 +99,8 @@ def build_path(job, grouping_key)
9999 end
100100
101101 grouping_key . each do |label , value |
102+ value = value . to_s
103+
102104 if value . include? ( '/' )
103105 encoded_value = Base64 . urlsafe_encode64 ( value )
104106 path += "/#{ label } @base64/#{ encoded_value } "
Original file line number Diff line number Diff line change 101101 expect ( push . path ) . to eql ( '/metrics/job/foo' )
102102 end
103103
104+ it 'converts non-string grouping labels to strings' do
105+ push = Prometheus ::Client ::Push . new (
106+ job : 'test-job' ,
107+ grouping_key : { foo : :bar , baz : :qux } ,
108+ )
109+
110+ expect ( push . path ) . to eql ( '/metrics/job/test-job/foo/bar/baz/qux' )
111+ end
112+
104113 it 'encodes the job name in url-safe base64 if it contains `/`' do
105114 push = Prometheus ::Client ::Push . new (
106115 job : 'foo/test-job' ,
You can’t perform that action at this time.
0 commit comments