This repository was archived by the owner on Feb 12, 2026. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontext.rb
More file actions
48 lines (42 loc) · 1.14 KB
/
context.rb
File metadata and controls
48 lines (42 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
require 'rbconfig'
require 'etc'
module Raven
class Context
def self.current
Thread.current[:sentry_context] ||= new
end
def self.clear!
Thread.current[:sentry_context] = nil
end
attr_accessor :transaction, :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 = {}
self.transaction = []
end
class << self
def os_context
@os_context ||=
begin
uname = Etc.uname
{
name: uname[:sysname] || RbConfig::CONFIG["host_os"],
version: uname[:version],
build: uname[:release],
kernel_version: uname[:version]
}
end
end
def runtime_context
@runtime_context ||= {
name: RbConfig::CONFIG["ruby_install_name"],
version: RUBY_DESCRIPTION || Raven.sys_command("ruby -v")
}
end
end
end
end