Sha256: 83a166e8aaf22ede4f0529a98466b46a5cefc490f445cc8cfb253c7124df6530

Contents?: true

Size: 1.65 KB

Versions: 4

Compression:

Stored size: 1.65 KB

Contents

# encoding: utf-8
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.

require 'new_relic/agent/new_relic_service/marshaller'

module NewRelic
  module Agent
    class NewRelicService
      # Primitive Ruby Object Notation which complies JSON format data strutures
      class PrubyMarshaller < Marshaller
        def initialize
          ::NewRelic::Agent.logger.debug 'Using Pruby marshaller'
          warn_for_pruby_deprecation
        end

        def warn_for_pruby_deprecation
          if RUBY_VERSION < "1.9" && !defined?(::JSON)
            NewRelic::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.newrelic.com/docs/ruby/ruby-1.8.7-support for more information.")
          end
        end

        def dump(ruby, opts={})
          NewRelic::LanguageSupport.with_cautious_gc do
            Marshal.dump(prepare(ruby, opts))
          end
        rescue => e
          ::NewRelic::Agent.logger.debug("#{e.class.name} : #{e.message} when marshalling #{ruby.inspect}")
          raise
        end

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

        def format
          'pruby'
        end

        def self.is_supported?
          true
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
newrelic_rpm-3.9.5.251 lib/new_relic/agent/new_relic_service/pruby_marshaller.rb
newrelic_rpm-3.9.4.245 lib/new_relic/agent/new_relic_service/pruby_marshaller.rb
newrelic_rpm-3.9.3.241 lib/new_relic/agent/new_relic_service/pruby_marshaller.rb
newrelic_rpm-3.9.2.239 lib/new_relic/agent/new_relic_service/pruby_marshaller.rb