sentry-ruby 0.1.2 → 4.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4cd10cdc1a28f396af641980c7440ab8fc74648a2ebe1364e81d137af7a8d832
4
- data.tar.gz: d96bebca93ed6d16fc4bc1a7c6f14a53f33ebf84f4d6197ce79ee344bd2a0056
3
+ metadata.gz: 732989200a2cbf0a935c386cf84037d655332953ea2fef828099fbf68b756ab9
4
+ data.tar.gz: 4aecc66958496eede273d4cc4b2e3861e0ce7eb3cf769912a4a6675efeba693e
5
5
  SHA512:
6
- metadata.gz: bacf5d66a156684b3dcf3048806ffab6b53f3172a146626a4b28e4a80d1c933a729ee813a933052a425d86d3c58ce04b8409a55ba0b3fe76c45cce3defc8a6f0
7
- data.tar.gz: 756550d44dd6765e478ae2922f69c2098121c3ae290dd99345805d5690281021683146b54e999b77ed82b82330f40b5ec7e57b172a39741e4023c911c9867cb0
6
+ metadata.gz: 798be41100ec3c8eb09039f9432df02fd0de323427fd0d8bf6d9ced8f7b39d420e972c6006bcb4490002e32f03acfad2311b8ddab826c6927bd53b2a7316c7cb
7
+ data.tar.gz: 78cc7ec6d5c1a7f6603f9f2e4917b26e12ad5b13c0387a00645282acf8c910518c4132c171e2c9a8311f11e82afa3eb0454d2102bf48abd4c44d6625fd4ce4cf
@@ -1,5 +1,30 @@
1
1
  # Changelog
2
2
 
3
+ ## 4.0.1
4
+
5
+ - Add rake integration: [1137](https://github.com/getsentry/sentry-ruby/pull/1137)
6
+ - Make Event's interfaces accessible: [1135](https://github.com/getsentry/sentry-ruby/pull/1135)
7
+ - ActiveSupportLogger should only record events that has a started time: [1132](https://github.com/getsentry/sentry-ruby/pull/1132)
8
+
9
+ ## 4.0.0
10
+
11
+ - Only documents update for the official release and no API/feature changes.
12
+
13
+ ## 0.3.0
14
+
15
+ - Major API changes: [1123](https://github.com/getsentry/sentry-ruby/pull/1123)
16
+ - Support event hint: [1122](https://github.com/getsentry/sentry-ruby/pull/1122)
17
+ - Add request-id tag to events: [1120](https://github.com/getsentry/sentry-ruby/pull/1120) (by @tvec)
18
+
19
+ ## 0.2.0
20
+
21
+ - Multiple fixes and refactorings
22
+ - Tracing support
23
+
24
+ ## 0.1.3
25
+
26
+ Fix require reference
27
+
3
28
  ## 0.1.2
4
29
 
5
30
  - Fix: Fix async callback [1098](https://github.com/getsentry/sentry-ruby/pull/1098)
data/Gemfile CHANGED
@@ -9,3 +9,8 @@ gem "codecov"
9
9
 
10
10
  gem "pry"
11
11
  gem "rack"
12
+
13
+ gem "benchmark-ips"
14
+ gem "benchmark_driver"
15
+ gem "benchmark-ipsa"
16
+ gem "benchmark-memory"
data/README.md CHANGED
@@ -7,6 +7,8 @@
7
7
 
8
8
  # sentry-ruby, the Ruby Client for Sentry
9
9
 
10
+ **The old `sentry-raven` client has entered maintenance mode and was moved to [here](https://github.com/getsentry/sentry-ruby/tree/master/sentry-raven).**
11
+
10
12
  ---
11
13
 
12
14
 
@@ -17,7 +19,7 @@
17
19
  [![SemVer](https://api.dependabot.com/badges/compatibility_score?dependency-name=sentry-ruby&package-manager=bundler&version-scheme=semver)](https://dependabot.com/compatibility-score.html?dependency-name=sentry-ruby&package-manager=bundler&version-scheme=semver)
18
20
 
19
21
 
20
- [Documentation](https://docs.sentry.io/clients/ruby/) | [Bug Tracker](https://github.com/getsentry/sentry-ruby/issues) | [Forum](https://forum.sentry.io/) | IRC: irc.freenode.net, #sentry
22
+ [Documentation](https://docs.sentry.io/platforms/ruby/) | [Bug Tracker](https://github.com/getsentry/sentry-ruby/issues) | [Forum](https://forum.sentry.io/) | IRC: irc.freenode.net, #sentry
21
23
 
22
24
  The official Ruby-language client and integration layer for the [Sentry](https://github.com/getsentry/sentry) error reporting API.
23
25
 
@@ -26,6 +28,10 @@ The official Ruby-language client and integration layer for the [Sentry](https:/
26
28
 
27
29
  We test on Ruby 2.4, 2.5, 2.6 and 2.7 at the latest patchlevel/teeny version. We also support JRuby 9.0.
28
30
 
31
+ ## Migrate From sentry-raven
32
+
33
+ If you're using `sentry-raven`, we recommend you to migrate to this new SDK. You can find the benefits of migrating and how to do it in our [migration guide](https://docs.sentry.io/platforms/ruby/migration/).
34
+
29
35
  ## Getting Started
30
36
 
31
37
  ### Install
@@ -70,17 +76,47 @@ Sentry.init do |config|
70
76
  end
71
77
  ```
72
78
 
79
+ ### Performance Monitoring
80
+
81
+ You can activate performance monitoring by enabling traces sampling:
82
+
83
+ ```ruby
84
+ Sentry.init do |config|
85
+ # set a uniform sample rate between 0.0 and 1.0
86
+ config.traces_sample_rate = 0.2
87
+
88
+ # or control sampling dynamically
89
+ config.traces_sampler = lambda do |sampling_context|
90
+ # sampling_context[:transaction_context] contains the information about the transaction
91
+ # sampling_context[:parent_sampled] contains the transaction's parent's sample decision
92
+ true # return value can be a boolean or a float between 0.0 and 1.0
93
+ end
94
+ end
95
+ ```
96
+
97
+ To lean more about performance monitoring, please visit the [official documentation](https://docs.sentry.io/platforms/ruby/performance).
98
+
73
99
  ### Usage
74
100
 
75
101
  `sentry-ruby` has a default integration with `Rack`, so you only need to use the middleware in your application like:
76
102
 
77
- ```
78
- require 'rack'
79
- require 'sentry'
103
+ ```ruby
104
+ require 'sentry-ruby'
80
105
 
81
- use Sentry::Rack::CaptureException
106
+ Sentry.init do |config|
107
+ config.dsn = 'https://examplePublicKey@o0.ingest.sentry.io/0'
108
+
109
+ # To activate performance monitoring, set one of these options.
110
+ # We recommend adjusting the value in production:
111
+ config.traces_sample_rate = 0.5
112
+ # or
113
+ config.traces_sampler = lambda do |context|
114
+ true
115
+ end
116
+ end
82
117
 
83
- run theapp
118
+ use Sentry::Rack::Tracing # this needs to be placed first
119
+ use Sentry::Rack::CaptureException
84
120
  ```
85
121
 
86
122
  Otherwise, Sentry you can always use the capture helpers manually
@@ -148,6 +184,16 @@ end
148
184
  Sentry.capture_exception(exception) # the event will carry all those information now
149
185
  ```
150
186
 
187
+ Or use top-level setters
188
+
189
+
190
+ ```ruby
191
+ Sentry.set_user(id: 1, email: "test@example.com")
192
+ Sentry.set_tags(tag_1: "foo", tag_2: "bar")
193
+ Sentry.set_extras(order_number: 1234, tickets_count: 4)
194
+
195
+ ```
196
+
151
197
  Or build up a temporary scope for local information:
152
198
 
153
199
  ```ruby
@@ -172,7 +218,7 @@ Sentry.capture_exception(exception, tags: {foo: "bar"})
172
218
 
173
219
  ## More Information
174
220
 
175
- * [Documentation](https://docs.sentry.io/clients/ruby/)
221
+ * [Documentation](https://docs.sentry.io/platforms/ruby/)
176
222
  * [Bug Tracker](https://github.com/getsentry/sentry-ruby/issues)
177
223
  * [Forum](https://forum.sentry.io/)
178
224
  - [Discord](https://discord.gg/ez5KZN7)
data/Rakefile CHANGED
@@ -1,6 +1,8 @@
1
1
  require "bundler/gem_tasks"
2
2
  require "rspec/core/rake_task"
3
3
 
4
- RSpec::Core::RakeTask.new(:spec)
4
+ RSpec::Core::RakeTask.new(:spec).tap do |task|
5
+ task.rspec_opts = "--order rand"
6
+ end
5
7
 
6
8
  task :default => :spec
@@ -1,11 +1,25 @@
1
+ require "forwardable"
2
+
1
3
  require "sentry/version"
2
4
  require "sentry/core_ext/object/deep_dup"
3
5
  require "sentry/configuration"
4
6
  require "sentry/logger"
5
7
  require "sentry/event"
8
+ require "sentry/transaction_event"
9
+ require "sentry/span"
10
+ require "sentry/transaction"
6
11
  require "sentry/hub"
7
12
  require "sentry/rack"
8
13
 
14
+ def safely_require(lib)
15
+ begin
16
+ require lib
17
+ rescue LoadError
18
+ end
19
+ end
20
+
21
+ safely_require "sentry/rake"
22
+
9
23
  module Sentry
10
24
  class Error < StandardError
11
25
  end
@@ -20,7 +34,15 @@ module Sentry
20
34
  META
21
35
  end
22
36
 
37
+ def self.utc_now
38
+ Time.now.utc
39
+ end
40
+
23
41
  class << self
42
+ extend Forwardable
43
+
44
+ def_delegators :get_current_scope, :set_tags, :set_extras, :set_user
45
+
24
46
  def init(&block)
25
47
  config = Configuration.new
26
48
  yield(config)
@@ -39,8 +61,8 @@ module Sentry
39
61
  configuration.logger
40
62
  end
41
63
 
42
- def breadcrumbs
43
- get_current_scope.breadcrumbs
64
+ def add_breadcrumb(breadcrumb, &block)
65
+ get_current_scope.breadcrumbs.record(breadcrumb, &block)
44
66
  end
45
67
 
46
68
  def configuration
@@ -92,6 +114,10 @@ module Sentry
92
114
  get_current_hub.capture_message(message, **options, &block)
93
115
  end
94
116
 
117
+ def start_transaction(**options)
118
+ get_current_hub.start_transaction(**options)
119
+ end
120
+
95
121
  def last_event_id
96
122
  get_current_hub.last_event_id
97
123
  end
@@ -0,0 +1,14 @@
1
+ module Sentry
2
+ class BenchmarkTransport < Transport
3
+ attr_accessor :events
4
+
5
+ def initialize(*)
6
+ super
7
+ @events = []
8
+ end
9
+
10
+ def send_event(event)
11
+ @events << encode(event.to_hash)
12
+ end
13
+ end
14
+ end
@@ -2,13 +2,13 @@ module Sentry
2
2
  class Breadcrumb
3
3
  attr_accessor :category, :data, :message, :level, :timestamp, :type
4
4
 
5
- def initialize
6
- @category = nil
7
- @data = {}
8
- @level = nil
9
- @message = nil
10
- @timestamp = Time.now.to_i
11
- @type = nil
5
+ def initialize(category: nil, data: nil, message: nil, timestamp: nil, level: nil, type: nil)
6
+ @category = category
7
+ @data = data || {}
8
+ @level = level
9
+ @message = message
10
+ @timestamp = timestamp || Sentry.utc_now.to_i
11
+ @type = type
12
12
  end
13
13
 
14
14
  def to_hash
@@ -58,17 +58,15 @@ module Sentry
58
58
  last_crumb = current_breadcrumbs.peek
59
59
  # try to avoid dupes from logger broadcasts
60
60
  if last_crumb.nil? || last_crumb.message != message
61
- current_breadcrumbs.record do |crumb|
62
- crumb.level = Sentry::Breadcrumb::SentryLogger::LEVELS.fetch(severity, nil)
63
- crumb.category = category
64
- crumb.message = message
65
- crumb.type =
66
- if severity >= 3
67
- "error"
68
- else
69
- crumb.level
70
- end
71
- end
61
+ level = Sentry::Breadcrumb::SentryLogger::LEVELS.fetch(severity, nil)
62
+ crumb = Sentry::Breadcrumb.new(
63
+ level: level,
64
+ category: category,
65
+ message: message,
66
+ type: severity >= 3 ? "error" : level
67
+ )
68
+
69
+ Sentry.add_breadcrumb(crumb)
72
70
  end
73
71
  end
74
72
 
@@ -80,21 +78,7 @@ module Sentry
80
78
  end
81
79
 
82
80
  def current_breadcrumbs
83
- Sentry.breadcrumbs
84
- end
85
- end
86
- module OldBreadcrumbsSentryLogger
87
- def self.included(base)
88
- base.class_eval do
89
- include Sentry::Breadcrumbs::SentryLogger
90
- alias_method :add_without_sentry, :add
91
- alias_method :add, :add_with_sentry
92
- end
93
- end
94
-
95
- def add_with_sentry(*args)
96
- add_breadcrumb(*args)
97
- add_without_sentry(*args)
81
+ Sentry.get_current_scope.breadcrumbs
98
82
  end
99
83
  end
100
84
  end
@@ -10,11 +10,8 @@ module Sentry
10
10
  @buffer = Array.new(size)
11
11
  end
12
12
 
13
- def record(crumb = nil)
14
- if block_given?
15
- crumb = Breadcrumb.new if crumb.nil?
16
- yield(crumb)
17
- end
13
+ def record(crumb)
14
+ yield(crumb) if block_given?
18
15
  @buffer.slice!(0)
19
16
  @buffer << crumb
20
17
  end
@@ -20,8 +20,8 @@ module Sentry
20
20
  end
21
21
  end
22
22
 
23
- def capture_event(event, scope)
24
- scope.apply_to_event(event)
23
+ def capture_event(event, scope, hint = nil)
24
+ scope.apply_to_event(event, hint)
25
25
 
26
26
  if configuration.async?
27
27
  begin
@@ -30,10 +30,10 @@ module Sentry
30
30
  configuration.async.call(event.to_json_compatible)
31
31
  rescue => e
32
32
  configuration.logger.error(LOGGER_PROGNAME) { "async event sending failed: #{e.message}" }
33
- send_event(event)
33
+ send_event(event, hint)
34
34
  end
35
35
  else
36
- send_event(event)
36
+ send_event(event, hint)
37
37
  end
38
38
 
39
39
  event
@@ -51,8 +51,20 @@ module Sentry
51
51
  Event.new(configuration: configuration, message: message)
52
52
  end
53
53
 
54
+ def event_from_transaction(transaction)
55
+ TransactionEvent.new(configuration: configuration).tap do |event|
56
+ event.transaction = transaction.name
57
+ event.contexts.merge!(trace: transaction.get_trace_context)
58
+ event.timestamp = transaction.timestamp
59
+ event.start_timestamp = transaction.start_timestamp
60
+
61
+ finished_spans = transaction.span_recorder.spans.select { |span| span.timestamp && span != transaction }
62
+ event.spans = finished_spans.map(&:to_hash)
63
+ end
64
+ end
65
+
54
66
  def send_event(event, hint = nil)
55
- return false unless configuration.sending_allowed?(event)
67
+ return false unless configuration.sending_allowed?
56
68
 
57
69
  event = configuration.before_send.call(event, hint) if configuration.before_send
58
70
  if event.nil?
@@ -15,6 +15,28 @@ module Sentry
15
15
  attr_reader :async
16
16
  alias async? async
17
17
 
18
+ # a proc/lambda that takes an array of stack traces
19
+ # it'll be used to silence (reduce) backtrace of the exception
20
+ #
21
+ # for example:
22
+ #
23
+ # ```ruby
24
+ # Sentry.configuration.backtrace_cleanup_callback = lambda do |backtrace|
25
+ # Rails.backtrace_cleaner.clean(backtrace)
26
+ # end
27
+ # ```
28
+ #
29
+ attr_accessor :backtrace_cleanup_callback
30
+
31
+ # Optional Proc, called before sending an event to the server/
32
+ # E.g.: lambda { |event| event }
33
+ # E.g.: lambda { |event| nil }
34
+ # E.g.: lambda { |event|
35
+ # event[:message] = 'a'
36
+ # event
37
+ # }
38
+ attr_reader :before_send
39
+
18
40
  # An array of breadcrumbs loggers to be used. Available options are:
19
41
  # - :sentry_logger
20
42
  # - :active_support_logger
@@ -24,10 +46,13 @@ module Sentry
24
46
  attr_accessor :context_lines
25
47
 
26
48
  # RACK_ENV by default.
27
- attr_reader :current_environment
49
+ attr_reader :environment
50
+
51
+ # the dsn value, whether it's set via `config.dsn=` or `ENV["SENTRY_DSN"]`
52
+ attr_reader :dsn
28
53
 
29
- # Whitelist of environments that will send notifications to Sentry. Array of Strings.
30
- attr_accessor :environments
54
+ # Whitelist of enabled_environments that will send notifications to Sentry. Array of Strings.
55
+ attr_accessor :enabled_environments
31
56
 
32
57
  # Logger 'progname's to exclude from breadcrumbs
33
58
  attr_accessor :exclude_loggers
@@ -64,51 +89,36 @@ module Sentry
64
89
  # any events, and a value of 1.0 will send 100% of events.
65
90
  attr_accessor :sample_rate
66
91
 
67
- # a proc/lambda that takes an array of stack traces
68
- # it'll be used to silence (reduce) backtrace of the exception
69
- #
70
- # for example:
71
- #
72
- # ```ruby
73
- # Sentry.configuration.backtrace_cleanup_callback = lambda do |backtrace|
74
- # Rails.backtrace_cleaner.clean(backtrace)
75
- # end
76
- # ```
77
- #
78
- attr_accessor :backtrace_cleanup_callback
79
-
80
92
  # Include module versions in reports - boolean.
81
93
  attr_accessor :send_modules
82
94
 
95
+ # When send_default_pii's value is false (default), sensitive information like
96
+ # - user ip
97
+ # - user cookie
98
+ # - request body
99
+ # will not be sent to Sentry.
83
100
  attr_accessor :send_default_pii
84
101
 
85
102
  attr_accessor :server_name
86
103
 
87
- # Provide a configurable callback to determine event capture.
88
- # Note that the object passed into the block will be a String (messages) or
89
- # an exception.
90
- # e.g. lambda { |exc_or_msg| exc_or_msg.some_attr == false }
91
- attr_reader :should_capture
92
-
93
- # Silences ready message when true.
94
- attr_accessor :silence_ready
95
-
104
+ # Return a Transport::Configuration object for transport-related configurations.
96
105
  attr_reader :transport
97
106
 
98
- # Optional Proc, called before sending an event to the server/
99
- # E.g.: lambda { |event, hint| event }
100
- # E.g.: lambda { |event, hint| nil }
101
- # E.g.: lambda { |event, hint|
102
- # event[:message] = 'a'
103
- # event
104
- # }
105
- attr_reader :before_send
107
+ # Take a float between 0.0 and 1.0 as the sample rate for tracing events (transactions).
108
+ attr_accessor :traces_sample_rate
106
109
 
107
- # Errors object - an Array that contains error messages. See #
108
- attr_reader :errors
110
+ # Take a Proc that controls the sample rate for every tracing event, e.g.
111
+ # ```
112
+ # lambda do |tracing_context|
113
+ # # tracing_context[:transaction_context] contains the information about the transaction
114
+ # # tracing_context[:parent_sampled] contains the transaction's parent's sample decision
115
+ # true # return value can be a boolean or a float between 0.0 and 1.0
116
+ # end
117
+ # ```
118
+ attr_accessor :traces_sampler
109
119
 
110
- # the dsn value, whether it's set via `config.dsn=` or `ENV["SENTRY_DSN"]`
111
- attr_reader :dsn
120
+ # these are not config options
121
+ attr_reader :errors, :gem_specs
112
122
 
113
123
  # Most of these errors generate 4XX responses. In general, Sentry clients
114
124
  # only automatically report 5xx responses.
@@ -138,8 +148,8 @@ module Sentry
138
148
  self.async = false
139
149
  self.breadcrumbs_logger = []
140
150
  self.context_lines = 3
141
- self.current_environment = current_environment_from_env
142
- self.environments = []
151
+ self.environment = environment_from_env
152
+ self.enabled_environments = []
143
153
  self.exclude_loggers = []
144
154
  self.excluded_exceptions = IGNORE_DEFAULT.dup
145
155
  self.inspect_exception_causes_for_exclusion = false
@@ -153,11 +163,12 @@ module Sentry
153
163
  self.send_default_pii = false
154
164
  self.dsn = ENV['SENTRY_DSN']
155
165
  self.server_name = server_name_from_env
156
- self.should_capture = false
157
166
 
158
- @transport = Transport::Configuration.new
159
167
  self.before_send = false
160
168
  self.rack_env_whitelist = RACK_ENV_WHITELIST_DEFAULT
169
+
170
+ @transport = Transport::Configuration.new
171
+ @gem_specs = Hash[Gem::Specification.map { |spec| [spec.name, spec.version.to_s] }] if Gem::Specification.respond_to?(:map)
161
172
  post_initialization_callback
162
173
  end
163
174
 
@@ -195,14 +206,6 @@ module Sentry
195
206
  @breadcrumbs_logger = logger
196
207
  end
197
208
 
198
- def should_capture=(value)
199
- unless value == false || value.respond_to?(:call)
200
- raise ArgumentError, "should_capture must be callable (or false to disable)"
201
- end
202
-
203
- @should_capture = value
204
- end
205
-
206
209
  def before_send=(value)
207
210
  unless value == false || value.respond_to?(:call)
208
211
  raise ArgumentError, "before_send must be callable (or false to disable)"
@@ -211,31 +214,21 @@ module Sentry
211
214
  @before_send = value
212
215
  end
213
216
 
214
- # Allows config options to be read like a hash
215
- #
216
- # @param [Symbol] option Key for a given attribute
217
- def [](option)
218
- public_send(option)
217
+ def environment=(environment)
218
+ @environment = environment.to_s
219
219
  end
220
220
 
221
- def current_environment=(environment)
222
- @current_environment = environment.to_s
223
- end
224
-
225
- def capture_allowed?(message_or_exc = nil)
221
+ def sending_allowed?
226
222
  @errors = []
227
223
 
228
224
  valid? &&
229
- capture_in_current_environment? &&
230
- capture_allowed_by_callback?(message_or_exc) &&
225
+ capture_in_environment? &&
231
226
  sample_allowed?
232
227
  end
233
- # If we cannot capture, we cannot send.
234
- alias sending_allowed? capture_allowed?
235
228
 
236
229
  def error_messages
237
- @errors = [errors[0]] + errors[1..-1].map(&:downcase) # fix case of all but first
238
- errors.join(", ")
230
+ @errors = [@errors[0]] + @errors[1..-1].map(&:downcase) # fix case of all but first
231
+ @errors.join(", ")
239
232
  end
240
233
 
241
234
  def project_root=(root_dir)
@@ -256,7 +249,11 @@ module Sentry
256
249
  end
257
250
 
258
251
  def enabled_in_current_env?
259
- environments.empty? || environments.include?(current_environment)
252
+ enabled_environments.empty? || enabled_environments.include?(environment)
253
+ end
254
+
255
+ def tracing_enabled?
256
+ !!((@traces_sample_rate && @traces_sample_rate > 0.0) || @traces_sampler)
260
257
  end
261
258
 
262
259
  private
@@ -279,13 +276,17 @@ module Sentry
279
276
  end
280
277
 
281
278
  def excluded_exception?(incoming_exception)
282
- excluded_exceptions.any? do |excluded_exception|
283
- matches_exception?(get_exception_class(excluded_exception), incoming_exception)
279
+ excluded_exception_classes.any? do |excluded_exception|
280
+ matches_exception?(excluded_exception, incoming_exception)
284
281
  end
285
282
  end
286
283
 
284
+ def excluded_exception_classes
285
+ @excluded_exception_classes ||= excluded_exceptions.map { |e| get_exception_class(e) }
286
+ end
287
+
287
288
  def get_exception_class(x)
288
- x.is_a?(Module) ? x : qualified_const_get(x)
289
+ x.is_a?(Module) ? x : safe_const_get(x)
289
290
  end
290
291
 
291
292
  def matches_exception?(excluded_exception_class, incoming_exception)
@@ -296,14 +297,9 @@ module Sentry
296
297
  end
297
298
  end
298
299
 
299
- # In Ruby <2.0 const_get can't lookup "SomeModule::SomeClass" in one go
300
- def qualified_const_get(x)
301
- x = x.to_s
302
- if !x.match(/::/)
303
- Object.const_get(x)
304
- else
305
- x.split(MODULE_SEPARATOR).reject(&:empty?).inject(Object) { |a, e| a.const_get(e) }
306
- end
300
+ def safe_const_get(x)
301
+ x = x.to_s unless x.is_a?(String)
302
+ Object.const_get(x)
307
303
  rescue NameError # There's no way to safely ask if a constant exist for an unknown string
308
304
  nil
309
305
  end
@@ -339,17 +335,10 @@ module Sentry
339
335
  ENV['SENTRY_RELEASE']
340
336
  end
341
337
 
342
- def capture_in_current_environment?
338
+ def capture_in_environment?
343
339
  return true if enabled_in_current_env?
344
340
 
345
- @errors << "Not configured to send/capture in environment '#{current_environment}'"
346
- false
347
- end
348
-
349
- def capture_allowed_by_callback?(message_or_exc)
350
- return true if !should_capture || message_or_exc.nil? || should_capture.call(message_or_exc)
351
-
352
- @errors << "should_capture returned false"
341
+ @errors << "Not configured to send/capture in environment '#{environment}'"
353
342
  false
354
343
  end
355
344
 
@@ -380,7 +369,7 @@ module Sentry
380
369
  Socket.gethostbyname(hostname).first rescue server_name
381
370
  end
382
371
 
383
- def current_environment_from_env
372
+ def environment_from_env
384
373
  ENV['SENTRY_CURRENT_ENV'] || ENV['SENTRY_ENVIRONMENT'] || ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'default'
385
374
  end
386
375