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.



423
424
425
# File 'lib/new_relic/agent/new_relic_service.rb', line 423

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

Class Method Details

.human_readable?Boolean

Returns:

  • (Boolean)


451
452
453
# File 'lib/new_relic/agent/new_relic_service.rb', line 451

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

.is_supported?Boolean

Returns:

  • (Boolean)


447
448
449
# File 'lib/new_relic/agent/new_relic_service.rb', line 447

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

Instance Method Details

#default_encoderObject



439
440
441
# File 'lib/new_relic/agent/new_relic_service.rb', line 439

def default_encoder
  Encoders::Base64CompressedJSON
end

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



427
428
429
# File 'lib/new_relic/agent/new_relic_service.rb', line 427

def dump(ruby, opts={})
  JSON.dump(prepare(ruby, opts))
end

#formatObject



443
444
445
# File 'lib/new_relic/agent/new_relic_service.rb', line 443

def format
  'json'
end

#load(data) ⇒ Object



431
432
433
434
435
436
437
# File 'lib/new_relic/agent/new_relic_service.rb', line 431

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