4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/fluent/plugin/utility.rb', line 4
def self.compress_payload(payload)
puts "#{self.get_time} Compressing metrics payload"
json_payload = payload.to_json
compressed_payload = StringIO.new
Zlib::GzipWriter.wrap(compressed_payload) do |gz|
gz.write(json_payload)
end
compressed_data = compressed_payload.string
puts "#{self.get_time} Original metrics payload size: #{json_payload.bytesize} bytes"
puts "#{self.get_time} Compressed metrics payload size: #{compressed_data.bytesize} bytes"
return compressed_data
end
|