From 0b8bd68cc7c391468297e694395bb6e1559e73cc Mon Sep 17 00:00:00 2001 From: Sergey Avseyev Date: Thu, 12 Dec 2024 08:59:29 -0800 Subject: [PATCH] round values to 3 digits after the dot https://prometheus.io/docs/instrumenting/exposition_formats/#line-format --- client-ruby/client.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/client-ruby/client.rb b/client-ruby/client.rb index 7ad80f2..3fb75fe 100644 --- a/client-ruby/client.rb +++ b/client-ruby/client.rb @@ -141,7 +141,7 @@ def export counters.each do |bucket, level_2| level_2.each do |host, level_3| level_3.each do |metric, value| - report << "#{metric}{agent=#{@agent.inspect},bucket=#{bucket.inspect},node=#{host.inspect}} #{value.round} #{scrapping_timestamp}" + report << "#{metric}{agent=#{@agent.inspect},bucket=#{bucket.inspect},node=#{host.inspect}} #{value.round(3)} #{scrapping_timestamp}" end end end @@ -150,9 +150,9 @@ def export level_3.each do |metric, histogram| histogram.each do |label, value| report << if label.is_a?(Numeric) - "#{metric}_bucket{le=#{histogram_label(label).inspect},agent=#{@agent.inspect},bucket=#{bucket.inspect},node=#{host.inspect}} #{value.round} #{scrapping_timestamp}" + "#{metric}_bucket{le=#{histogram_label(label).inspect},agent=#{@agent.inspect},bucket=#{bucket.inspect},node=#{host.inspect}} #{value.round(3)} #{scrapping_timestamp}" else - "#{metric}_#{label}{agent=#{@agent.inspect},bucket=#{bucket.inspect},node=#{host.inspect}} #{value.round}" + "#{metric}_#{label}{agent=#{@agent.inspect},bucket=#{bucket.inspect},node=#{host.inspect}} #{value.round(3)}" end end end