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

Instance Attribute Summary

Attributes inherited from Marshaller

#encoding

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Marshaller

#compress, #parsed_error

Constructor Details

#initializeJsonMarshaller

Returns a new instance of JsonMarshaller.



359
360
361
# File 'lib/new_relic/agent/new_relic_service.rb', line 359

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

Class Method Details

.is_supported?Boolean

Returns:

  • (Boolean)


383
384
385
# File 'lib/new_relic/agent/new_relic_service.rb', line 383

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

Instance Method Details

#dump(ruby) ⇒ Object



363
364
365
# File 'lib/new_relic/agent/new_relic_service.rb', line 363

def dump(ruby)
  compress(JSON.dump(prepare(ruby)))
end

#encode_compress(data) ⇒ Object



375
376
377
# File 'lib/new_relic/agent/new_relic_service.rb', line 375

def encode_compress(data)
  Base64.encode64(compress(JSON.dump(data), :force => true))
end

#formatObject



379
380
381
# File 'lib/new_relic/agent/new_relic_service.rb', line 379

def format
  'json'
end

#load(data) ⇒ Object



367
368
369
370
371
372
373
# File 'lib/new_relic/agent/new_relic_service.rb', line 367

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