fluent-plugin-out-http 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.3
4
+ * Add configuration option: raise_on_error (default: true)
5
+ * To have the plugin raise exceptions like it did in 0.1.1: keep using your configuration as-is
6
+ * To supress all exceptions: add `raise_on_error false` to your configuration
7
+
3
8
  ## 0.1.2
4
9
  * #6 Catch all `StandardError`s during HTTP request to prevent td-agent from freezing
5
10
 
data/README.md CHANGED
@@ -4,22 +4,28 @@ A generic [fluentd][1] output plugin for sending logs to an HTTP endpoint.
4
4
 
5
5
  [![Build Status](https://travis-ci.org/ento/fluent-plugin-out-http.svg?branch=master)](https://travis-ci.org/ento/fluent-plugin-out-http)
6
6
 
7
- ## Configs
7
+ ## Configuration options
8
8
 
9
9
  <match *>
10
10
  type http
11
11
  endpoint_url http://localhost.local/api/
12
- http_method put
13
- serializer json
14
- rate_limit_msec 100
15
- authentication basic
16
- username alice
17
- password bobpop
12
+ http_method put # default: post
13
+ serializer json # default: form
14
+ rate_limit_msec 100 # default: 0 = no rate limiting
15
+ raise_on_error false # default: true
16
+ authentication basic # default: none
17
+ username alice # default: ''
18
+ password bobpop # default: ''
18
19
  </match>
19
20
 
21
+ ## Usage notes
22
+
23
+ If you'd like to retry failed requests, consider using [fluent-plugin-bufferize][3].
24
+
20
25
  ----
21
26
 
22
27
  Heavily based on [fluent-plugin-growthforecast][2]
23
28
 
24
29
  [1]: http://fluentd.org/
25
30
  [2]: https://github.com/tagomoris/fluent-plugin-growthforecast
31
+ [3]: https://github.com/sabottenda/fluent-plugin-bufferize
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |gem|
4
4
  gem.name = "fluent-plugin-out-http"
5
- gem.version = "0.1.2"
5
+ gem.version = "0.1.3"
6
6
  gem.authors = ["Marica Odagaki"]
7
7
  gem.email = ["ento.entotto@gmail.com"]
8
8
  gem.summary = %q{A generic Fluentd output plugin to send logs to an HTTP endpoint}
@@ -21,6 +21,9 @@ class Fluent::HTTPOutput < Fluent::Output
21
21
  # since the last one.
22
22
  config_param :rate_limit_msec, :integer, :default => 0
23
23
 
24
+ # Raise errors that were rescued during HTTP requests?
25
+ config_param :raise_on_error, :bool, :default => true
26
+
24
27
  # nil | 'none' | 'basic'
25
28
  config_param :authentication, :string, :default => nil
26
29
  config_param :username, :string, :default => ''
@@ -104,9 +107,10 @@ class Fluent::HTTPOutput < Fluent::Output
104
107
  end
105
108
  @last_request_time = Time.now.to_f
106
109
  res = Net::HTTP.new(uri.host, uri.port).start {|http| http.request(req) }
107
- rescue # rescue all StandardErrors
110
+ rescue => e # rescue all StandardErrors
108
111
  # server didn't respond
109
- $log.warn "Net::HTTP.#{req.method.capitalize} raises exception: #{$!.class}, '#{$!.message}'"
112
+ $log.warn "Net::HTTP.#{req.method.capitalize} raises exception: #{e.class}, '#{e.message}'"
113
+ raise e if @raise_on_error
110
114
  else
111
115
  unless res and res.is_a?(Net::HTTPSuccess)
112
116
  res_summary = if res
@@ -151,6 +151,11 @@ class HTTPOutputTest < HTTPOutputTestBase
151
151
  endpoint_url https://127.0.0.1:#{TEST_LISTEN_PORT + 1}/api/
152
152
  ]
153
153
 
154
+ CONFIG_HTTP_ERROR_SUPPRESSED = %[
155
+ endpoint_url https://127.0.0.1:#{TEST_LISTEN_PORT + 1}/api/
156
+ raise_on_error false
157
+ ]
158
+
154
159
  RATE_LIMIT_MSEC = 1200
155
160
 
156
161
  CONFIG_RATE_LIMIT = %[
@@ -229,8 +234,15 @@ class HTTPOutputTest < HTTPOutputTestBase
229
234
  assert_nil record[:auth]
230
235
  end
231
236
 
232
- def test_http_error
237
+ def test_http_error_is_raised
233
238
  d = create_driver CONFIG_HTTP_ERROR
239
+ assert_raise Errno::ECONNREFUSED do
240
+ d.emit({ 'field1' => 50 })
241
+ end
242
+ end
243
+
244
+ def test_http_error_is_suppressed_with_raise_on_error_false
245
+ d = create_driver CONFIG_HTTP_ERROR_SUPPRESSED
234
246
  d.emit({ 'field1' => 50 })
235
247
  d.run
236
248
  # drive asserts the next output chain is called;
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-out-http
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -107,7 +107,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
107
107
  version: '0'
108
108
  segments:
109
109
  - 0
110
- hash: 3802053956636342653
110
+ hash: -1675313951779573112
111
111
  required_rubygems_version: !ruby/object:Gem::Requirement
112
112
  none: false
113
113
  requirements:
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
116
  version: '0'
117
117
  segments:
118
118
  - 0
119
- hash: 3802053956636342653
119
+ hash: -1675313951779573112
120
120
  requirements: []
121
121
  rubyforge_project:
122
122
  rubygems_version: 1.8.23