Sha256: 98d0bc9c95b856b61f610b66f98ca01b7af4bd3746b4fc2ae91ffad9aab6aacc
Contents?: true
Size: 1004 Bytes
Versions: 1
Compression:
Stored size: 1004 Bytes
Contents
require 'zlib' class Utility def self.compress_payload(payload) puts "#{self.get_time} Compressing metrics payload" json_payload = payload.to_json # Compress the JSON string using zlib's GzipWriter compressed_payload = StringIO.new Zlib::GzipWriter.wrap(compressed_payload) do |gz| begin gz.write(json_payload) ensure gz.close end end # convert the compressed data to a string 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 def self.get_time() return Time.now.strftime("%Y-%m-%d %H:%M:%S") end def self.enable_http_client_logs(http_client_logs) if http_client_logs RestClient.log = STDOUT else RestClient.log = nil end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
fluent-plugin-jfrog-send-metrics-0.1.9 | lib/fluent/plugin/utility.rb |