Sha256: 19565a6b842229b3eadc5a7a2ecb7952e3dff373563a085a7d78e5f026a0c006

Contents?: true

Size: 1.08 KB

Versions: 13

Compression:

Stored size: 1.08 KB

Contents

require 'rbconfig'

module Raven
  class Context
    def self.current
      Thread.current[:sentry_context] ||= new
    end

    def self.clear!
      Thread.current[:sentry_context] = nil
    end

    attr_accessor :extra, :server_os, :rack_env, :runtime, :tags, :user

    def initialize
      self.server_os = self.class.os_context
      self.runtime = self.class.runtime_context
      self.extra = { :server => { :os => server_os, :runtime => runtime } }
      self.rack_env = nil
      self.tags = {}
      self.user = {}
    end

    class << self
      def os_context
        @os_context ||= {
          :name => Raven.sys_command("uname -s") || RbConfig::CONFIG["host_os"],
          :version => Raven.sys_command("uname -v"),
          :build => Raven.sys_command("uname -r"),
          :kernel_version => Raven.sys_command("uname -a") || Raven.sys_command("ver") # windows
        }
      end

      def runtime_context
        @runtime_context ||= {
          :name => RbConfig::CONFIG["ruby_install_name"],
          :version => Raven.sys_command("ruby -v")
        }
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
sentry-raven-2.6.3 lib/raven/context.rb
sentry-raven-2.6.2 lib/raven/context.rb
sentry-raven-2.6.1 lib/raven/context.rb
sentry-raven-2.6.0 lib/raven/context.rb
sentry-raven-2.5.3 lib/raven/context.rb
sentry-raven-2.5.2 lib/raven/context.rb
sentry-raven-2.5.1 lib/raven/context.rb
sentry-raven-2.5.0 lib/raven/context.rb
sentry-raven-2.4.0 lib/raven/context.rb
sentry-raven-2.3.1 lib/raven/context.rb
sentry-raven-2.3.0 lib/raven/context.rb
sentry-raven-2.2.0 lib/raven/context.rb
sentry-raven-2.1.4 lib/raven/context.rb