sentry-raven 1.2.0 → 1.2.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
  SHA1:
3
- metadata.gz: bd0a24e20bb50a520df079f36059cb0adb5d7673
4
- data.tar.gz: c89f6a2a4146c6ac291e527e7ec362f12a2e82eb
3
+ metadata.gz: e97702132902b09734d484062d95956e34c55e04
4
+ data.tar.gz: ca8d939ea7ff848249c6bcef9603bf31324a314b
5
5
  SHA512:
6
- metadata.gz: ddb34f4ff56c51af45e4c369f61f9a2a01e24107bc97eca694abbb1a501902cac5254fc912e1eb9e794b8d6c21beff0a49570bb1b114d748676b39cfb7862735
7
- data.tar.gz: b35f1609019436dd7f42ef6ed976f53bde10a15eab61b5c6a1bc362b99fa571e459913cafb02da7e1281ff366c70ba1a6a06ff8abf326fd455d1824f4a7cfe00
6
+ metadata.gz: 7b89c8cd9d4e2f28d8a83703d617a904b7cfca119f3a0bb3dbfff16d392307dbad7b6a37ffb844f136ce370e4c5b1f9a48069b2f86b172fa4d6afd3bbeea7d69
7
+ data.tar.gz: fd1da535f9f07a252ab08ca095beb0e863ae45d070074780e677dd56c51f74c1dfaae475ba62364ae90b3d905e3728f1ead572462266e6e988eefaa25a110eb6
@@ -34,7 +34,7 @@ module Raven
34
34
 
35
35
  def_delegators :instance, :client=, :configuration=, :context, :logger, :configuration,
36
36
  :client, :report_status, :configure, :send_event, :capture, :capture_type,
37
- :last_event_id, :should_capture?, :annotate_exception, :user_context,
37
+ :last_event_id, :annotate_exception, :user_context,
38
38
  :tags_context, :extra_context, :rack_context, :breadcrumbs
39
39
 
40
40
  def_delegator :instance, :report_status, :report_ready
@@ -14,7 +14,7 @@ module Raven
14
14
  Raven.configuration.dsn = dsn if dsn
15
15
 
16
16
  # wipe out env settings to ensure we send the event
17
- unless Raven.configuration.send_in_current_environment?
17
+ unless Raven.configuration.capture_in_current_environment?
18
18
  env_name = Raven.configuration.environments.pop || 'production'
19
19
  puts "Setting environment to #{env_name}"
20
20
  Raven.configuration.current_environment = env_name
@@ -22,7 +22,7 @@ module Raven
22
22
  end
23
23
 
24
24
  def send_event(event)
25
- return false unless configuration_allows_sending
25
+ return false unless configuration.sending_allowed?(event)
26
26
 
27
27
  # Convert to hash
28
28
  event = event.to_hash
@@ -62,15 +62,6 @@ module Raven
62
62
 
63
63
  private
64
64
 
65
- def configuration_allows_sending
66
- if configuration.send_in_current_environment?
67
- true
68
- else
69
- configuration.log_excluded_environment_message
70
- false
71
- end
72
- end
73
-
74
65
  def encode(event)
75
66
  hash = @processors.reduce(event.to_hash) { |memo, p| p.process(memo) }
76
67
  encoded = JSON.generate(hash)
@@ -215,12 +215,21 @@ module Raven
215
215
  @current_environment = environment.to_s
216
216
  end
217
217
 
218
- def send_in_current_environment?
218
+ def capture_allowed?(message_or_exc)
219
+ capture_in_current_environment? &&
220
+ capture_allowed_by_callback?(message_or_exc)
221
+ end
222
+
223
+ # If we cannot capture, we cannot send.
224
+ alias sending_allowed? capture_allowed?
225
+
226
+ def capture_in_current_environment?
219
227
  !!server && (environments.empty? || environments.include?(current_environment))
220
228
  end
221
229
 
222
- def log_excluded_environment_message
223
- Raven.logger.debug "Event not sent due to excluded environment: #{current_environment}"
230
+ def capture_allowed_by_callback?(message_or_exc)
231
+ return true unless should_capture
232
+ should_capture.call(*[message_or_exc])
224
233
  end
225
234
 
226
235
  def verify!
@@ -60,11 +60,11 @@ module Raven
60
60
 
61
61
  # Tell the log that the client is good to go
62
62
  def report_status
63
- return if client.configuration.silence_ready
64
- if client.configuration.send_in_current_environment?
63
+ return if configuration.silence_ready
64
+ if configuration.capture_in_current_environment?
65
65
  logger.info "Raven #{VERSION} ready to catch errors"
66
66
  else
67
- logger.info "Raven #{VERSION} configured not to send errors."
67
+ logger.info "Raven #{VERSION} configured not to capture errors."
68
68
  end
69
69
  end
70
70
 
@@ -113,7 +113,11 @@ module Raven
113
113
  end
114
114
 
115
115
  def capture_type(obj, options = {})
116
- return false unless should_capture?(obj)
116
+ unless configuration.capture_allowed?(obj)
117
+ Raven.logger.debug("#{obj} excluded from capture due to environment or should_capture callback")
118
+ return false
119
+ end
120
+
117
121
  message_or_exc = obj.is_a?(String) ? "message" : "exception"
118
122
  if (evt = Event.send("from_" + message_or_exc, obj, options))
119
123
  yield evt if block_given?
@@ -131,14 +135,6 @@ module Raven
131
135
  Thread.current["sentry_#{object_id}_last_event_id".to_sym]
132
136
  end
133
137
 
134
- def should_capture?(message_or_exc)
135
- if configuration.should_capture
136
- configuration.should_capture.call(*[message_or_exc])
137
- else
138
- true
139
- end
140
- end
141
-
142
138
  # Provides extra context to the exception prior to it being handled by
143
139
  # Raven. An exception can have multiple annotations, which are merged
144
140
  # together.
@@ -42,6 +42,9 @@ module Delayed
42
42
 
43
43
  # Make sure we propagate the failure!
44
44
  raise exception
45
+ ensure
46
+ Context.clear!
47
+ BreadcrumbBuffer.clear!
45
48
  end
46
49
  end
47
50
  end
@@ -41,10 +41,6 @@ module Raven
41
41
  end
42
42
 
43
43
  def call(env)
44
- # clear context at the beginning of the request to ensure a clean slate
45
- Context.clear!
46
- BreadcrumbBuffer.clear!
47
-
48
44
  # store the current environment in our local context for arbitrary
49
45
  # callers
50
46
  env['raven.requested_at'] = Time.now
@@ -64,6 +60,9 @@ module Raven
64
60
  Raven::Rack.capture_exception(error, env) if error
65
61
 
66
62
  response
63
+ ensure
64
+ Context.clear!
65
+ BreadcrumbBuffer.clear!
67
66
  end
68
67
  end
69
68
 
@@ -10,6 +10,9 @@ module Raven
10
10
  Raven.capture_exception(ex, :extra => { :sidekiq => msg },
11
11
  :time_spent => Time.now-started_at)
12
12
  raise
13
+ ensure
14
+ Context.clear!
15
+ BreadcrumbBuffer.clear!
13
16
  end
14
17
  end
15
18
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
  module Raven
3
3
  # Freezing this constant breaks in 1.9.x
4
- VERSION = "1.2.0" # rubocop:disable Style/MutableConstant
4
+ VERSION = "1.2.1" # rubocop:disable Style/MutableConstant
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sentry-raven
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sentry Team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-03 00:00:00.000000000 Z
11
+ date: 2016-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday