Class: NewRelic::Agent::NewRelicService::JsonMarshaller

Inherits:
Marshaller
  • Object
show all
Defined in:
lib/new_relic/agent/new_relic_service.rb

Overview

Marshal collector protocol with JSON when available

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Marshaller

#parsed_error, #prepare

Constructor Details

#initializeJsonMarshaller

Returns a new instance of JsonMarshaller.



476
477
478
# File 'lib/new_relic/agent/new_relic_service.rb', line 476

def initialize
  ::NewRelic::Agent.logger.debug 'Using JSON marshaller'
end

Class Method Details

.human_readable?Boolean

Returns:

  • (Boolean)


507
508
509
# File 'lib/new_relic/agent/new_relic_service.rb', line 507

def self.human_readable?
  true # for some definitions of 'human'
end

.is_supported?Boolean

Returns:

  • (Boolean)


503
504
505
# File 'lib/new_relic/agent/new_relic_service.rb', line 503

def self.is_supported?
  RUBY_VERSION >= '1.9.2'
end

Instance Method Details

#default_encoderObject



495
496
497
# File 'lib/new_relic/agent/new_relic_service.rb', line 495

def default_encoder
  Encoders::Base64CompressedJSON
end

#dump(ruby, opts = {}) ⇒ Object



480
481
482
483
484
485
# File 'lib/new_relic/agent/new_relic_service.rb', line 480

def dump(ruby, opts={})
  JSON.dump(prepare(ruby, opts))
rescue => e
  ::NewRelic::Agent.logger.debug "#{e.class.name} : #{e.message} encountered dumping agent data: #{ruby}"
  raise JsonError.new(e)
end

#formatObject



499
500
501
# File 'lib/new_relic/agent/new_relic_service.rb', line 499

def format
  'json'
end

#load(data) ⇒ Object



487
488
489
490
491
492
493
# File 'lib/new_relic/agent/new_relic_service.rb', line 487

def load(data)
  return unless data && data != ''
  return_value(JSON.load(data))
rescue => e
  ::NewRelic::Agent.logger.debug "#{e.class.name} : #{e.message} encountered loading collector response: #{data}"
  raise
end