Sha256: d94bc6b5801cb03baca99985c5084376e0621db60f8748dbefcde0f39bfd1982

Contents?: true

Size: 1.65 KB

Versions: 46

Compression:

Stored size: 1.65 KB

Contents

# frozen_string_literal: true

require "yaml"

begin
  if Appsignal::System.jruby?
    require "appsignal/extension/jruby"
    # {Appsignal.extension_loaded} is set in the JRuby extension file
  else
    require "appsignal_extension"
    Appsignal.extension_loaded = true
  end
rescue LoadError => err
  Appsignal.logger.error(
    "Failed to load extension (#{err}), please check the install.log file in " \
    "the ext directory of the gem and email us at support@appsignal.com"
  )
  Appsignal.extension_loaded = false
end

module Appsignal
  # @api private
  class Extension
    class << self
      def agent_config
        @agent_config ||= YAML.load(
          File.read(File.join(File.dirname(__FILE__), "../../ext/agent.yml"))
        )
      end

      def agent_version
        agent_config["version"]
      end

      # Do nothing if the extension methods are not loaded
      #
      # Disabled in testing so we can make sure that we don't miss a extension
      # function implementation.
      def method_missing(m, *args, &block)
        super if Appsignal.testing?
      end
    end

    if Appsignal::System.jruby?
      extend Appsignal::Extension::Jruby

      # Reassign Transaction class for JRuby extension usage.
      #
      # Makes sure the generated docs aren't always overwritten with the JRuby
      # version.
      Transaction = Jruby::Transaction
      # Reassign Data class for JRuby extension usage.
      #
      # Makes sure the generated docs aren't always overwritten with the JRuby
      # version.
      Data = Jruby::Data
    end

    class Data
      def inspect
        "#<#{self.class.name}:#{object_id} #{self}>"
      end
    end
  end
end

Version data entries

46 entries across 46 versions & 1 rubygems

Version Path
appsignal-2.7.2-java lib/appsignal/extension.rb
appsignal-2.7.2 lib/appsignal/extension.rb
appsignal-2.7.1 lib/appsignal/extension.rb
appsignal-2.7.1-java lib/appsignal/extension.rb
appsignal-2.8.0.alpha.1-java lib/appsignal/extension.rb
appsignal-2.8.0.alpha.1 lib/appsignal/extension.rb
appsignal-2.7.0 lib/appsignal/extension.rb
appsignal-2.7.0-java lib/appsignal/extension.rb
appsignal-2.7.0.beta.2 lib/appsignal/extension.rb
appsignal-2.7.0.beta.2-java lib/appsignal/extension.rb
appsignal-2.7.0.beta.1 lib/appsignal/extension.rb
appsignal-2.7.0.beta.1-java lib/appsignal/extension.rb
appsignal-2.7.0.alpha.4-java lib/appsignal/extension.rb
appsignal-2.7.0.alpha.4 lib/appsignal/extension.rb
appsignal-2.7.0.alpha.3-java lib/appsignal/extension.rb
appsignal-2.7.0.alpha.3 lib/appsignal/extension.rb
appsignal-2.7.0.alpha.2-java lib/appsignal/extension.rb
appsignal-2.7.0.alpha.2 lib/appsignal/extension.rb
appsignal-2.7.0.alpha.1 lib/appsignal/extension.rb
appsignal-2.7.0.alpha.1-java lib/appsignal/extension.rb