Sha256: ea98647540ca3c4a01cfeb42e59ca51f05889cf39a3679b8c935c60d8bb735ec

Contents?: true

Size: 1.92 KB

Versions: 22

Compression:

Stored size: 1.92 KB

Contents

module NewRelic::LanguageSupport
  extend self
  
  module DataSerialization
    def self.included(base)
      # need to disable GC during marshal load in 1.8.7
      if NewRelic::LanguageSupport.using_version?('1.8.7') &&
          !NewRelic::LanguageSupport.using_engine?('jruby') &&
          !NewRelic::LanguageSupport.using_engine?('rbx')
        base.class_eval do
          def self.load(*args)
            if defined?(::GC) && ::GC.respond_to?(:disable)
              ::GC.disable
              val = super
              ::GC.enable
              val
            else
              super
            end
          end
        end
      end
    end
  end
  
  module Control
    def self.included(base)
      # need to use syck rather than psych when possible
      if defined?(::YAML::ENGINE)
        if !NewRelic::LanguageSupport.using_engine?('jruby') &&
            (NewRelic::LanguageSupport.using_version?('1.9.1') ||
             NewRelic::LanguageSupport.using_version?('1.9.2'))
          base.class_eval do
            def load_newrelic_yml(*args)
              yamler = ::YAML::ENGINE.yamler
              ::YAML::ENGINE.yamler = 'syck'
              val = super
              ::YAML::ENGINE.yamler = yamler
              val
            end
          end
        end
      end
    end
  end
  
  module SynchronizedHash
    def self.included(base)
      # need to lock iteration of stats hash in 1.9.x
      if NewRelic::LanguageSupport.using_version?('1.9') ||
          NewRelic::LanguageSupport.using_engine?('jruby')
        base.class_eval do
          def each(*args, &block)
            @lock.synchronize { super }
          end
        end
      end
    end
  end
  
  def using_engine?(engine)
    if defined?(::RUBY_ENGINE)
      ::RUBY_ENGINE == engine
    else
      engine == 'ruby'
    end
  end
  
  def using_version?(version)
    numbers = version.split('.')
    numbers == ::RUBY_VERSION.split('.')[0, numbers.size]
  end
end

Version data entries

22 entries across 22 versions & 3 rubygems

Version Path
newrelic_rpm-3.3.5 lib/new_relic/language_support.rb
newrelic_rpm-3.3.5.beta1 lib/new_relic/language_support.rb
dolores_rpm-3.3.4.8 lib/new_relic/language_support.rb
dolores_rpm-3.3.4.7 lib/new_relic/language_support.rb
dolores_rpm-3.3.4.6 lib/new_relic/language_support.rb
dolores_rpm-3.3.4.5 lib/new_relic/language_support.rb
dolores_rpm-3.3.4.4 lib/new_relic/language_support.rb
dolores_rpm-3.3.4.3 lib/new_relic/language_support.rb
dolores_rpm-3.3.4.1.fork2 lib/new_relic/language_support.rb
dolores_rpm-3.3.4.1.fork lib/new_relic/language_support.rb
wd_newrelic_rpm-3.3.4.1 lib/new_relic/language_support.rb
dolores_rpm-3.3.4.fork lib/new_relic/language_support.rb
newrelic_rpm-3.3.4.1 lib/new_relic/language_support.rb
newrelic_rpm-3.3.4 lib/new_relic/language_support.rb
newrelic_rpm-3.3.4.beta1 lib/new_relic/language_support.rb
newrelic_rpm-3.3.3 lib/new_relic/language_support.rb
newrelic_rpm-3.3.3.beta2 lib/new_relic/language_support.rb
newrelic_rpm-3.3.2.1 lib/new_relic/language_support.rb
newrelic_rpm-3.3.3.beta1 lib/new_relic/language_support.rb
newrelic_rpm-3.3.2 lib/new_relic/language_support.rb