airbrake-ruby 6.1.0 → 6.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/airbrake-ruby/async_sender.rb +11 -15
- data/lib/airbrake-ruby/backlog.rb +123 -0
- data/lib/airbrake-ruby/config.rb +7 -0
- data/lib/airbrake-ruby/filters/git_last_checkout_filter.rb +1 -1
- data/lib/airbrake-ruby/nested_exception.rb +22 -1
- data/lib/airbrake-ruby/notice.rb +5 -3
- data/lib/airbrake-ruby/notice_notifier.rb +1 -0
- data/lib/airbrake-ruby/performance_notifier.rb +1 -0
- data/lib/airbrake-ruby/response.rb +56 -5
- data/lib/airbrake-ruby/sync_sender.rb +41 -10
- data/lib/airbrake-ruby/version.rb +1 -1
- data/lib/airbrake-ruby.rb +2 -1
- metadata +5 -122
- data/spec/airbrake_spec.rb +0 -522
- data/spec/async_sender_spec.rb +0 -65
- data/spec/backtrace_spec.rb +0 -430
- data/spec/benchmark_spec.rb +0 -35
- data/spec/code_hunk_spec.rb +0 -124
- data/spec/config/processor_spec.rb +0 -167
- data/spec/config/validator_spec.rb +0 -204
- data/spec/config_spec.rb +0 -188
- data/spec/context_spec.rb +0 -54
- data/spec/deploy_notifier_spec.rb +0 -50
- data/spec/file_cache_spec.rb +0 -35
- data/spec/filter_chain_spec.rb +0 -124
- data/spec/filters/context_filter_spec.rb +0 -32
- data/spec/filters/dependency_filter_spec.rb +0 -14
- data/spec/filters/exception_attributes_filter_spec.rb +0 -52
- data/spec/filters/gem_root_filter_spec.rb +0 -44
- data/spec/filters/git_last_checkout_filter_spec.rb +0 -61
- data/spec/filters/git_repository_filter_spec.rb +0 -72
- data/spec/filters/git_revision_filter_spec.rb +0 -126
- data/spec/filters/keys_allowlist_spec.rb +0 -204
- data/spec/filters/keys_blocklist_spec.rb +0 -242
- data/spec/filters/root_directory_filter_spec.rb +0 -39
- data/spec/filters/sql_filter_spec.rb +0 -274
- data/spec/filters/system_exit_filter_spec.rb +0 -16
- data/spec/filters/thread_filter_spec.rb +0 -281
- data/spec/fixtures/notroot.txt +0 -7
- data/spec/fixtures/project_root/code.rb +0 -221
- data/spec/fixtures/project_root/empty_file.rb +0 -0
- data/spec/fixtures/project_root/long_line.txt +0 -1
- data/spec/fixtures/project_root/short_file.rb +0 -3
- data/spec/fixtures/project_root/vendor/bundle/ignored_file.rb +0 -5
- data/spec/helpers.rb +0 -9
- data/spec/ignorable_spec.rb +0 -14
- data/spec/inspectable_spec.rb +0 -45
- data/spec/loggable_spec.rb +0 -17
- data/spec/monotonic_time_spec.rb +0 -25
- data/spec/nested_exception_spec.rb +0 -73
- data/spec/notice_notifier/options_spec.rb +0 -269
- data/spec/notice_notifier_spec.rb +0 -361
- data/spec/notice_spec.rb +0 -300
- data/spec/performance_breakdown_spec.rb +0 -11
- data/spec/performance_notifier_spec.rb +0 -645
- data/spec/promise_spec.rb +0 -203
- data/spec/query_spec.rb +0 -11
- data/spec/queue_spec.rb +0 -18
- data/spec/remote_settings/callback_spec.rb +0 -162
- data/spec/remote_settings/settings_data_spec.rb +0 -348
- data/spec/remote_settings_spec.rb +0 -201
- data/spec/request_spec.rb +0 -9
- data/spec/response_spec.rb +0 -110
- data/spec/spec_helper.rb +0 -100
- data/spec/stashable_spec.rb +0 -23
- data/spec/stat_spec.rb +0 -39
- data/spec/sync_sender_spec.rb +0 -168
- data/spec/tdigest_spec.rb +0 -235
- data/spec/thread_pool_spec.rb +0 -196
- data/spec/time_truncate_spec.rb +0 -30
- data/spec/timed_trace_spec.rb +0 -127
- data/spec/truncator_spec.rb +0 -267
@@ -1,274 +0,0 @@
|
|
1
|
-
RSpec.describe Airbrake::Filters::SqlFilter do
|
2
|
-
shared_examples "query filtering" do |test|
|
3
|
-
test[:dialects].each do |dialect|
|
4
|
-
it "correctly filters SQL like `#{test[:input]}' (#{dialect} dialect)" do
|
5
|
-
filter = described_class.new(dialect)
|
6
|
-
q = OpenStruct.new(query: test[:input])
|
7
|
-
filter.call(q)
|
8
|
-
expect(q.query).to eq(test[:output])
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
shared_examples "query blocklisting" do |query, opts|
|
14
|
-
it "ignores '#{query}'" do
|
15
|
-
filter = described_class.new('postgres')
|
16
|
-
q = Airbrake::Query.new(query: query, method: 'GET', route: '/', timing: 1)
|
17
|
-
filter.call(q)
|
18
|
-
|
19
|
-
expect(q.ignored?).to eq(opts[:should_ignore])
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
all_dialects = %i[mysql postgres sqlite cassandra oracle].freeze
|
24
|
-
|
25
|
-
# rubocop:disable Layout/LineLength
|
26
|
-
[
|
27
|
-
{
|
28
|
-
input: 'SELECT * FROM things;',
|
29
|
-
output: 'SELECT * FROM things;',
|
30
|
-
dialects: all_dialects,
|
31
|
-
}, {
|
32
|
-
input: "SELECT `t001`.`c2` FROM `t001` WHERE `t001`.`c2` = 'value' AND c3=\"othervalue\" LIMIT ?",
|
33
|
-
output: "SELECT `t001`.`c2` FROM `t001` WHERE `t001`.`c2` = ? AND c3=? LIMIT ?",
|
34
|
-
dialects: %i[mysql],
|
35
|
-
}, {
|
36
|
-
input: "SELECT * FROM t WHERE foo=\"bar/*\" AND baz=\"whatever */qux\"",
|
37
|
-
output: "SELECT * FROM t WHERE foo=? AND baz=?",
|
38
|
-
dialects: %i[mysql],
|
39
|
-
}, {
|
40
|
-
input: "SELECT * FROM t WHERE foo='bar/*' AND baz='whatever */qux'",
|
41
|
-
output: "SELECT * FROM t WHERE foo=? AND baz=?",
|
42
|
-
dialects: all_dialects,
|
43
|
-
}, {
|
44
|
-
input: "SELECT \"t001\".\"c2\" FROM \"t001\" WHERE \"t001\".\"c2\" = 'value' AND c3=1234 LIMIT 1",
|
45
|
-
output: "SELECT \"t001\".\"c2\" FROM \"t001\" WHERE \"t001\".\"c2\" = ? AND c3=? LIMIT ?",
|
46
|
-
dialects: %i[postgres oracle],
|
47
|
-
}, {
|
48
|
-
input: "SELECT * FROM t WHERE foo=\"bar--\" AND\n baz=\"qux--\"",
|
49
|
-
output: "SELECT * FROM t WHERE foo=? AND\n baz=?",
|
50
|
-
dialects: %i[mysql],
|
51
|
-
}, {
|
52
|
-
input: "SELECT * FROM t WHERE foo='bar--' AND\n baz='qux--'",
|
53
|
-
output: "SELECT * FROM t WHERE foo=? AND\n baz=?",
|
54
|
-
dialects: all_dialects,
|
55
|
-
}, {
|
56
|
-
input: "SELECT * FROM foo WHERE bar='baz' /* Hide Me */",
|
57
|
-
output: "SELECT * FROM foo WHERE bar=? ?",
|
58
|
-
dialects: all_dialects,
|
59
|
-
}, {
|
60
|
-
input: "SELECT * FROM foobar WHERE password='hunter2'\n-- No peeking!",
|
61
|
-
output: "SELECT * FROM foobar WHERE password=?\n?",
|
62
|
-
dialects: all_dialects,
|
63
|
-
}, {
|
64
|
-
input: "SELECT foo, bar FROM baz WHERE password='hunter2' # Secret",
|
65
|
-
output: "SELECT foo, bar FROM baz WHERE password=? ?",
|
66
|
-
dialects: all_dialects,
|
67
|
-
}, {
|
68
|
-
input: "SELECT \"col1\", \"col2\" from \"table\" WHERE \"col3\"=E'foo\\'bar\\\\baz' AND country=e'foo\\'bar\\\\baz'",
|
69
|
-
output: "SELECT \"col1\", \"col2\" from \"table\" WHERE \"col3\"=E?",
|
70
|
-
dialects: %i[postgres],
|
71
|
-
}, {
|
72
|
-
input: "INSERT INTO `X` values(\"test\",0, 1 , 2, 'test')",
|
73
|
-
output: "INSERT INTO `X` values(?)",
|
74
|
-
dialects: %i[mysql],
|
75
|
-
}, {
|
76
|
-
input: "INSERT INTO `X` values(\"test\",0, 1 , 2, 'test')",
|
77
|
-
output: "INSERT INTO `X` values(?)",
|
78
|
-
dialects: %i[mysql],
|
79
|
-
}, {
|
80
|
-
input: "SELECT c11.col1, c22.col2 FROM table c11, table c22 WHERE value='nothing'",
|
81
|
-
output: "SELECT c11.col1, c22.col2 FROM table c11, table c22 WHERE value=?",
|
82
|
-
dialects: all_dialects,
|
83
|
-
}, {
|
84
|
-
input: "INSERT INTO X VALUES(1, 23456, 123.456, 99+100)",
|
85
|
-
output: "INSERT INTO X VALUES(?)",
|
86
|
-
dialects: all_dialects,
|
87
|
-
}, {
|
88
|
-
input: "SELECT * FROM table WHERE name=\"foo\" AND value=\"don't\"",
|
89
|
-
output: "SELECT * FROM table WHERE name=? AND value=?",
|
90
|
-
dialects: %i[mysql],
|
91
|
-
}, {
|
92
|
-
input: "SELECT * FROM table WHERE name='foo' AND value = 'bar'",
|
93
|
-
output: "SELECT * FROM table WHERE name=? AND value = ?",
|
94
|
-
dialects: all_dialects,
|
95
|
-
}, {
|
96
|
-
input: "SELECT * FROM table WHERE col='foo\\''bar'",
|
97
|
-
output: "SELECT * FROM table WHERE col=?",
|
98
|
-
dialects: all_dialects,
|
99
|
-
}, {
|
100
|
-
input: "SELECT * FROM table WHERE col1='foo\"bar' AND col2='what\"ever'",
|
101
|
-
output: "SELECT * FROM table WHERE col1=? AND col2=?",
|
102
|
-
dialects: all_dialects,
|
103
|
-
}, {
|
104
|
-
input: "select * from accounts where accounts.name != 'dude\n newline' order by accounts.name",
|
105
|
-
output: "select * from accounts where accounts.name != ? order by accounts.name",
|
106
|
-
dialects: all_dialects,
|
107
|
-
}, {
|
108
|
-
input: "SELECT * FROM table WHERE col1=\"don't\" AND col2=\"won't\"",
|
109
|
-
output: "SELECT * FROM table WHERE col1=? AND col2=?",
|
110
|
-
dialects: %i[mysql],
|
111
|
-
}, {
|
112
|
-
input: "INSERT INTO X values('', 'jim''s ssn',0, 1 , 'jim''s son''s son', \"\"\"jim''s\"\" hat\", \"\\\"jim''s secret\\\"\")",
|
113
|
-
output: "INSERT INTO X values(?, ?,?, ? , ?, ?, ?",
|
114
|
-
dialects: %i[mysql],
|
115
|
-
}, {
|
116
|
-
input: "SELECT * FROM table WHERE name='foo\\' AND color='blue'",
|
117
|
-
output: "SELECT * FROM table WHERE name=?",
|
118
|
-
dialects: all_dialects,
|
119
|
-
}, {
|
120
|
-
input: "SELECT * FROM table WHERE foo=\"this string ends with a backslash\\\\\"",
|
121
|
-
output: "SELECT * FROM table WHERE foo=?",
|
122
|
-
dialects: %i[mysql],
|
123
|
-
}, {
|
124
|
-
input: "SELECT * FROM table WHERE foo='this string ends with a backslash\\\\'",
|
125
|
-
output: "SELECT * FROM table WHERE foo=?",
|
126
|
-
dialects: all_dialects,
|
127
|
-
}, {
|
128
|
-
# TODO: fix this example.
|
129
|
-
input: "SELECT * FROM table WHERE name='foo\'' AND color='blue'",
|
130
|
-
output: "Error: Airbrake::Query was not filtered",
|
131
|
-
dialects: all_dialects,
|
132
|
-
}, {
|
133
|
-
input: "INSERT INTO X values('', 'a''b c',0, 1 , 'd''e f''s h')",
|
134
|
-
output: "INSERT INTO X values(?)",
|
135
|
-
dialects: all_dialects,
|
136
|
-
}, {
|
137
|
-
input: "SELECT * FROM t WHERE -- '\n bar='baz' -- '",
|
138
|
-
output: "SELECT * FROM t WHERE ?\n bar=? ?",
|
139
|
-
dialects: all_dialects,
|
140
|
-
}, {
|
141
|
-
input: "SELECT * FROM t WHERE /* ' */\n bar='baz' -- '",
|
142
|
-
output: "SELECT * FROM t WHERE ?\n bar=? ?",
|
143
|
-
dialects: all_dialects,
|
144
|
-
}, {
|
145
|
-
input: "SELECT * FROM t WHERE -- '\n /* ' */ c2='xxx' /* ' */\n c='x\n xx' -- '",
|
146
|
-
output: "SELECT * FROM t WHERE ?\n ? c2=? ?\n c=? ?",
|
147
|
-
dialects: all_dialects,
|
148
|
-
}, {
|
149
|
-
input: "SELECT * FROM t WHERE -- '\n c='x\n xx' -- '",
|
150
|
-
output: "SELECT * FROM t WHERE ?\n c=? ?",
|
151
|
-
dialects: all_dialects,
|
152
|
-
}, {
|
153
|
-
input: "SELECT * FROM foo WHERE col='value1' AND /* don't */ col2='value1' /* won't */",
|
154
|
-
output: "SELECT * FROM foo WHERE col=? AND ? col2=? ?",
|
155
|
-
dialects: all_dialects,
|
156
|
-
}, {
|
157
|
-
input: "SELECT * FROM table WHERE foo='bar' AND baz=\"nothing to see here'",
|
158
|
-
output: "Error: Airbrake::Query was not filtered",
|
159
|
-
dialects: %i[mysql],
|
160
|
-
}, {
|
161
|
-
input: "SELECT * FROM table WHERE foo='bar' AND baz='nothing to see here",
|
162
|
-
output: "Error: Airbrake::Query was not filtered",
|
163
|
-
dialects: all_dialects,
|
164
|
-
}, {
|
165
|
-
input: "SELECT * FROM \"foo\" WHERE \"foo\" = $a$dollar quotes can be $b$nested$b$$a$ and bar = 'baz'",
|
166
|
-
output: "SELECT * FROM \"foo\" WHERE \"foo\" = ? and bar = ?",
|
167
|
-
dialects: %i[postgres],
|
168
|
-
}, {
|
169
|
-
input: "INSERT INTO \"foo\" (\"bar\", \"baz\", \"qux\") VALUES ($1, $2, $3) RETURNING \"id\"",
|
170
|
-
output: "INSERT INTO \"foo\" (?) RETURNING \"id\"",
|
171
|
-
dialects: %i[postgres],
|
172
|
-
}, {
|
173
|
-
input: "select * from foo where bar = 'some\\tthing' and baz = 10",
|
174
|
-
output: "select * from foo where bar = ? and baz = ?",
|
175
|
-
dialects: all_dialects,
|
176
|
-
}, {
|
177
|
-
input: "select * from users where user = 'user1\\' password = 'hunter 2' -- ->don't count this quote",
|
178
|
-
output: "select * from users where user = ?",
|
179
|
-
dialects: all_dialects,
|
180
|
-
}, {
|
181
|
-
input: "select * from foo where bar=q'[baz's]' and x=5",
|
182
|
-
output: "select * from foo where bar=? and x=?",
|
183
|
-
dialects: %i[oracle],
|
184
|
-
}, {
|
185
|
-
input: "select * from foo where bar=q'{baz's}' and x=5",
|
186
|
-
output: "select * from foo where bar=? and x=?",
|
187
|
-
dialects: %i[oracle],
|
188
|
-
}, {
|
189
|
-
input: "select * from foo where bar=q'<baz's>' and x=5",
|
190
|
-
output: "select * from foo where bar=? and x=?",
|
191
|
-
dialects: %i[oracle],
|
192
|
-
}, {
|
193
|
-
input: "select * from foo where bar=q'(baz's)' and x=5",
|
194
|
-
output: "select * from foo where bar=? and x=?",
|
195
|
-
dialects: %i[oracle],
|
196
|
-
}, {
|
197
|
-
input: "select * from foo where bar=0xabcdef123 and x=5",
|
198
|
-
output: "select * from foo where bar=? and x=?",
|
199
|
-
dialects: %i[cassandra sqlite],
|
200
|
-
}, {
|
201
|
-
input: "select * from foo where bar=0x2F and x=5",
|
202
|
-
output: "select * from foo where bar=? and x=?",
|
203
|
-
dialects: %i[mysql cassandra sqlite],
|
204
|
-
}, {
|
205
|
-
input: "select * from foo where bar=1.234e-5 and x=5",
|
206
|
-
output: "select * from foo where bar=? and x=?",
|
207
|
-
dialects: all_dialects,
|
208
|
-
}, {
|
209
|
-
input: "select * from foo where bar=01234567-89ab-cdef-0123-456789abcdef and x=5",
|
210
|
-
output: "select * from foo where bar=? and x=?",
|
211
|
-
dialects: %i[postgres cassandra],
|
212
|
-
}, {
|
213
|
-
input: "select * from foo where bar={01234567-89ab-cdef-0123-456789abcdef} and x=5",
|
214
|
-
output: "select * from foo where bar=? and x=?",
|
215
|
-
dialects: %i[postgres],
|
216
|
-
}, {
|
217
|
-
input: "select * from foo where bar=0123456789abcdef0123456789abcdef and x=5",
|
218
|
-
output: "select * from foo where bar=? and x=?",
|
219
|
-
dialects: %i[postgtes],
|
220
|
-
}, {
|
221
|
-
input: "select * from foo where bar={012-345678-9abc-def012345678-9abcdef} and x=5",
|
222
|
-
output: "select * from foo where bar=? and x=?",
|
223
|
-
dialects: %i[postgres],
|
224
|
-
}, {
|
225
|
-
input: "select * from foo where bar=true and x=FALSE",
|
226
|
-
output: "select * from foo where bar=? and x=?",
|
227
|
-
dialects: %i[mysql postgres cassandra sqlite],
|
228
|
-
}
|
229
|
-
].each do |test|
|
230
|
-
include_examples 'query filtering', test
|
231
|
-
end
|
232
|
-
# rubocop:enable Layout/LineLength
|
233
|
-
|
234
|
-
[
|
235
|
-
'COMMIT',
|
236
|
-
'commit',
|
237
|
-
'BEGIN',
|
238
|
-
'begin',
|
239
|
-
'SET time zone ?',
|
240
|
-
'set time zone ?',
|
241
|
-
'SHOW max_identifier_length',
|
242
|
-
'show max_identifier_length',
|
243
|
-
|
244
|
-
'WITH pk_constraint AS ( SELECT conrelid, unnest(conkey) AS connum ' \
|
245
|
-
'FROM pg_constraint WHERE contype = ? AND conrelid = ?::regclass ), ' \
|
246
|
-
'cons AS ( SELECT conrelid, connum, row_number() OVER() AS rownum FROM ' \
|
247
|
-
'pk_constraint ) SELECT attr.attname FROM pg_attribute attr INNER JOIN ' \
|
248
|
-
'cons ON attr.attrelid = cons.conrelid AND attr.attnum = cons.connum ' \
|
249
|
-
'ORDER BY cons.rownum',
|
250
|
-
|
251
|
-
'SELECT c.relname FROM pg_class c LEFT JOIN pg_namespace n ON ' \
|
252
|
-
'n.oid = c.relnamespace WHERE n.nspname = ANY (?)',
|
253
|
-
|
254
|
-
'SELECT a.attname FROM ( SELECT indrelid, indkey, generate_subscripts(?) ' \
|
255
|
-
'idx FROM pg_index WHERE indrelid = ?::regclass AND indisprimary ) i ' \
|
256
|
-
'JOIN pg_attribute a ON a.attrelid = i.indrelid AND ' \
|
257
|
-
'a.attnum = i.indkey[i.idx] ORDER BY i.idx',
|
258
|
-
|
259
|
-
'SELECT t.oid, t.typname, t.typelem, t.typdelim, t.typinput, r.rngsubtype, ' \
|
260
|
-
't.typtype, t.typbasetype FROM pg_type as t LEFT JOIN pg_range as r ON ' \
|
261
|
-
'oid = rngtypid WHERE t.typname IN (?) OR t.typtype IN (?) OR t.typinput ' \
|
262
|
-
'= ?::regprocedure OR t.typelem != ?',
|
263
|
-
|
264
|
-
'SELECT t.oid, t.typname FROM pg_type as t WHERE t.typname IN (?)',
|
265
|
-
].each do |query|
|
266
|
-
include_examples 'query blocklisting', query, should_ignore: true
|
267
|
-
end
|
268
|
-
|
269
|
-
[
|
270
|
-
'UPDATE "users" SET "last_sign_in_at" = ? WHERE "users"."id" = ?',
|
271
|
-
].each do |query|
|
272
|
-
include_examples 'query blocklisting', query, should_ignore: false
|
273
|
-
end
|
274
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
RSpec.describe Airbrake::Filters::SystemExitFilter do
|
2
|
-
subject(:system_exit_filter) { described_class.new }
|
3
|
-
|
4
|
-
it "marks SystemExit exceptions as ignored" do
|
5
|
-
notice = Airbrake::Notice.new(SystemExit.new)
|
6
|
-
expect { system_exit_filter.call(notice) }.to(
|
7
|
-
change { notice.ignored? }.from(false).to(true),
|
8
|
-
)
|
9
|
-
end
|
10
|
-
|
11
|
-
it "doesn't mark non SystemExit exceptions as ignored" do
|
12
|
-
notice = Airbrake::Notice.new(AirbrakeTestError.new)
|
13
|
-
expect(notice).not_to be_ignored
|
14
|
-
expect { system_exit_filter.call(notice) }.not_to(change { notice.ignored? })
|
15
|
-
end
|
16
|
-
end
|
@@ -1,281 +0,0 @@
|
|
1
|
-
RSpec.describe Airbrake::Filters::ThreadFilter do
|
2
|
-
subject(:thread_filter) { described_class.new }
|
3
|
-
|
4
|
-
let(:notice) { Airbrake::Notice.new(AirbrakeTestError.new) }
|
5
|
-
|
6
|
-
def new_thread
|
7
|
-
Thread.new do
|
8
|
-
th = Thread.current
|
9
|
-
|
10
|
-
# Ensure a thread always has some variable to make sure the
|
11
|
-
# :fiber_variables Hash is always present.
|
12
|
-
th[:random_var] = 42
|
13
|
-
yield(th)
|
14
|
-
end.join
|
15
|
-
end
|
16
|
-
|
17
|
-
describe "thread variables" do
|
18
|
-
shared_examples "expected thread variable" do |var|
|
19
|
-
it "attaches the thread variable" do
|
20
|
-
new_thread do |th|
|
21
|
-
th.thread_variable_set(:bingo, var)
|
22
|
-
thread_filter.call(notice)
|
23
|
-
end
|
24
|
-
|
25
|
-
expect(notice[:params][:thread][:thread_variables][:bingo]).to eq(var)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
context "given nil" do
|
30
|
-
include_examples "expected thread variable", nil
|
31
|
-
end
|
32
|
-
|
33
|
-
context "given true" do
|
34
|
-
include_examples "expected thread variable", true
|
35
|
-
end
|
36
|
-
|
37
|
-
context "given false" do
|
38
|
-
include_examples "expected thread variable", false
|
39
|
-
end
|
40
|
-
|
41
|
-
context "given a String" do
|
42
|
-
include_examples "expected thread variable", 'bango'
|
43
|
-
end
|
44
|
-
|
45
|
-
context "given a Symbol" do
|
46
|
-
include_examples "expected thread variable", :bango
|
47
|
-
end
|
48
|
-
|
49
|
-
context "given a Regexp" do
|
50
|
-
include_examples "expected thread variable", /bango/
|
51
|
-
end
|
52
|
-
|
53
|
-
context "given an Integer" do
|
54
|
-
include_examples "expected thread variable", 1
|
55
|
-
end
|
56
|
-
|
57
|
-
context "given a Float" do
|
58
|
-
include_examples "expected thread variable", 1.01
|
59
|
-
end
|
60
|
-
|
61
|
-
context "given an Object" do
|
62
|
-
it "converts it to a String and attaches" do
|
63
|
-
new_thread do |th|
|
64
|
-
th.thread_variable_set(:bingo, Object.new)
|
65
|
-
thread_filter.call(notice)
|
66
|
-
end
|
67
|
-
|
68
|
-
vars = notice[:params][:thread][:thread_variables]
|
69
|
-
expect(vars[:bingo]).to match(/\A#<Object:.+>\z/)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
context "given an Array of nested Hashes with complex objects" do
|
74
|
-
let(:var) do
|
75
|
-
[
|
76
|
-
{
|
77
|
-
bango: {
|
78
|
-
bongo: [
|
79
|
-
{
|
80
|
-
bish: {
|
81
|
-
bash: 'foo',
|
82
|
-
bosh: Object.new,
|
83
|
-
},
|
84
|
-
},
|
85
|
-
],
|
86
|
-
},
|
87
|
-
},
|
88
|
-
123,
|
89
|
-
]
|
90
|
-
end
|
91
|
-
|
92
|
-
it "converts objects to a safe objects" do
|
93
|
-
new_thread do |th|
|
94
|
-
th.thread_variable_set(:bingo, var)
|
95
|
-
thread_filter.call(notice)
|
96
|
-
end
|
97
|
-
|
98
|
-
vars = notice[:params][:thread][:thread_variables]
|
99
|
-
expect(vars[:bingo]).to(
|
100
|
-
match(
|
101
|
-
[
|
102
|
-
{
|
103
|
-
bango: {
|
104
|
-
bongo: [
|
105
|
-
{
|
106
|
-
bish: {
|
107
|
-
bash: 'foo',
|
108
|
-
bosh: /\A#<Object:.+>\z/,
|
109
|
-
},
|
110
|
-
},
|
111
|
-
],
|
112
|
-
},
|
113
|
-
},
|
114
|
-
123,
|
115
|
-
],
|
116
|
-
),
|
117
|
-
)
|
118
|
-
end
|
119
|
-
end
|
120
|
-
|
121
|
-
it "ignores thread variables starting with an underscore" do
|
122
|
-
var = :__recursive_key__
|
123
|
-
|
124
|
-
new_thread do |th|
|
125
|
-
th.thread_variable_set(var, :bingo)
|
126
|
-
thread_filter.call(notice)
|
127
|
-
end
|
128
|
-
|
129
|
-
thread_variables = notice[:params][:thread][:thread_variables]
|
130
|
-
expect(thread_variables).to be_nil
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
describe "fiber variables" do
|
135
|
-
shared_examples "expected fiber variable" do |var|
|
136
|
-
it "attaches the fiber variable" do
|
137
|
-
new_thread do |th|
|
138
|
-
th[:bingo] = var
|
139
|
-
thread_filter.call(notice)
|
140
|
-
end
|
141
|
-
|
142
|
-
expect(notice[:params][:thread][:fiber_variables][:bingo]).to eq(var)
|
143
|
-
end
|
144
|
-
end
|
145
|
-
|
146
|
-
context "given nil" do
|
147
|
-
include_examples "expected fiber variable", nil
|
148
|
-
end
|
149
|
-
|
150
|
-
context "given true" do
|
151
|
-
include_examples "expected fiber variable", true
|
152
|
-
end
|
153
|
-
|
154
|
-
context "given false" do
|
155
|
-
include_examples "expected fiber variable", false
|
156
|
-
end
|
157
|
-
|
158
|
-
context "given a String" do
|
159
|
-
include_examples "expected fiber variable", 'bango'
|
160
|
-
end
|
161
|
-
|
162
|
-
context "given a Symbol" do
|
163
|
-
include_examples "expected fiber variable", :bango
|
164
|
-
end
|
165
|
-
|
166
|
-
context "given a Regexp" do
|
167
|
-
include_examples "expected fiber variable", /bango/
|
168
|
-
end
|
169
|
-
|
170
|
-
context "given an Integer" do
|
171
|
-
include_examples "expected fiber variable", 1
|
172
|
-
end
|
173
|
-
|
174
|
-
context "given a Float" do
|
175
|
-
include_examples "expected fiber variable", 1.01
|
176
|
-
end
|
177
|
-
|
178
|
-
context "given an Object" do
|
179
|
-
it "converts it to a String and attaches" do
|
180
|
-
new_thread do |th|
|
181
|
-
th[:bingo] = Object.new
|
182
|
-
thread_filter.call(notice)
|
183
|
-
end
|
184
|
-
|
185
|
-
vars = notice[:params][:thread][:fiber_variables]
|
186
|
-
expect(vars[:bingo]).to match(/\A#<Object:.+>\z/)
|
187
|
-
end
|
188
|
-
end
|
189
|
-
|
190
|
-
context "given an Array of nested Hashes with complex objects" do
|
191
|
-
let(:var) do
|
192
|
-
[
|
193
|
-
{
|
194
|
-
bango: {
|
195
|
-
bongo: [
|
196
|
-
{
|
197
|
-
bish: {
|
198
|
-
bash: 'foo',
|
199
|
-
bosh: Object.new,
|
200
|
-
},
|
201
|
-
},
|
202
|
-
],
|
203
|
-
},
|
204
|
-
},
|
205
|
-
123,
|
206
|
-
]
|
207
|
-
end
|
208
|
-
|
209
|
-
it "converts objects to a safe objects" do
|
210
|
-
new_thread do |th|
|
211
|
-
th[:bingo] = var
|
212
|
-
thread_filter.call(notice)
|
213
|
-
end
|
214
|
-
|
215
|
-
vars = notice[:params][:thread][:fiber_variables]
|
216
|
-
expect(vars[:bingo]).to(
|
217
|
-
match(
|
218
|
-
[
|
219
|
-
{
|
220
|
-
bango: {
|
221
|
-
bongo: [
|
222
|
-
{
|
223
|
-
bish: {
|
224
|
-
bash: 'foo',
|
225
|
-
bosh: /\A#<Object:.+>\z/,
|
226
|
-
},
|
227
|
-
},
|
228
|
-
],
|
229
|
-
},
|
230
|
-
},
|
231
|
-
123,
|
232
|
-
],
|
233
|
-
),
|
234
|
-
)
|
235
|
-
end
|
236
|
-
end
|
237
|
-
end
|
238
|
-
|
239
|
-
it "appends name" do
|
240
|
-
new_thread do |th|
|
241
|
-
th.name = 'bingo'
|
242
|
-
thread_filter.call(notice)
|
243
|
-
end
|
244
|
-
|
245
|
-
expect(notice[:params][:thread][:name]).to eq('bingo')
|
246
|
-
end
|
247
|
-
|
248
|
-
it "appends thread inspect (self)" do
|
249
|
-
thread_filter.call(notice)
|
250
|
-
expect(notice[:params][:thread][:self]).to match(/\A#<Thread:.+>\z/)
|
251
|
-
end
|
252
|
-
|
253
|
-
it "appends thread group" do
|
254
|
-
thread_filter.call(notice)
|
255
|
-
expect(notice[:params][:thread][:group][0]).to match(/\A#<Thread:.+>\z/)
|
256
|
-
end
|
257
|
-
|
258
|
-
it "appends priority" do
|
259
|
-
thread_filter.call(notice)
|
260
|
-
expect(notice[:params][:thread][:priority]).to eq(0)
|
261
|
-
end
|
262
|
-
|
263
|
-
it "appends safe_level", skip: (
|
264
|
-
"Not supported on this version of Ruby." unless Airbrake::HAS_SAFE_LEVEL
|
265
|
-
) do
|
266
|
-
thread_filter.call(notice)
|
267
|
-
expect(notice[:params][:thread][:safe_level]).to eq(0)
|
268
|
-
end
|
269
|
-
|
270
|
-
it "ignores fiber variables starting with an underscore" do
|
271
|
-
key = :__recursive_key__
|
272
|
-
|
273
|
-
new_thread do |th|
|
274
|
-
th[key] = :bingo
|
275
|
-
thread_filter.call(notice)
|
276
|
-
end
|
277
|
-
|
278
|
-
fiber_variables = notice[:params][:thread][:fiber_variables]
|
279
|
-
expect(fiber_variables[key]).to be_nil
|
280
|
-
end
|
281
|
-
end
|