fluent-plugin-out-http 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -3,5 +3,6 @@
3
3
  .\#*
4
4
  *.gem
5
5
  .bundle
6
+ .ruby-version
6
7
  Gemfile.lock
7
8
  vendor
data/.travis.yml ADDED
@@ -0,0 +1,11 @@
1
+ rvm:
2
+ - 1.9.2
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - 2.1.0
6
+
7
+ gemfile:
8
+ - Gemfile
9
+
10
+ script: bundle exec rake test
11
+
data/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.1.2
4
+ * #6 Catch all `StandardError`s during HTTP request to prevent td-agent from freezing
5
+
3
6
  ## 0.1.1
4
7
  * #2 Use yajl instead of json as json serializer
5
8
  * #1 Fix a bug where a nil HTTP response caused the plugin to stop working
data/README.md CHANGED
@@ -1,7 +1,9 @@
1
- # fluent-plugin-out-http
1
+ # fluent-plugin-out-http, a plugin for [Fluentd](http://fluentd.org)
2
2
 
3
3
  A generic [fluentd][1] output plugin for sending logs to an HTTP endpoint.
4
4
 
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
+
5
7
  ## Configs
6
8
 
7
9
  <match *>
@@ -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.1"
5
+ gem.version = "0.1.2"
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}
@@ -97,25 +97,27 @@ class Fluent::HTTPOutput < Fluent::Output
97
97
  end
98
98
 
99
99
  res = nil
100
+
100
101
  begin
101
102
  if @auth and @auth == :basic
102
103
  req.basic_auth(@username, @password)
103
104
  end
104
105
  @last_request_time = Time.now.to_f
105
106
  res = Net::HTTP.new(uri.host, uri.port).start {|http| http.request(req) }
106
- rescue IOError, EOFError, SystemCallError
107
+ rescue # rescue all StandardErrors
107
108
  # server didn't respond
108
109
  $log.warn "Net::HTTP.#{req.method.capitalize} raises exception: #{$!.class}, '#{$!.message}'"
109
- end
110
- unless res and res.is_a?(Net::HTTPSuccess)
111
- res_summary = if res
112
- "#{res.code} #{res.message} #{res.body}"
113
- else
114
- "res=nil"
115
- end
116
- $log.warn "failed to #{req.method} #{uri} (#{res_summary})"
117
- end
118
- end
110
+ else
111
+ unless res and res.is_a?(Net::HTTPSuccess)
112
+ res_summary = if res
113
+ "#{res.code} #{res.message} #{res.body}"
114
+ else
115
+ "res=nil"
116
+ end
117
+ $log.warn "failed to #{req.method} #{uri} (#{res_summary})"
118
+ end #end unless
119
+ end # end begin
120
+ end # end send_request
119
121
 
120
122
  def handle_record(tag, time, record)
121
123
  req, uri = create_request(tag, time, record)
@@ -184,7 +184,7 @@ class HTTPOutputTest < HTTPOutputTestBase
184
184
  assert_equal '20', record[:form]['field2']
185
185
  assert_equal '10', record[:form]['field3']
186
186
  assert_equal '1', record[:form]['otherfield']
187
- assert_equal URI.escape("あ"), record[:form]['binary']
187
+ assert_equal URI.encode_www_form_component("あ").upcase, record[:form]['binary'].upcase
188
188
  assert_nil record[:auth]
189
189
 
190
190
  d.emit({ 'field1' => 50, 'field2' => 20, 'field3' => 10, 'otherfield' => 1 })
@@ -254,7 +254,8 @@ class HTTPOutputTest < HTTPOutputTestBase
254
254
  assert last_emit + RATE_LIMIT_MSEC > _current_msec, "Still under rate limiting interval"
255
255
  assert_equal 1, @posts.size
256
256
 
257
- sleep (last_emit + RATE_LIMIT_MSEC - _current_msec) * 0.001
257
+ wait_msec = 500
258
+ sleep (last_emit + RATE_LIMIT_MSEC - _current_msec + wait_msec) * 0.001
258
259
 
259
260
  assert last_emit + RATE_LIMIT_MSEC < _current_msec, "No longer under rate limiting interval"
260
261
  d.emit(record)
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.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-12-01 00:00:00.000000000 Z
12
+ date: 2014-09-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: yajl-ruby
@@ -83,6 +83,7 @@ extensions: []
83
83
  extra_rdoc_files: []
84
84
  files:
85
85
  - .gitignore
86
+ - .travis.yml
86
87
  - CHANGELOG.md
87
88
  - Gemfile
88
89
  - LICENSE.txt
@@ -106,7 +107,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
106
107
  version: '0'
107
108
  segments:
108
109
  - 0
109
- hash: 4460454963525016737
110
+ hash: 3802053956636342653
110
111
  required_rubygems_version: !ruby/object:Gem::Requirement
111
112
  none: false
112
113
  requirements:
@@ -115,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
115
116
  version: '0'
116
117
  segments:
117
118
  - 0
118
- hash: 4460454963525016737
119
+ hash: 3802053956636342653
119
120
  requirements: []
120
121
  rubyforge_project:
121
122
  rubygems_version: 1.8.23