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

Returns a new instance of Context.



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

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

Instance Attribute Details

#extraObject

Returns the value of attribute extra.



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

def extra
  @extra
end

#osObject

Returns the value of attribute os.



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

def os
  @os
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

#tagsObject

Returns the value of attribute tags.



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

def tags
  @tags
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



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

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



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

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