module Sqreen::RuntimeInfos
Public Instance Methods
agent()
click to toggle source
# File lib/sqreen/runtime_infos.rb, line 67 def agent { :agent_type => :ruby, :agent_version => ::Sqreen::VERSION, }.tap do |h| h[:libsqreen_version] = libsqreen_version if libsqreen? end end
all(framework)
click to toggle source
# File lib/sqreen/runtime_infos.rb, line 17 def all(framework) res = { :various_infos => {} } res.merge! agent res.merge! os res.merge! runtime res.merge! framework.framework_infos res[:bundle_signature] = dependencies_signature res[:various_infos].merge! time res[:various_infos].merge! process res end
calculate_dependencies_signature(pkgs)
click to toggle source
# File lib/sqreen/runtime_infos.rb, line 137 def calculate_dependencies_signature(pkgs) return nil if pkgs.nil? || pkgs.empty? sha1 = Digest::SHA1.new pkgs.map { |pkg| [pkg[:name], pkg[:version]] }.sort.each_with_index do |p, i| sha1 << format(i.zero? ? '%s-%s' : '|%s-%s', *p) end sha1.hexdigest end
dependencies()
click to toggle source
# File lib/sqreen/runtime_infos.rb, line 36 def dependencies gem_info = Gem.loaded_specs gem_info.map do |name, spec| { :name => name, :version => spec.version.to_s, :homepage => spec.homepage, :source => (extract_source(spec.source) if spec.respond_to?(:source)), } end end
dependencies_signature()
click to toggle source
# File lib/sqreen/runtime_infos.rb, line 133 def dependencies_signature calculate_dependencies_signature(dependencies) end
extract_source(source)
click to toggle source
# File lib/sqreen/runtime_infos.rb, line 146 def extract_source(source) return nil unless source ret = { 'name' => source.class.name.split(':')[-1] } opts = {} opts = source.options if source.respond_to?(:options) ret['remotes'] = opts['remotes'] if opts['remotes'] ret['uri'] = opts['uri'] if opts['uri'] # FIXME: scrub any auth data in uris ret['path'] = opts['path'].to_s if opts['path'] ret end
hostname()
click to toggle source
# File lib/sqreen/runtime_infos.rb, line 105 def hostname Socket.gethostname end
libsqreen?()
click to toggle source
# File lib/sqreen/runtime_infos.rb, line 76 def libsqreen? Sqreen::Dependency::LibSqreen.required? && !Sqreen::Dependency::LibSqreen.stub? end
libsqreen_version()
click to toggle source
# File lib/sqreen/runtime_infos.rb, line 80 def libsqreen_version return unless libsqreen? @libsqreen_version ||= case (version = ::LibSqreen.version) when Array version.map(&:to_s).join('.') else version end end
local_infos()
click to toggle source
# File lib/sqreen/runtime_infos.rb, line 29 def local_infos { 'time' => Time.now.utc, 'name' => hostname, } end
os()
click to toggle source
# File lib/sqreen/runtime_infos.rb, line 91 def os plat = if defined? ::RUBY_PLATFORM ::RUBY_PLATFORM elsif defined? ::PLATFORM ::PLATFORM else '' end { :os_type => plat, :hostname => hostname, } end
process()
click to toggle source
# File lib/sqreen/runtime_infos.rb, line 109 def process { :pid => Process.pid, :ppid => Process.ppid, :euid => Process.euid, :egid => Process.egid, :uid => Process.uid, :gid => Process.gid, :name => $0, } end
runtime()
click to toggle source
# File lib/sqreen/runtime_infos.rb, line 121 def runtime engine = if defined? ::RUBY_ENGINE ::RUBY_ENGINE else 'ruby' end { :runtime_type => engine, :runtime_version => ::RUBY_DESCRIPTION, } end
ssl()
click to toggle source
# File lib/sqreen/runtime_infos.rb, line 53 def ssl type = nil version = nil if defined? OpenSSL type = 'OpenSSL' version = OpenSSL::OPENSSL_VERSION if defined? OpenSSL::OPENSSL_VERSION end { :ssl => { :type => type, :version => version, } } end
time()
click to toggle source
# File lib/sqreen/runtime_infos.rb, line 48 def time # FIXME: That should maybe be called local-time { :time => Time.now } end