sentry-raven 3.0.3 → 3.0.4

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: 80521c1a75c0ad22be530ffd95d497c5faa6def9d88d21dceecf3b7dacecb7a8
4
- data.tar.gz: 1c1302782b979b2cf098ef0a90b71d69a65f733af2f95d588b4ae71e0ab67922
3
+ metadata.gz: e0e19bd3b705bd0a2c680d367ea7420941d5df1c5b245317170b9c31fd177006
4
+ data.tar.gz: f826cbfb501dfd844ff1096b8561ffc8a2e4f589d51d186ce063e4cfcabc65aa
5
5
  SHA512:
6
- metadata.gz: 0cd7c853ace426bd428037ea0cf436b781511beded44373fea677a06f58e7a6200f0ddad9d9777fb12468954b344e4035a7a275427a65ff38e6cb618317e7198
7
- data.tar.gz: ab5c38a374dc93fffa6baf9b9284795c3790e3db247848a9b39d7aa4902a3045375c24cea5e480cee25758bab96fe6f4c79c2fdae43c1f80ad25f171c443ba1f
6
+ metadata.gz: 8f47ca78fad6ebc47e9a76efd32e8009e6b8196256b06edef38dc1081a4eafb57f0f880e69d3e423ef5dffe6f66f2651c6c1fa2ca4002ad1c5be352b541bdfb3
7
+ data.tar.gz: f6e95e7a313ece5ebfb1af584d2cd11648575a6121a0ff0b807180e396bfb8102b1bc0cc1914d96e26058273193dbf6014c0acd6ded8dbef284cac6d0279ab79
@@ -2,6 +2,11 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 3.0.4
6
+
7
+ - fix: Don't log warning messages when it doesn't need to (#1000)
8
+ - fix: Revert "Refactor Raven::Client class" (#1002)
9
+
5
10
  ## 3.0.3
6
11
 
7
12
  - fix: Ensure Processor::Cookie can run after Processor::RemoveCircularReferences (#996)
data/README.md CHANGED
@@ -112,19 +112,28 @@ config.transport_failure_callback = lambda { |event|
112
112
 
113
113
  #### Context
114
114
 
115
- Much of the usefulness of Sentry comes from additional context data with the events. Raven makes this very convenient by providing methods to set thread local context data that is then submitted automatically with all events.
116
-
117
- There are three primary methods for providing request context:
115
+ Much of the usefulness of Sentry comes from additional context data with the events. Raven makes this very convenient by providing methods to set thread local context data that is then submitted automatically with all events:
118
116
 
119
117
  ```ruby
120
- # bind the logged in user
121
118
  Raven.user_context email: 'foo@example.com'
122
119
 
123
- # tag the request with something interesting
124
- Raven.tags_context interesting: 'yes'
120
+ Raven.tags.merge!(interesting: 'yes')
121
+
122
+ Raven.extra.merge!(additional_info: 'foo')
123
+ ```
124
+
125
+ You can also use `tags_context` and `extra_context` to provide scoped information:
126
+
127
+ ```ruby
128
+ Raven.tags_context(interesting: 'yes') do
129
+ # the `interesting: 'yes'` tag will only present in the requests sent inside the block
130
+ Raven.capture_exception(exception)
131
+ end
125
132
 
126
- # provide a bit of additional context
127
- Raven.extra_context happiness: 'very'
133
+ Raven.extra_context(additional_info: 'foo') do
134
+ # same as above, the `additional_info` will only present in this request
135
+ Raven.capture_exception(exception)
136
+ end
128
137
  ```
129
138
 
130
139
  For more information, see [Context](https://docs.sentry.io/clients/ruby/context/).
@@ -30,15 +30,18 @@ module Raven
30
30
  return
31
31
  end
32
32
 
33
+ # Convert to hash
34
+ event = event.to_hash
35
+
33
36
  unless @state.should_try?
34
37
  failed_send(nil, event)
35
38
  return
36
39
  end
37
40
 
38
- configuration.logger.info "Sending event #{event.event_id} to Sentry"
41
+ event_id = event[:event_id] || event['event_id']
42
+ configuration.logger.info "Sending event #{event_id} to Sentry"
39
43
 
40
- event_hash = event.to_hash
41
- content_type, encoded_data = encode(event_hash)
44
+ content_type, encoded_data = encode(event)
42
45
 
43
46
  begin
44
47
  transport.send_event(generate_auth_header, encoded_data,
@@ -49,7 +52,7 @@ module Raven
49
52
  return
50
53
  end
51
54
 
52
- event_hash
55
+ event
53
56
  end
54
57
 
55
58
  def transport
@@ -68,8 +71,8 @@ module Raven
68
71
 
69
72
  private
70
73
 
71
- def encode(event_hash)
72
- hash = @processors.reduce(event_hash) { |a, e| e.process(a) }
74
+ def encode(event)
75
+ hash = @processors.reduce(event.to_hash) { |a, e| e.process(a) }
73
76
  encoded = JSON.fast_generate(hash)
74
77
 
75
78
  case configuration.encoding
@@ -80,6 +83,22 @@ module Raven
80
83
  end
81
84
  end
82
85
 
86
+ def get_message_from_exception(event)
87
+ (
88
+ event &&
89
+ event[:exception] &&
90
+ event[:exception][:values] &&
91
+ event[:exception][:values][0] &&
92
+ event[:exception][:values][0][:type] &&
93
+ event[:exception][:values][0][:value] &&
94
+ "#{event[:exception][:values][0][:type]}: #{event[:exception][:values][0][:value]}"
95
+ )
96
+ end
97
+
98
+ def get_log_message(event)
99
+ (event && event[:message]) || (event && event['message']) || get_message_from_exception(event) || '<no message value>'
100
+ end
101
+
83
102
  def generate_auth_header
84
103
  now = Time.now.to_i.to_s
85
104
  fields = {
@@ -103,12 +122,10 @@ module Raven
103
122
  else
104
123
  configuration.logger.warn "Not sending event due to previous failure(s)."
105
124
  end
106
-
107
- event_message = event&.log_message || '<no message value>'
108
- configuration.logger.warn("Failed to submit event: #{event_message}")
125
+ configuration.logger.warn("Failed to submit event: #{get_log_message(event)}")
109
126
 
110
127
  # configuration.transport_failure_callback can be false & nil
111
- configuration.transport_failure_callback.call(event.to_hash) if configuration.transport_failure_callback # rubocop:disable Style/SafeNavigation
128
+ configuration.transport_failure_callback.call(event) if configuration.transport_failure_callback # rubocop:disable Style/SafeNavigation
112
129
  end
113
130
  end
114
131
 
@@ -342,6 +342,10 @@ module Raven
342
342
  end
343
343
  end
344
344
 
345
+ def enabled_in_current_env?
346
+ environments.empty? || environments.include?(current_environment)
347
+ end
348
+
345
349
  private
346
350
 
347
351
  def detect_project_root
@@ -423,7 +427,7 @@ module Raven
423
427
  end
424
428
 
425
429
  def capture_in_current_environment?
426
- return true unless environments.any? && !environments.include?(current_environment)
430
+ return true if enabled_in_current_env?
427
431
 
428
432
  @errors << "Not configured to send/capture in environment '#{current_environment}'"
429
433
  false
@@ -136,25 +136,6 @@ module Raven
136
136
  JSON.parse(JSON.generate(cleaned_hash))
137
137
  end
138
138
 
139
- def message_from_exception
140
- exception = @interfaces[:exception]
141
-
142
- return unless exception
143
-
144
- exception = exception.to_hash
145
-
146
- type = exception.dig(:values, 0, :type)
147
- value = exception.dig(:values, 0, :value)
148
-
149
- if type && value
150
- "#{type}: #{value}"
151
- end
152
- end
153
-
154
- def log_message
155
- message || message_from_exception
156
- end
157
-
158
139
  def add_exception_interface(exc)
159
140
  interface(:exception) do |exc_int|
160
141
  exceptions = Raven::Utils::ExceptionCauseChain.exception_to_array(exc).reverse
@@ -50,6 +50,7 @@ module Raven
50
50
 
51
51
  # Tell the log that the client is good to go
52
52
  def report_status
53
+ return unless configuration.enabled_in_current_env?
53
54
  return if configuration.silence_ready
54
55
 
55
56
  if configuration.capture_allowed?
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Raven
4
- VERSION = "3.0.3"
4
+ VERSION = "3.0.4"
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: 3.0.3
4
+ version: 3.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sentry Team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-08-27 00:00:00.000000000 Z
11
+ date: 2020-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday