Class: NewRelic::Agent::NewRelicService::JsonMarshaller
- Inherits:
-
Marshaller
- Object
- Marshaller
- NewRelic::Agent::NewRelicService::JsonMarshaller
- 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
- #default_encoder ⇒ Object
- #dump(ruby, opts = {}) ⇒ Object
- #format ⇒ Object
-
#initialize ⇒ JsonMarshaller
constructor
A new instance of JsonMarshaller.
- #load(data) ⇒ Object
Methods inherited from Marshaller
Constructor Details
#initialize ⇒ JsonMarshaller
Returns a new instance of JsonMarshaller.
477 478 479 |
# File 'lib/new_relic/agent/new_relic_service.rb', line 477 def initialize ::NewRelic::Agent.logger.debug 'Using JSON marshaller' end |
Class Method Details
.human_readable? ⇒ Boolean
508 509 510 |
# File 'lib/new_relic/agent/new_relic_service.rb', line 508 def self.human_readable? true # for some definitions of 'human' end |
.is_supported? ⇒ Boolean
504 505 506 |
# File 'lib/new_relic/agent/new_relic_service.rb', line 504 def self.is_supported? RUBY_VERSION >= '1.9.2' end |
Instance Method Details
#default_encoder ⇒ Object
496 497 498 |
# File 'lib/new_relic/agent/new_relic_service.rb', line 496 def default_encoder Encoders::Base64CompressedJSON end |
#dump(ruby, opts = {}) ⇒ Object
481 482 483 484 485 486 |
# File 'lib/new_relic/agent/new_relic_service.rb', line 481 def dump(ruby, opts={}) JSON.dump(prepare(ruby, opts)) rescue => e ::NewRelic::Agent.logger.debug "#{e.class.name} : #{e.} encountered dumping agent data: #{ruby}" raise JsonError.new(e) end |
#format ⇒ Object
500 501 502 |
# File 'lib/new_relic/agent/new_relic_service.rb', line 500 def format 'json' end |
#load(data) ⇒ Object
488 489 490 491 492 493 494 |
# File 'lib/new_relic/agent/new_relic_service.rb', line 488 def load(data) return unless data && data != '' return_value(JSON.load(data)) rescue => e ::NewRelic::Agent.logger.debug "#{e.class.name} : #{e.} encountered loading collector response: #{data}" raise end |