class Mmtrix::Agent::MmtrixService::PrubyMarshaller

Primitive Ruby Object Notation which complies JSON format data strutures

Public Class Methods

is_supported?() click to toggle source
# File lib/mmtrix/agent/mmtrix_service/pruby_marshaller.rb, line 50
def self.is_supported?
  true
end
new() click to toggle source
# File lib/mmtrix/agent/mmtrix_service/pruby_marshaller.rb, line 12
def initialize
  ::Mmtrix::Agent.logger.debug 'Using Pruby marshaller'
  warn_for_pruby_deprecation
end

Public Instance Methods

dump(ruby, opts={}) click to toggle source
# File lib/mmtrix/agent/mmtrix_service/pruby_marshaller.rb, line 23
def dump(ruby, opts={})
  Mmtrix::LanguageSupport.with_cautious_gc do
    Marshal.dump(prepare(ruby, opts))
  end
rescue => e
  ::Mmtrix::Agent.logger.debug("#{e.class.name} : #{e.message} when marshalling #{ruby.inspect}")
  raise
end
format() click to toggle source
# File lib/mmtrix/agent/mmtrix_service/pruby_marshaller.rb, line 46
def format
  'pruby'
end
load(data) click to toggle source
# File lib/mmtrix/agent/mmtrix_service/pruby_marshaller.rb, line 32
def load(data)
  if data.nil? || data.empty?
    ::Mmtrix::Agent.logger.error "Empty pruby response from collector: '#{data.inspect}'"
    return nil
  end

  Mmtrix::LanguageSupport.with_cautious_gc do
    return_value(Marshal.load(data))
  end
rescue
  ::Mmtrix::Agent.logger.debug "Error encountered loading collector response: #{data}"
  raise
end
warn_for_pruby_deprecation() click to toggle source
# File lib/mmtrix/agent/mmtrix_service/pruby_marshaller.rb, line 17
def warn_for_pruby_deprecation
  if RUBY_VERSION < "1.9" && !defined?(::JSON)
    Mmtrix::Agent.logger.warn("Upcoming versions of the Ruby agent running on Ruby 1.8.7 will require the 'json' gem. To avoid interuption in reporting, please update your Gemfile. See http://docs.mmtrix.com/docs/ruby/ruby-1.8.7-support for more information.")
  end
end