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