Class: Raven::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/raven/context.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeContext


15
16
17
18
19
20
21
22
23
# File 'lib/raven/context.rb', line 15

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 = {}
  self.transaction = []
end

Instance Attribute Details

#extraObject

Returns the value of attribute extra


13
14
15
# File 'lib/raven/context.rb', line 13

def extra
  @extra
end

#rack_envObject

Returns the value of attribute rack_env


13
14
15
# File 'lib/raven/context.rb', line 13

def rack_env
  @rack_env
end

#runtimeObject

Returns the value of attribute runtime


13
14
15
# File 'lib/raven/context.rb', line 13

def runtime
  @runtime
end

#server_osObject

Returns the value of attribute server_os


13
14
15
# File 'lib/raven/context.rb', line 13

def server_os
  @server_os
end

#tagsObject

Returns the value of attribute tags


13
14
15
# File 'lib/raven/context.rb', line 13

def tags
  @tags
end

#transactionObject

Returns the value of attribute transaction


13
14
15
# File 'lib/raven/context.rb', line 13

def transaction
  @transaction
end

#userObject

Returns the value of attribute user


13
14
15
# File 'lib/raven/context.rb', line 13

def user
  @user
end

Class Method Details

.clear!Object


9
10
11
# File 'lib/raven/context.rb', line 9

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

.currentObject


5
6
7
# File 'lib/raven/context.rb', line 5

def self.current
  Thread.current[:sentry_context] ||= new
end

.os_contextObject


26
27
28
29
30
31
32
33
# File 'lib/raven/context.rb', line 26

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

.runtime_contextObject


35
36
37
38
39
40
# File 'lib/raven/context.rb', line 35

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