class Mmtrix::Agent::MmtrixService::JsonMarshaller
Marshal collector protocol with JSON when available
Constants
- OK_YAJL_VERSION
Public Class Methods
human_readable?()
click to toggle source
# File lib/mmtrix/agent/mmtrix_service/json_marshaller.rb, line 69 def self.human_readable? true # for some definitions of 'human' end
is_supported?()
click to toggle source
# File lib/mmtrix/agent/mmtrix_service/json_marshaller.rb, line 65 def self.is_supported? Mmtrix::JSONWrapper.usable_for_collector_serialization? end
new()
click to toggle source
# File lib/mmtrix/agent/mmtrix_service/json_marshaller.rb, line 12 def initialize ::Mmtrix::Agent.logger.debug "Using JSON marshaller (#{Mmtrix::JSONWrapper.backend_name})" unless self.class.is_supported? ::Mmtrix::Agent.logger.warn "The JSON marshaller in use (#{Mmtrix::JSONWrapper.backend_name}) is not recommended. Ensure the 'json' gem is available in your application for better performance." end warn_for_yajl end
Public Instance Methods
default_encoder()
click to toggle source
# File lib/mmtrix/agent/mmtrix_service/json_marshaller.rb, line 57 def default_encoder Encoders::Base64CompressedJSON end
dump(ruby, opts={})
click to toggle source
# File lib/mmtrix/agent/mmtrix_service/json_marshaller.rb, line 33 def dump(ruby, opts={}) prepared = prepare(ruby, opts) if opts[:skip_normalization] normalize_encodings = false else normalize_encodings = Agent.config[:normalize_json_string_encodings] end Mmtrix::JSONWrapper.dump(prepared, :normalize => normalize_encodings) end
format()
click to toggle source
# File lib/mmtrix/agent/mmtrix_service/json_marshaller.rb, line 61 def format 'json' end
load(data)
click to toggle source
# File lib/mmtrix/agent/mmtrix_service/json_marshaller.rb, line 45 def load(data) if data.nil? || data.empty? ::Mmtrix::Agent.logger.error "Empty JSON response from collector: '#{data.inspect}'" return nil end return_value(Mmtrix::JSONWrapper.load(data)) rescue => e ::Mmtrix::Agent.logger.debug "#{e.class.name} : #{e.message} encountered loading collector response: #{data}" raise end
warn_for_yajl()
click to toggle source
# File lib/mmtrix/agent/mmtrix_service/json_marshaller.rb, line 22 def warn_for_yajl if defined?(::Yajl) require 'yajl/version' if Mmtrix::VersionNumber.new(::Yajl::VERSION) < OK_YAJL_VERSION ::Mmtrix::Agent.logger.warn "Detected yajl-ruby version #{::Yajl::VERSION} which can cause segfaults with mmtrix_rpm's thread profiling features. We strongly recommend you upgrade to the latest yajl-ruby version available." end end rescue => err ::Mmtrix::Agent.logger.warn "Failed trying to watch for problematic yajl-ruby version.", err end