logstash-output-http 5.3.0 → 5.4.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 58ad383035622e8cc13441e89147871f55669f22ff22835a0d6db9a87d1ab185
4
- data.tar.gz: 28498a16c1ee3fefcf87cb6990ca99a90be82cb3e73438dc8a564d171a3bcc9f
3
+ metadata.gz: dd850256e5336762a98ed5cc4ae699ddcc1c3c3bcb9e5382b033aa21aebd5fea
4
+ data.tar.gz: '08b1450d6eadd6ea8e7a9451d781c4fd78c3d7b199751616c1e74cabc75e3899'
5
5
  SHA512:
6
- metadata.gz: a14293accaea16058469ad4e2c92b759b8686fee8b068f31dd3d8984679260cb32c080287f08e02e9c2ac60ca84c8129fbe042eb76ca69333959cc07da50d6ae
7
- data.tar.gz: e92646b17dbe8662d707526cb983f898bfa80392662bfe0658ad8abb80e0b786acbc24e73bce98e6621a8b99b75e90bede275cd7162da2a3b9137e93954525dc
6
+ metadata.gz: 11dce3822d80720abedca11fe586cb8d4c8384e44cb793da13bba509c571c48bf8b617a0545297fb49a8cd254d5374e5b4702dddf607e4bad04eaaf07b24e0d0
7
+ data.tar.gz: 62546e31fc1386c48a0b77c25f5e13093fc63bfc371ea1924ebc8737ec26b4855c4c0bd40cebbd5a2eac82288315da436c46772793c2fc86adcf848d79cfadd9
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 5.4.0
2
+ - Introduce retryable unknown exceptions for "connection reset by peer" and "timeout" [#127](https://github.com/logstash-plugins/logstash-output-http/pull/127)
3
+
1
4
  ## 5.3.0
2
5
  - Feat: support ssl_verification_mode option [#126](https://github.com/logstash-plugins/logstash-output-http/pull/126)
3
6
 
@@ -23,6 +23,12 @@ class LogStash::Outputs::Http < LogStash::Outputs::Base
23
23
  ::Manticore::SocketTimeout
24
24
  ]
25
25
 
26
+ RETRYABLE_UNKNOWN_EXCEPTION_STRINGS = [
27
+ /Connection reset by peer/i,
28
+ /Read Timed out/i
29
+ ]
30
+
31
+
26
32
  # This output lets you send events to a
27
33
  # generic HTTP(S) endpoint
28
34
  #
@@ -295,7 +301,16 @@ class LogStash::Outputs::Http < LogStash::Outputs::Base
295
301
  end
296
302
 
297
303
  def retryable_exception?(exception)
298
- RETRYABLE_MANTICORE_EXCEPTIONS.any? {|me| exception.is_a?(me) }
304
+ retryable_manticore_exception?(exception) || retryable_unknown_exception?(exception)
305
+ end
306
+
307
+ def retryable_manticore_exception?(exception)
308
+ RETRYABLE_MANTICORE_EXCEPTIONS.any? {|me| exception.is_a?(me)}
309
+ end
310
+
311
+ def retryable_unknown_exception?(exception)
312
+ exception.is_a?(::Manticore::UnknownException) &&
313
+ RETRYABLE_UNKNOWN_EXCEPTION_STRINGS.any? { |snippet| exception.message =~ snippet }
299
314
  end
300
315
 
301
316
  # This is split into a separate method mostly to help testing
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-output-http'
3
- s.version = '5.3.0'
3
+ s.version = '5.4.0'
4
4
  s.licenses = ['Apache License (2.0)']
5
5
  s.summary = "Sends events to a generic HTTP or HTTPS endpoint"
6
6
  s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
@@ -126,6 +126,44 @@ describe LogStash::Outputs::Http do
126
126
  let(:method) { "post" }
127
127
 
128
128
  shared_examples("verb behavior") do |method|
129
+
130
+ shared_examples("failure log behaviour") do
131
+ it "logs failure" do
132
+ expect(subject).to have_received(:log_failure).with(any_args)
133
+ end
134
+
135
+ it "does not log headers" do
136
+ expect(subject).to have_received(:log_failure).with(anything, hash_not_including(:headers))
137
+ end
138
+
139
+ it "does not log the message body" do
140
+ expect(subject).to have_received(:log_failure).with(anything, hash_not_including(:body))
141
+ end
142
+
143
+ context "with debug log level" do
144
+ before :all do
145
+ @current_log_level = LogStash::Logging::Logger.get_logging_context.get_root_logger.get_level.to_s.downcase
146
+ LogStash::Logging::Logger.configure_logging "debug"
147
+ end
148
+ after :all do
149
+ LogStash::Logging::Logger.configure_logging @current_log_level
150
+ end
151
+
152
+ it "logs a failure" do
153
+ expect(subject).to have_received(:log_failure).with(any_args)
154
+ end
155
+
156
+ it "logs headers" do
157
+ expect(subject).to have_received(:log_failure).with(anything, hash_including(:headers))
158
+ end
159
+
160
+ it "logs the body" do
161
+ expect(subject).to have_received(:log_failure).with(anything, hash_including(:body))
162
+ end
163
+ end
164
+
165
+ end
166
+
129
167
  let(:verb_behavior_config) { {"url" => url, "http_method" => method, "pool_max" => 1} }
130
168
  subject { LogStash::Outputs::Http.new(verb_behavior_config) }
131
169
 
@@ -213,44 +251,96 @@ describe LogStash::Outputs::Http do
213
251
  end
214
252
  end
215
253
 
216
- context "on exception" do
254
+ context "on retryable unknown exception" do
217
255
  before :each do
218
- allow(subject.client).to receive(:send).and_raise RuntimeError
256
+ raised = false
257
+ original_method = subject.client.method(:send)
258
+ allow(subject).to receive(:send_event).and_call_original
259
+ expect(subject.client).to receive(:send) do |*args|
260
+ unless raised
261
+ raised = true
262
+ raise ::Manticore::UnknownException.new("Read timed out")
263
+ end
264
+ original_method.call(args)
265
+ end
219
266
  subject.multi_receive([event])
220
267
  end
221
268
 
222
- it "should not log headers" do
223
- expect(subject).to have_received(:log_failure).with(anything, hash_not_including(:headers))
224
- end
269
+ include_examples("failure log behaviour")
225
270
 
226
- it "should not log the body" do
227
- expect(subject).to have_received(:log_failure).with(anything, hash_not_including(:body))
271
+ it "retries" do
272
+ expect(subject).to have_received(:send_event).exactly(2).times
228
273
  end
274
+ end
229
275
 
230
- context "with debug log level" do
231
- before :all do
232
- @current_log_level = LogStash::Logging::Logger.get_logging_context.get_root_logger.get_level.to_s.downcase
233
- LogStash::Logging::Logger.configure_logging "debug"
234
- end
235
- after :all do
236
- LogStash::Logging::Logger.configure_logging @current_log_level
276
+ context "on non-retryable unknown exception" do
277
+ before :each do
278
+ raised = false
279
+ original_method = subject.client.method(:send)
280
+ allow(subject).to receive(:send_event).and_call_original
281
+ expect(subject.client).to receive(:send) do |*args|
282
+ unless raised
283
+ raised = true
284
+ raise ::Manticore::UnknownException.new("broken")
285
+ end
286
+ original_method.call(args)
237
287
  end
288
+ subject.multi_receive([event])
289
+ end
238
290
 
239
- it "should log a failure" do
240
- expect(subject).to have_received(:log_failure).with(any_args)
241
- end
291
+ include_examples("failure log behaviour")
242
292
 
243
- it "should not log headers" do
244
- expect(subject).to have_received(:log_failure).with(anything, hash_including(:headers))
293
+ it "does not retry" do
294
+ expect(subject).to have_received(:send_event).exactly(1).times
295
+ end
296
+ end
297
+
298
+ context "on non-retryable exception" do
299
+ before :each do
300
+ raised = false
301
+ original_method = subject.client.method(:send)
302
+ allow(subject).to receive(:send_event).and_call_original
303
+ expect(subject.client).to receive(:send) do |*args|
304
+ unless raised
305
+ raised = true
306
+ raise RuntimeError.new("broken")
307
+ end
308
+ original_method.call(args)
245
309
  end
310
+ subject.multi_receive([event])
311
+ end
246
312
 
247
- it "should not log the body" do
248
- expect(subject).to have_received(:log_failure).with(anything, hash_including(:body))
313
+ include_examples("failure log behaviour")
314
+
315
+ it "does not retry" do
316
+ expect(subject).to have_received(:send_event).exactly(1).times
317
+ end
318
+ end
319
+
320
+ context "on retryable exception" do
321
+ before :each do
322
+ raised = false
323
+ original_method = subject.client.method(:send)
324
+ allow(subject).to receive(:send_event).and_call_original
325
+ expect(subject.client).to receive(:send) do |*args|
326
+ unless raised
327
+ raised = true
328
+ raise ::Manticore::Timeout.new("broken")
329
+ end
330
+ original_method.call(args)
249
331
  end
332
+ subject.multi_receive([event])
250
333
  end
334
+
335
+ it "retries" do
336
+ expect(subject).to have_received(:send_event).exactly(2).times
337
+ end
338
+
339
+ include_examples("failure log behaviour")
251
340
  end
252
341
  end
253
342
 
343
+
254
344
  LogStash::Outputs::Http::VALID_METHODS.each do |method|
255
345
  context "when using '#{method}'" do
256
346
  include_examples("verb behavior", method)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-http
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.3.0
4
+ version: 5.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-02-01 00:00:00.000000000 Z
11
+ date: 2022-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement