Sha256: 46f0dc6c292a5f455db659fc5949e3b785896ac7c645164566dda75bdd27c035

Contents?: true

Size: 1015 Bytes

Versions: 2

Compression:

Stored size: 1015 Bytes

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, :os, :rack_env, :runtime, :tags, :user

    def initialize
      self.extra = {}
      self.os = self.class.os_context
      self.rack_env = nil
      self.runtime = self.class.runtime_context
      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", "ver")
        }
      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

2 entries across 2 versions & 1 rubygems

Version Path
sentry-raven-2.1.1 lib/raven/context.rb
sentry-raven-2.1.0 lib/raven/context.rb