Sha256: a94a559eea2867f23779088e2a146dbe707c436abce4355a95b70f95c4438f1e

Contents?: true

Size: 1.62 KB

Versions: 88

Compression:

Stored size: 1.62 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 run `appsignal diagnose` " \
      "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

88 entries across 88 versions & 1 rubygems

Version Path
appsignal-2.10.12 lib/appsignal/extension.rb
appsignal-2.10.12-java lib/appsignal/extension.rb
appsignal-2.10.11 lib/appsignal/extension.rb
appsignal-2.10.11-java lib/appsignal/extension.rb
appsignal-2.11.0.beta.4 lib/appsignal/extension.rb
appsignal-2.11.0.beta.4-java lib/appsignal/extension.rb
appsignal-2.11.0.beta.3 lib/appsignal/extension.rb
appsignal-2.11.0.beta.3-java lib/appsignal/extension.rb
appsignal-2.10.10 lib/appsignal/extension.rb
appsignal-2.10.10-java lib/appsignal/extension.rb
appsignal-2.11.0.beta.2 lib/appsignal/extension.rb
appsignal-2.11.0.beta.2-java lib/appsignal/extension.rb
appsignal-2.11.0.beta.1-java lib/appsignal/extension.rb
appsignal-2.11.0.beta.1 lib/appsignal/extension.rb
appsignal-2.11.0.alpha.2 lib/appsignal/extension.rb
appsignal-2.11.0.alpha.2-java lib/appsignal/extension.rb
appsignal-2.11.0.alpha.1 lib/appsignal/extension.rb
appsignal-2.11.0.alpha.1-java lib/appsignal/extension.rb
appsignal-2.10.9 lib/appsignal/extension.rb
appsignal-2.10.9-java lib/appsignal/extension.rb