Sha256: c2bbbf990b42e4f93b32c219df9b68e06b283ea2f046d0e6e2bfbf47c3205084
Contents?: true
Size: 1.46 KB
Versions: 11
Compression:
Stored size: 1.46 KB
Contents
# This file is distributed under New Relic's license terms. # See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details. # frozen_string_literal: true require 'base64' require 'json' require 'stringio' require 'zlib' module NewRelic module Agent class NewRelicService module Encoders module Identity def self.encode(data, opts = nil) data end end module Compressed module Deflate def self.encode(data, opts = nil) Zlib::Deflate.deflate(data, Zlib::DEFAULT_COMPRESSION) end end module Gzip BINARY = 'BINARY'.freeze def self.encode(data, opts = nil) output = StringIO.new output.set_encoding(BINARY) gz = Zlib::GzipWriter.new(output, Zlib::DEFAULT_COMPRESSION, Zlib::DEFAULT_STRATEGY) gz.write(data) gz.close output.rewind output.string end end end module Base64CompressedJSON def self.encode(data, opts = {}) if !opts[:skip_normalization] && Agent.config[:normalize_json_string_encodings] data = NewRelic::Agent::EncodingNormalizer.normalize_object(data) end json = ::JSON.dump(data) Base64.encode64(Compressed::Deflate.encode(json)) end end end end end end
Version data entries
11 entries across 11 versions & 1 rubygems