@@ -36,15 +36,27 @@ module Sentry
36
36
37
37
THREAD_LOCAL = :sentry_hub
38
38
39
- def self . sdk_meta
40
- META
41
- end
39
+ class << self
40
+ attr_accessor :background_worker
42
41
43
- def self . utc_now
44
- Time . now . utc
45
- end
42
+ ##### Patch Registration #####
43
+ #
44
+ def register_patch ( &block )
45
+ registered_patches << block
46
+ end
46
47
47
- class << self
48
+ def apply_patches ( config )
49
+ registered_patches . each do |patch |
50
+ patch . call ( config )
51
+ end
52
+ end
53
+
54
+ def registered_patches
55
+ @registered_patches ||= [ ]
56
+ end
57
+
58
+ ##### Integrations #####
59
+ #
48
60
# Returns a hash that contains all the integrations that have been registered to the main SDK.
49
61
def integrations
50
62
@integrations ||= { }
@@ -55,32 +67,16 @@ def register_integration(name, version)
55
67
meta = { name : "sentry.ruby.#{ name } " , version : version } . freeze
56
68
integrations [ name . to_s ] = meta
57
69
end
58
- end
59
70
60
- class << self
71
+ ##### Method Delegation #####
72
+ #
61
73
extend Forwardable
62
74
63
75
def_delegators :get_current_client , :configuration , :send_event
64
76
def_delegators :get_current_scope , :set_tags , :set_extras , :set_user , :set_context
65
77
66
- attr_accessor :background_worker
67
-
68
- @@registered_patches = [ ]
69
-
70
- def register_patch ( &block )
71
- registered_patches << block
72
- end
73
-
74
- def apply_patches ( config )
75
- registered_patches . each do |patch |
76
- patch . call ( config )
77
- end
78
- end
79
-
80
- def registered_patches
81
- @@registered_patches
82
- end
83
-
78
+ ##### Main APIs #####
79
+ #
84
80
def init ( &block )
85
81
config = Configuration . new
86
82
yield ( config ) if block_given?
@@ -193,6 +189,9 @@ def last_event_id
193
189
get_current_hub &.last_event_id
194
190
end
195
191
192
+
193
+ ##### Helpers #####
194
+ #
196
195
def sys_command ( command )
197
196
result = `#{ command } 2>&1` rescue nil
198
197
return if result . nil? || result . empty? || ( $CHILD_STATUS && $CHILD_STATUS. exitstatus != 0 )
@@ -207,6 +206,14 @@ def initialized?
207
206
def logger
208
207
configuration . logger
209
208
end
209
+
210
+ def sdk_meta
211
+ META
212
+ end
213
+
214
+ def utc_now
215
+ Time . now . utc
216
+ end
210
217
end
211
218
end
212
219
0 commit comments