Sha256: e8b762d491d4beed89f35a3d21520e68a3d558f086d829ec78c0c7600c990cd9
Contents?: true
Size: 1.49 KB
Versions: 3
Compression:
Stored size: 1.49 KB
Contents
# Report environment data on the first request. # # XXX: Completely untested outside of MRI (official Ruby runtime) 1.9.3 and up! module Immunio class EnvironmentReporter def initialize(app) @app = app # No need for mutex, reporting environment is idempotent @reported = false end def call(env) response = @app.call(env) # Report gem usage at the end so that everything as been loaded. Request.time "plugin", "#{Module.nesting[0]}::#{__method__}" do report if !@reported end response end def runtime_name if Object.const_defined?(:RUBY_DESCRIPTION) && RUBY_DESCRIPTION =~ /Enterprise/ 'ree' elsif Object.const_defined? :RUBY_ENGINE RUBY_ENGINE.to_s else 'unknown' end end def runtime_version case runtime_name when 'ruby' then RUBY_VERSION when 'jruby' then JRUBY_VERSION when 'rbx' then Rubinius::VERSION else 'unknown' end end def report @reported = true info = { runtime: { name: runtime_name, version: runtime_version }, language: { name: 'ruby', version: RUBY_VERSION }, platform: { description: RUBY_PLATFORM }, dependencies: {} } Gem.loaded_specs.each_pair do |name, spec| info[:dependencies][name] = spec.version.to_s end Immunio.agent.environment = info end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
immunio-0.15.4 | lib/immunio/plugins/environment_reporter.rb |
immunio-0.15.3 | lib/immunio/plugins/environment_reporter.rb |
immunio-0.15.2 | lib/immunio/plugins/environment_reporter.rb |