class NewRelic::Agent::NewRelicService::JsonMarshaller
Marshal collector protocol with JSON when available
Constants
- OK_YAJL_VERSION
Public Class Methods
Source
# File lib/new_relic/agent/new_relic_service/json_marshaller.rb, line 63 def self.human_readable? true # for some definitions of 'human' end
Source
# File lib/new_relic/agent/new_relic_service/json_marshaller.rb, line 13 def initialize warn_for_yajl end
Public Instance Methods
Source
# File lib/new_relic/agent/new_relic_service/json_marshaller.rb, line 51 def default_encoder if NewRelic::Agent.config[:simple_compression] Encoders::Identity else Encoders::Base64CompressedJSON end end
Source
# File lib/new_relic/agent/new_relic_service/json_marshaller.rb, line 30 def dump(ruby, opts = {}) prepared = prepare(ruby, opts) if !opts[:skip_normalization] && Agent.config[:normalize_json_string_encodings] prepared = NewRelic::Agent::EncodingNormalizer.normalize_object(prepared) end ::JSON.dump(prepared) end
Source
# File lib/new_relic/agent/new_relic_service/json_marshaller.rb, line 59 def format 'json' end
Source
# File lib/new_relic/agent/new_relic_service/json_marshaller.rb, line 40 def load(data) if data.nil? || data.empty? return nil end return_value(::JSON.load(data)) rescue => e ::NewRelic::Agent.logger.debug("#{e.class.name} : #{e.message} encountered loading collector response: #{data}") raise end
Source
# File lib/new_relic/agent/new_relic_service/json_marshaller.rb, line 19 def warn_for_yajl if defined?(::Yajl) require 'yajl/version' if Gem::Version.new(::Yajl::VERSION) < OK_YAJL_VERSION ::NewRelic::Agent.logger.warn("Detected yajl-ruby version #{::Yajl::VERSION} which can cause segfaults with newrelic_rpm's thread profiling features. We strongly recommend you upgrade to the latest yajl-ruby version available.") end end rescue => err ::NewRelic::Agent.logger.warn('Failed trying to watch for problematic yajl-ruby version.', err) end