raygun4ruby 2.6.0 → 2.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/Rakefile +0 -2
- data/lib/raygun/client.rb +8 -1
- data/lib/raygun/configuration.rb +5 -1
- data/lib/raygun/version.rb +1 -1
- data/lib/raygun.rb +9 -2
- data/raygun4ruby.gemspec +2 -2
- data/specs/raygun/raygun_spec.rb +50 -0
- data/specs/spec_helper.rb +21 -1
- data/test/test_helper.rb +4 -8
- data/test/unit/configuration_test.rb +12 -0
- data/test/unit/resque_failure_test.rb +3 -1
- data/test/unit/sidekiq_failure_test.rb +3 -1
- metadata +19 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1975c19107e042426b56c91ca986207e3e17d681
|
4
|
+
data.tar.gz: 491657544cbb5537c01fc4483dd45a8282add25c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79eb83863ba93f963857e2a43af01e9daff5e13cd788a218db867a5a622e51a8ab119b16f546534f7f12b680c9e086fa0d524502306d04b17c95461a56046ab0
|
7
|
+
data.tar.gz: 2a4fc829d54fe4deb855283719f7432360854760cf1d78f06235f82304587d00ed2607e42ff7b6cafe9def75e3b0585d81aa0930a403de5861e5e35f881fe967
|
data/CHANGELOG.md
CHANGED
data/Rakefile
CHANGED
@@ -8,13 +8,11 @@ namespace :test do
|
|
8
8
|
desc "Test the basics of the adapter"
|
9
9
|
Rake::TestTask.new(:units) do |t|
|
10
10
|
t.test_files = FileList["test/unit/*_test.rb", "specs/**/*_spec.rb"]
|
11
|
-
t.verbose = true
|
12
11
|
end
|
13
12
|
|
14
13
|
desc "Run a test against the live API"
|
15
14
|
Rake::TestTask.new(:integration) do |t|
|
16
15
|
t.test_files = FileList["test/integration/*_test.rb"]
|
17
|
-
t.verbose = true
|
18
16
|
end
|
19
17
|
|
20
18
|
end
|
data/lib/raygun/client.rb
CHANGED
@@ -16,6 +16,7 @@ module Raygun
|
|
16
16
|
|
17
17
|
enable_http_proxy if Raygun.configuration.proxy_settings[:address]
|
18
18
|
self.class.base_uri Raygun.configuration.api_url
|
19
|
+
self.class.default_timeout(Raygun.configuration.error_report_send_timeout)
|
19
20
|
end
|
20
21
|
|
21
22
|
def require_api_key
|
@@ -242,7 +243,13 @@ module Raygun
|
|
242
243
|
def create_entry(payload_hash)
|
243
244
|
Raygun.log('sending payload to api')
|
244
245
|
|
245
|
-
self.class.post(
|
246
|
+
self.class.post(
|
247
|
+
"/entries",
|
248
|
+
verify_peer: true,
|
249
|
+
verify: true,
|
250
|
+
headers: @headers,
|
251
|
+
body: JSON.generate(payload_hash),
|
252
|
+
)
|
246
253
|
end
|
247
254
|
|
248
255
|
def filter_params_with_blacklist(params_hash = {}, extra_filter_keys = nil)
|
data/lib/raygun/configuration.rb
CHANGED
@@ -77,6 +77,9 @@ module Raygun
|
|
77
77
|
# Should the exceptions to Raygun be sent asynchronously?
|
78
78
|
config_option :send_in_background
|
79
79
|
|
80
|
+
# How long to wait for the POST request to the API server before timing out
|
81
|
+
config_option :error_report_send_timeout
|
82
|
+
|
80
83
|
# Exception classes to ignore by default
|
81
84
|
IGNORE_DEFAULT = ['ActiveRecord::RecordNotFound',
|
82
85
|
'ActionController::RoutingError',
|
@@ -129,7 +132,8 @@ module Raygun
|
|
129
132
|
api_url: 'https://api.raygun.io/',
|
130
133
|
breadcrumb_level: :info,
|
131
134
|
record_raw_data: false,
|
132
|
-
send_in_background: false
|
135
|
+
send_in_background: false,
|
136
|
+
error_report_send_timeout: 10
|
133
137
|
)
|
134
138
|
end
|
135
139
|
|
data/lib/raygun/version.rb
CHANGED
data/lib/raygun.rb
CHANGED
@@ -51,6 +51,10 @@ module Raygun
|
|
51
51
|
configuration.defaults
|
52
52
|
end
|
53
53
|
|
54
|
+
def reset_configuration
|
55
|
+
@configuration = Configuration.new
|
56
|
+
end
|
57
|
+
|
54
58
|
def configured?
|
55
59
|
!!configuration.api_key
|
56
60
|
end
|
@@ -118,7 +122,7 @@ module Raygun
|
|
118
122
|
def track_exception_async(*args)
|
119
123
|
future = Concurrent::Future.execute { track_exception_sync(*args) }
|
120
124
|
future.add_observer(lambda do |_, value, reason|
|
121
|
-
if value == nil || value.response.code != "202"
|
125
|
+
if value == nil || !value.responds_to?(:response) || value.response.code != "202"
|
122
126
|
log("unexpected response from Raygun, could indicate error: #{value.inspect}")
|
123
127
|
end
|
124
128
|
end, :call)
|
@@ -127,7 +131,10 @@ module Raygun
|
|
127
131
|
def track_exception_sync(exception_instance, env, user, retry_count)
|
128
132
|
if should_report?(exception_instance)
|
129
133
|
log('attempting to send exception')
|
130
|
-
Client.new.track_exception(exception_instance, env, user)
|
134
|
+
resp = Client.new.track_exception(exception_instance, env, user)
|
135
|
+
log('sent payload to api')
|
136
|
+
|
137
|
+
resp
|
131
138
|
end
|
132
139
|
rescue Exception => e
|
133
140
|
log('error sending exception to raygun, see failsafe logger for more information')
|
data/raygun4ruby.gemspec
CHANGED
@@ -25,8 +25,7 @@ Gem::Specification.new do |spec|
|
|
25
25
|
spec.add_runtime_dependency "concurrent-ruby"
|
26
26
|
|
27
27
|
spec.add_development_dependency "bundler", ">= 1.1"
|
28
|
-
spec.add_development_dependency "rake", "
|
29
|
-
spec.add_development_dependency "fakeweb", ["~> 1.3"]
|
28
|
+
spec.add_development_dependency "rake", "~> 11"
|
30
29
|
spec.add_development_dependency "timecop"
|
31
30
|
spec.add_development_dependency "minitest", "~> 4.2"
|
32
31
|
spec.add_development_dependency "redis-namespace", ">= 1.3.1"
|
@@ -34,4 +33,5 @@ Gem::Specification.new do |spec|
|
|
34
33
|
spec.add_development_dependency "sidekiq", [">= 3", "< 3.2.2"]
|
35
34
|
spec.add_development_dependency "mocha"
|
36
35
|
spec.add_development_dependency "pry"
|
36
|
+
spec.add_development_dependency "webmock"
|
37
37
|
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require_relative '../spec_helper'
|
2
|
+
require 'stringio'
|
3
|
+
|
4
|
+
describe Raygun do
|
5
|
+
let(:failsafe_logger) { FakeLogger.new }
|
6
|
+
|
7
|
+
describe '#track_exception' do
|
8
|
+
context 'send in background' do
|
9
|
+
before do
|
10
|
+
Raygun.setup do |c|
|
11
|
+
c.send_in_background = true
|
12
|
+
c.api_url = 'http://example.api'
|
13
|
+
c.api_key = 'foo'
|
14
|
+
c.debug = true
|
15
|
+
c.failsafe_logger = failsafe_logger
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'request times out' do
|
20
|
+
before do
|
21
|
+
stub_request(:post, 'http://example.api/entries').to_timeout
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'logs the failure to the failsafe logger' do
|
25
|
+
error = StandardError.new
|
26
|
+
|
27
|
+
Raygun.track_exception(error)
|
28
|
+
|
29
|
+
# Occasionally doesn't write to the failsafe logger, add small timeout to add some safety
|
30
|
+
sleep 0.1
|
31
|
+
failsafe_logger.get.must_match /Problem reporting exception to Raygun/
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#reset_configuration' do
|
38
|
+
it 'clears any customized configuration options' do
|
39
|
+
Raygun.setup do |c|
|
40
|
+
c.api_url = 'http://test.api'
|
41
|
+
end
|
42
|
+
|
43
|
+
Raygun.configuration.api_url.must_equal 'http://test.api'
|
44
|
+
|
45
|
+
Raygun.reset_configuration
|
46
|
+
|
47
|
+
Raygun.configuration.api_url.must_equal Raygun.default_configuration.api_url
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
data/specs/spec_helper.rb
CHANGED
@@ -2,8 +2,28 @@ ENV['RACK_ENV'] = 'test'
|
|
2
2
|
require_relative "../lib/raygun.rb"
|
3
3
|
require "minitest/autorun"
|
4
4
|
require "minitest/pride"
|
5
|
-
require "fakeweb"
|
6
5
|
require "timecop"
|
7
6
|
require "mocha/mini_test"
|
7
|
+
require "webmock/minitest"
|
8
|
+
require 'stringio'
|
8
9
|
|
9
10
|
alias :context :describe
|
11
|
+
|
12
|
+
class FakeLogger
|
13
|
+
def initialize
|
14
|
+
@logger = StringIO.new
|
15
|
+
end
|
16
|
+
|
17
|
+
def info(message)
|
18
|
+
@logger.write(message)
|
19
|
+
end
|
20
|
+
|
21
|
+
def reset
|
22
|
+
@logger.string = ""
|
23
|
+
end
|
24
|
+
|
25
|
+
def get
|
26
|
+
@logger.string
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
data/test/test_helper.rb
CHANGED
@@ -2,7 +2,6 @@ ENV['RACK_ENV'] = 'test'
|
|
2
2
|
require_relative "../lib/raygun.rb"
|
3
3
|
require "minitest/autorun"
|
4
4
|
require "minitest/pride"
|
5
|
-
require "fakeweb"
|
6
5
|
require "timecop"
|
7
6
|
require "mocha/mini_test"
|
8
7
|
require 'stringio'
|
@@ -47,20 +46,17 @@ end
|
|
47
46
|
class Raygun::UnitTest < MiniTest::Unit::TestCase
|
48
47
|
|
49
48
|
def setup
|
50
|
-
FakeWeb.allow_net_connect = false
|
51
49
|
Raygun.configuration.api_key = "test api key"
|
52
50
|
end
|
53
51
|
|
54
|
-
def fake_successful_entry
|
55
|
-
FakeWeb.register_uri(:post, "https://api.raygun.io/entries", body: "", status: 202)
|
56
|
-
end
|
57
|
-
|
58
52
|
def teardown
|
59
|
-
FakeWeb.clean_registry
|
60
|
-
FakeWeb.allow_net_connect = true
|
61
53
|
reset_configuration
|
62
54
|
end
|
63
55
|
|
56
|
+
def fake_successful_entry
|
57
|
+
stub_request(:post, 'https://api.raygun.io/entries').to_return(status: 202)
|
58
|
+
end
|
59
|
+
|
64
60
|
def reset_configuration
|
65
61
|
Raygun.configuration = Raygun::Configuration.new
|
66
62
|
end
|
@@ -12,6 +12,10 @@ class ConfigurationTest < Raygun::UnitTest
|
|
12
12
|
end
|
13
13
|
end
|
14
14
|
|
15
|
+
def teardown
|
16
|
+
Raygun.reset_configuration
|
17
|
+
end
|
18
|
+
|
15
19
|
def test_setting_api_key_and_version
|
16
20
|
assert_equal 9.9, Raygun.configuration.version
|
17
21
|
assert_equal "a test api key", Raygun.configuration.api_key
|
@@ -179,4 +183,12 @@ class ConfigurationTest < Raygun::UnitTest
|
|
179
183
|
def test_send_in_background_default
|
180
184
|
assert_equal false, Raygun.configuration.send_in_background
|
181
185
|
end
|
186
|
+
|
187
|
+
def test_error_report_send_timeout_default
|
188
|
+
assert_equal 10, Raygun.configuration.error_report_send_timeout
|
189
|
+
end
|
190
|
+
|
191
|
+
def test_enable_reporting_default
|
192
|
+
assert_equal true, Raygun.configuration.enable_reporting
|
193
|
+
end
|
182
194
|
end
|
@@ -7,6 +7,8 @@ class ResqueFailureTest < Raygun::UnitTest
|
|
7
7
|
|
8
8
|
def setup
|
9
9
|
super
|
10
|
+
|
11
|
+
stub_request(:post, 'https://api.raygun.io/entries').to_return(status: 202)
|
10
12
|
fake_successful_entry
|
11
13
|
end
|
12
14
|
|
@@ -19,4 +21,4 @@ class ResqueFailureTest < Raygun::UnitTest
|
|
19
21
|
).save.success?
|
20
22
|
end
|
21
23
|
|
22
|
-
end
|
24
|
+
end
|
@@ -13,6 +13,8 @@ class SidekiqFailureTest < Raygun::UnitTest
|
|
13
13
|
|
14
14
|
def setup
|
15
15
|
super
|
16
|
+
|
17
|
+
stub_request(:post, 'https://api.raygun.io/entries').to_return(status: 202)
|
16
18
|
fake_successful_entry
|
17
19
|
end
|
18
20
|
|
@@ -27,4 +29,4 @@ class SidekiqFailureTest < Raygun::UnitTest
|
|
27
29
|
assert Sidekiq.error_handlers.include?(Raygun::SidekiqReporter)
|
28
30
|
end
|
29
31
|
|
30
|
-
end
|
32
|
+
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.7.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:
|
12
|
+
date: 2018-02-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httparty
|
@@ -83,32 +83,18 @@ dependencies:
|
|
83
83
|
version: '1.1'
|
84
84
|
- !ruby/object:Gem::Dependency
|
85
85
|
name: rake
|
86
|
-
requirement: !ruby/object:Gem::Requirement
|
87
|
-
requirements:
|
88
|
-
- - '='
|
89
|
-
- !ruby/object:Gem::Version
|
90
|
-
version: 0.9.6
|
91
|
-
type: :development
|
92
|
-
prerelease: false
|
93
|
-
version_requirements: !ruby/object:Gem::Requirement
|
94
|
-
requirements:
|
95
|
-
- - '='
|
96
|
-
- !ruby/object:Gem::Version
|
97
|
-
version: 0.9.6
|
98
|
-
- !ruby/object:Gem::Dependency
|
99
|
-
name: fakeweb
|
100
86
|
requirement: !ruby/object:Gem::Requirement
|
101
87
|
requirements:
|
102
88
|
- - "~>"
|
103
89
|
- !ruby/object:Gem::Version
|
104
|
-
version: '
|
90
|
+
version: '11'
|
105
91
|
type: :development
|
106
92
|
prerelease: false
|
107
93
|
version_requirements: !ruby/object:Gem::Requirement
|
108
94
|
requirements:
|
109
95
|
- - "~>"
|
110
96
|
- !ruby/object:Gem::Version
|
111
|
-
version: '
|
97
|
+
version: '11'
|
112
98
|
- !ruby/object:Gem::Dependency
|
113
99
|
name: timecop
|
114
100
|
requirement: !ruby/object:Gem::Requirement
|
@@ -213,6 +199,20 @@ dependencies:
|
|
213
199
|
- - ">="
|
214
200
|
- !ruby/object:Gem::Version
|
215
201
|
version: '0'
|
202
|
+
- !ruby/object:Gem::Dependency
|
203
|
+
name: webmock
|
204
|
+
requirement: !ruby/object:Gem::Requirement
|
205
|
+
requirements:
|
206
|
+
- - ">="
|
207
|
+
- !ruby/object:Gem::Version
|
208
|
+
version: '0'
|
209
|
+
type: :development
|
210
|
+
prerelease: false
|
211
|
+
version_requirements: !ruby/object:Gem::Requirement
|
212
|
+
requirements:
|
213
|
+
- - ">="
|
214
|
+
- !ruby/object:Gem::Version
|
215
|
+
version: '0'
|
216
216
|
description: Ruby Adapter for Raygun.io
|
217
217
|
email:
|
218
218
|
- hello@raygun.io
|
@@ -251,6 +251,7 @@ files:
|
|
251
251
|
- raygun4ruby.gemspec
|
252
252
|
- specs/raygun/breadcrumbs/breadcrumb_spec.rb
|
253
253
|
- specs/raygun/breadcrumbs/store_spec.rb
|
254
|
+
- specs/raygun/raygun_spec.rb
|
254
255
|
- specs/services/apply_whitelist_filter_to_payload_spec.rb
|
255
256
|
- specs/spec_helper.rb
|
256
257
|
- test/integration/client_test.rb
|