koderift-rails 1.3.4 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -4,6 +4,11 @@ require 'koderift/rails/version'
4
4
  require 'koderift/rails/configuration'
5
5
  require 'koderift/rails/instrumentation'
6
6
  require 'koderift/rails/lograge_config'
7
+ require 'koderift/rails/event'
8
+ require 'koderift/rails/breadcrumb'
9
+ require 'koderift/rails/scope'
10
+ require 'koderift/rails/capture'
11
+ require 'koderift/rails/tracing'
7
12
  require 'koderift/rails/controller'
8
13
  require 'koderift/rails/rum_helper'
9
14
  require 'koderift/rails/railtie' if defined?(::Rails::Railtie)
@@ -21,7 +26,188 @@ module Koderift
21
26
 
22
27
  def reset!
23
28
  @configuration = Configuration.new
29
+ Capture.reset_rate_limiter!
30
+ Scope.reset!
31
+ Breadcrumbs.clear
24
32
  end
33
+
34
+ # ---------------------------------------------------------------- capture
35
+
36
+ def capture_exception(error, **options, &block)
37
+ Capture.exception(error, **options, &block)
38
+ end
39
+
40
+ def capture_message(text, **options, &block)
41
+ Capture.message(text, **options, &block)
42
+ end
43
+
44
+ def capture_event(event)
45
+ Capture.event(event)
46
+ end
47
+
48
+ def last_event_id
49
+ Capture.last_event_id
50
+ end
51
+
52
+ def initialized?
53
+ Capture.initialized?
54
+ end
55
+
56
+ def exception_captured?(error)
57
+ Capture.exception_captured?(error)
58
+ end
59
+
60
+ # ------------------------------------------------------------------ scope
61
+
62
+ def get_current_scope
63
+ Scope.current
64
+ end
65
+
66
+ def configure_scope
67
+ yield Scope.current if block_given?
68
+ Scope.current
69
+ end
70
+
71
+ def with_scope
72
+ Scope.push
73
+ begin
74
+ yield Scope.current
75
+ ensure
76
+ Scope.pop
77
+ end
78
+ end
79
+
80
+ def set_user(user)
81
+ Scope.current.set_user(user)
82
+ end
83
+
84
+ def set_tags(tags)
85
+ Scope.current.set_tags(tags)
86
+ end
87
+
88
+ def set_tag(key, value)
89
+ Scope.current.set_tag(key, value)
90
+ end
91
+
92
+ def set_extras(extras)
93
+ Scope.current.set_extras(extras)
94
+ end
95
+
96
+ def set_extra(key, value)
97
+ Scope.current.set_extra(key, value)
98
+ end
99
+
100
+ def set_context(key, value)
101
+ Scope.current.set_context(key, value)
102
+ end
103
+
104
+ def add_breadcrumb(crumb)
105
+ Breadcrumbs.add(crumb)
106
+ end
107
+
108
+ # ---------------------------------------------------------------- tracing
109
+
110
+ def start_transaction(name: nil, op: nil, &block)
111
+ Tracing.start_transaction(name: name, op: op, &block)
112
+ end
113
+
114
+ def with_child_span(op: nil, description: nil, &block)
115
+ Tracing.with_child_span(op: op, description: description, &block)
116
+ end
117
+ end
118
+ end
119
+
120
+ # Sentry-shaped constant, so `Sentry::Breadcrumb.new(...)` becomes
121
+ # `Koderift::Breadcrumb.new(...)` under the same find-and-replace that
122
+ # rewrites the method calls.
123
+ Breadcrumb = Rails::Breadcrumb
124
+
125
+ # The migration surface. An app instrumented with Sentry swaps the namespace
126
+ # and keeps its call sites, including the idiom this API was built for:
127
+ #
128
+ # event_id = Koderift.capture_exception(error)&.event_id
129
+ #
130
+ # Delegators are written out rather than metaprogrammed so the signatures are
131
+ # greppable and `method(:capture_exception).parameters` tells the truth.
132
+ class << self
133
+ def capture_exception(error, **options, &block)
134
+ Rails.capture_exception(error, **options, &block)
135
+ end
136
+
137
+ def capture_message(text, **options, &block)
138
+ Rails.capture_message(text, **options, &block)
139
+ end
140
+
141
+ def capture_event(event)
142
+ Rails.capture_event(event)
143
+ end
144
+
145
+ def last_event_id
146
+ Rails.last_event_id
147
+ end
148
+
149
+ def initialized?
150
+ Rails.initialized?
151
+ end
152
+
153
+ def exception_captured?(error)
154
+ Rails.exception_captured?(error)
155
+ end
156
+
157
+ def get_current_scope
158
+ Rails.get_current_scope
159
+ end
160
+
161
+ def configure_scope(&block)
162
+ Rails.configure_scope(&block)
163
+ end
164
+
165
+ def with_scope(&block)
166
+ Rails.with_scope(&block)
167
+ end
168
+
169
+ def set_user(user)
170
+ Rails.set_user(user)
171
+ end
172
+
173
+ def set_tags(tags)
174
+ Rails.set_tags(tags)
175
+ end
176
+
177
+ def set_tag(key, value)
178
+ Rails.set_tag(key, value)
179
+ end
180
+
181
+ def set_extras(extras)
182
+ Rails.set_extras(extras)
183
+ end
184
+
185
+ def set_extra(key, value)
186
+ Rails.set_extra(key, value)
187
+ end
188
+
189
+ def set_context(key, value)
190
+ Rails.set_context(key, value)
191
+ end
192
+
193
+ def add_breadcrumb(crumb)
194
+ Rails.add_breadcrumb(crumb)
195
+ end
196
+
197
+ def start_transaction(name: nil, op: nil, &block)
198
+ Rails.start_transaction(name: name, op: op, &block)
199
+ end
200
+
201
+ def with_child_span(op: nil, description: nil, &block)
202
+ Rails.with_child_span(op: op, description: description, &block)
203
+ end
204
+
205
+ def configure(&block)
206
+ Rails.configure(&block)
207
+ end
208
+
209
+ def configuration
210
+ Rails.configuration
25
211
  end
26
212
  end
27
213
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: koderift-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.4
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Koderift
@@ -110,13 +110,19 @@ files:
110
110
  - README.md
111
111
  - lib/koderift-rails.rb
112
112
  - lib/koderift/rails.rb
113
+ - lib/koderift/rails/breadcrumb.rb
114
+ - lib/koderift/rails/capture.rb
113
115
  - lib/koderift/rails/configuration.rb
114
116
  - lib/koderift/rails/controller.rb
117
+ - lib/koderift/rails/event.rb
115
118
  - lib/koderift/rails/instrumentation.rb
116
119
  - lib/koderift/rails/lograge_config.rb
117
120
  - lib/koderift/rails/railtie.rb
121
+ - lib/koderift/rails/rake_integration.rb
118
122
  - lib/koderift/rails/rum_helper.rb
123
+ - lib/koderift/rails/scope.rb
119
124
  - lib/koderift/rails/sidekiq_middleware.rb
125
+ - lib/koderift/rails/tracing.rb
120
126
  - lib/koderift/rails/version.rb
121
127
  homepage: https://github.com/koderift/koderift-rails
122
128
  licenses: