raygun4ruby 2.1.0 → 2.2.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +1 -1
- data/lib/raygun.rb +37 -18
- data/lib/raygun/client.rb +4 -1
- data/lib/raygun/configuration.rb +7 -3
- data/lib/raygun/version.rb +1 -1
- data/raygun4ruby.gemspec +1 -0
- data/test/unit/client_test.rb +4 -4
- data/test/unit/configuration_test.rb +4 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f6e237c42f9f818bec75c11a19c4122cc7dbbcd
|
4
|
+
data.tar.gz: fe2879c2c31a4138ff3f38f41add405698bcb6c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41887a583b9417a02908eb9485df7d276d9c7be4e0bcaa4c2f1c77c3c4a439f004d51f254a6935fc0425399b6cac97c29bde3e295087fa9e6ee0b40e8167dabf
|
7
|
+
data.tar.gz: 4a15d7e5d04857888ad998795a32a55d206bcb76a6c888f4a68d70f693eeaee1e37da3bcd9996e3bc381c2d7747a31be0b71f16e60d7720c357c9b5b059920d5
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## 2.2.0
|
2
|
+
|
3
|
+
Features
|
4
|
+
- Opt in support for sending exceptions in a background thread to not block web request thread during IO ([#117](https://github.com/MindscapeHQ/raygun4ruby/pull/117))
|
5
|
+
|
6
|
+
Bugfixes
|
7
|
+
- Don't attempt to read raw data during GET requests or if rack.input buffer is empty
|
8
|
+
|
1
9
|
## 2.1.0
|
2
10
|
|
3
11
|
Features
|
data/README.md
CHANGED
@@ -33,7 +33,7 @@ You can then test your Raygun integration by running:
|
|
33
33
|
|
34
34
|
You should see an "ItWorksException" appear in your Raygun dashboard. You're ready to zap those errors!
|
35
35
|
|
36
|
-
NB: Raygun4Ruby currently requires Ruby >=
|
36
|
+
NB: Raygun4Ruby currently requires Ruby >= 2.0
|
37
37
|
|
38
38
|
Note that the generator will create a file in `config/initializers` called "raygun.rb". If you need to do any further configuration or customization of Raygun, that's the place to do it!
|
39
39
|
|
data/lib/raygun.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require "concurrent"
|
1
2
|
require "httparty"
|
2
3
|
require "logger"
|
3
4
|
require "json"
|
@@ -54,25 +55,10 @@ module Raygun
|
|
54
55
|
end
|
55
56
|
|
56
57
|
def track_exception(exception_instance, env = {}, user = nil, retry_count = 1)
|
57
|
-
if
|
58
|
-
|
59
|
-
Client.new.track_exception(exception_instance, env, user)
|
60
|
-
end
|
61
|
-
rescue Exception => e
|
62
|
-
if configuration.failsafe_logger
|
63
|
-
failsafe_log("Problem reporting exception to Raygun: #{e.class}: #{e.message}\n\n#{e.backtrace.join("\n")}")
|
64
|
-
end
|
65
|
-
|
66
|
-
if retry_count > 0
|
67
|
-
new_exception = e.exception("raygun4ruby encountered an exception processing your exception")
|
68
|
-
new_exception.set_backtrace(e.backtrace)
|
69
|
-
|
70
|
-
env[:custom_data] ||= {}
|
71
|
-
env[:custom_data].merge!(original_stacktrace: exception_instance.backtrace)
|
72
|
-
|
73
|
-
track_exception(new_exception, env, user, retry_count - 1)
|
58
|
+
if configuration.send_in_background
|
59
|
+
track_exception_async(exception_instance, env, user, retry_count)
|
74
60
|
else
|
75
|
-
|
61
|
+
track_exception_sync(exception_instance, env, user, retry_count)
|
76
62
|
end
|
77
63
|
end
|
78
64
|
|
@@ -122,6 +108,39 @@ module Raygun
|
|
122
108
|
|
123
109
|
private
|
124
110
|
|
111
|
+
def track_exception_async(*args)
|
112
|
+
future = Concurrent::Future.execute { track_exception_sync(*args) }
|
113
|
+
future.add_observer(lambda do |_, value, reason|
|
114
|
+
if value == nil || value.response.code != "202"
|
115
|
+
log("[Raygun] unexpected response from Raygun, could indicate error: #{value.inspect}")
|
116
|
+
end
|
117
|
+
end, :call)
|
118
|
+
end
|
119
|
+
|
120
|
+
def track_exception_sync(exception_instance, env, user, retry_count)
|
121
|
+
if should_report?(exception_instance)
|
122
|
+
log("[Raygun] Tracking Exception...")
|
123
|
+
Client.new.track_exception(exception_instance, env, user)
|
124
|
+
end
|
125
|
+
rescue Exception => e
|
126
|
+
if configuration.failsafe_logger
|
127
|
+
failsafe_log("Problem reporting exception to Raygun: #{e.class}: #{e.message}\n\n#{e.backtrace.join("\n")}")
|
128
|
+
end
|
129
|
+
|
130
|
+
if retry_count > 0
|
131
|
+
new_exception = e.exception("raygun4ruby encountered an exception processing your exception")
|
132
|
+
new_exception.set_backtrace(e.backtrace)
|
133
|
+
|
134
|
+
env[:custom_data] ||= {}
|
135
|
+
env[:custom_data].merge!(original_stacktrace: exception_instance.backtrace)
|
136
|
+
|
137
|
+
track_exception(new_exception, env, user, retry_count - 1)
|
138
|
+
else
|
139
|
+
raise e
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
143
|
+
|
125
144
|
def print_api_key_warning
|
126
145
|
$stderr.puts(NO_API_KEY_MESSAGE)
|
127
146
|
end
|
data/lib/raygun/client.rb
CHANGED
@@ -136,8 +136,11 @@ module Raygun
|
|
136
136
|
|
137
137
|
request = Rack::Request.new(rack_env)
|
138
138
|
input = rack_env['rack.input']
|
139
|
+
return if request.get?
|
139
140
|
|
140
|
-
|
141
|
+
# If size is 0 the buffer is at best empty and at worst
|
142
|
+
# something like the Puma::NullIO buffer which is missing methods
|
143
|
+
if input && input.size && !request.form_data?
|
141
144
|
current_position = input.pos
|
142
145
|
input.rewind
|
143
146
|
|
data/lib/raygun/configuration.rb
CHANGED
@@ -74,6 +74,9 @@ module Raygun
|
|
74
74
|
# form submissions and will not be filtered by the blacklist
|
75
75
|
config_option :record_raw_data
|
76
76
|
|
77
|
+
# Should the exceptions to Raygun be sent asynchronously?
|
78
|
+
config_option :send_in_background
|
79
|
+
|
77
80
|
# Exception classes to ignore by default
|
78
81
|
IGNORE_DEFAULT = ['ActiveRecord::RecordNotFound',
|
79
82
|
'ActionController::RoutingError',
|
@@ -111,7 +114,7 @@ module Raygun
|
|
111
114
|
@config_values = {}
|
112
115
|
|
113
116
|
# set default attribute values
|
114
|
-
@defaults = OpenStruct.new(
|
117
|
+
@defaults = OpenStruct.new(
|
115
118
|
ignore: IGNORE_DEFAULT,
|
116
119
|
custom_data: {},
|
117
120
|
tags: [],
|
@@ -125,8 +128,9 @@ module Raygun
|
|
125
128
|
debug: false,
|
126
129
|
api_url: 'https://api.raygun.io/',
|
127
130
|
breadcrumb_level: :info,
|
128
|
-
record_raw_data: false
|
129
|
-
|
131
|
+
record_raw_data: false,
|
132
|
+
send_in_background: false
|
133
|
+
)
|
130
134
|
end
|
131
135
|
|
132
136
|
def [](key)
|
data/lib/raygun/version.rb
CHANGED
data/raygun4ruby.gemspec
CHANGED
@@ -22,6 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_runtime_dependency "httparty", "> 0.13.7"
|
23
23
|
spec.add_runtime_dependency "json"
|
24
24
|
spec.add_runtime_dependency "rack"
|
25
|
+
spec.add_runtime_dependency "concurrent-ruby"
|
25
26
|
|
26
27
|
spec.add_development_dependency "bundler", ">= 1.1"
|
27
28
|
spec.add_development_dependency "rake", "0.9.6"
|
data/test/unit/client_test.rb
CHANGED
@@ -213,7 +213,7 @@ class ClientTest < Raygun::UnitTest
|
|
213
213
|
queryString: { "a" => "b", "c" => "4945438" },
|
214
214
|
headers: { "Version"=>"HTTP/1.1", "Host"=>"localhost:3000", "Cookie"=>"cookieval" },
|
215
215
|
form: {},
|
216
|
-
rawData:
|
216
|
+
rawData: nil
|
217
217
|
}
|
218
218
|
|
219
219
|
assert_equal expected_hash, @client.send(:request_information, env_hash)
|
@@ -550,7 +550,7 @@ class ClientTest < Raygun::UnitTest
|
|
550
550
|
queryString: { "a" => "b", "c" => "4945438" },
|
551
551
|
headers: { "Version"=>"HTTP/1.1", "Host"=>"localhost:3000", "Cookie"=>"cookieval" },
|
552
552
|
form: {},
|
553
|
-
rawData:
|
553
|
+
rawData: nil
|
554
554
|
}
|
555
555
|
|
556
556
|
details = @client.send(:build_payload_hash, test_exception, env_hash)[:details]
|
@@ -574,7 +574,7 @@ class ClientTest < Raygun::UnitTest
|
|
574
574
|
queryString: "[FILTERED]",
|
575
575
|
headers: { "Version"=>"HTTP/1.1", "Host"=>"localhost:3000", "Cookie"=>"cookieval" },
|
576
576
|
form: {},
|
577
|
-
rawData:
|
577
|
+
rawData: nil
|
578
578
|
}
|
579
579
|
|
580
580
|
details = @client.send(:build_payload_hash, test_exception, sample_env_hash)[:details]
|
@@ -597,7 +597,7 @@ class ClientTest < Raygun::UnitTest
|
|
597
597
|
queryString: { "a" => "b", "c" => "4945438" },
|
598
598
|
headers: { "Version"=>"HTTP/1.1", "Host"=>"localhost:3000", "Cookie"=>"cookieval" },
|
599
599
|
form: {},
|
600
|
-
rawData:
|
600
|
+
rawData: nil
|
601
601
|
}
|
602
602
|
|
603
603
|
details = @client.send(:build_payload_hash, test_exception, env_hash)[:details]
|
@@ -159,4 +159,8 @@ class ConfigurationTest < Raygun::UnitTest
|
|
159
159
|
def test_record_raw_data_default
|
160
160
|
assert_equal false, Raygun.configuration.record_raw_data
|
161
161
|
end
|
162
|
+
|
163
|
+
def test_send_in_background_default
|
164
|
+
assert_equal false, Raygun.configuration.send_in_background
|
165
|
+
end
|
162
166
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: raygun4ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mindscape
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-04
|
12
|
+
date: 2017-05-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
@@ -53,6 +53,20 @@ dependencies:
|
|
53
53
|
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: concurrent-ruby
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ">="
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
type: :runtime
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
56
70
|
- !ruby/object:Gem::Dependency
|
57
71
|
name: bundler
|
58
72
|
requirement: !ruby/object:Gem::Requirement
|