logstash-output-http 2.0.5 → 2.1.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
  SHA1:
3
- metadata.gz: f9f8204839f653dead5f53cdf9de9158aeacd061
4
- data.tar.gz: 68463deb8cad8e5f559604e379c8b5c7570178ff
3
+ metadata.gz: fae9178467d58576560fe35574cd6a2c66363d09
4
+ data.tar.gz: a631d6b89069d8c42a0bbf07a5e187cfdadd4bd0
5
5
  SHA512:
6
- metadata.gz: 9ccf7a294708db2364966b117365001aa9c1f176efd85e1fc3f924409e565ccf6b0232e9418c50ce5a34c8944cd435e77fa28b3374b896501896ad47f7d4f280
7
- data.tar.gz: 479985e604fabcf939fc34c93dab8adc3a98f600228a5474d79b0fd6478232f93511ba49822c97cb3a9a73e9c9f3003925f972198d0b3ae692d65b413bc06c8b
6
+ metadata.gz: 0232e0887bcda5e10903210fb6d0556aad188deca1f64f1415ce697024f06f2d387211d59e8446b6e6cdaa88074f9618452ed1b3108b53d2436f28b8e23b2cd4
7
+ data.tar.gz: 74ffbf0a24cb748f8ba2f3518ed321c6366295ab3a7de7f7cccd01540b757d723840075206f5a9c744be0ca8bd2784329f9be6f190feeeeaebe61f74090e3387
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 2.1.0
2
+ - Properly close the client on #close
3
+ - Optimized execution for Logstash 2.2 ng pipeline
4
+
1
5
  ## 2.0.5
2
6
  - fixed memory leak
3
7
 
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # Logstash Plugin
2
2
 
3
+ [![Travis Build Status](https://travis-ci.org/logstash-plugins/logstash-output-http.svg)](https://travis-ci.org/logstash-plugins/logstash-output-http)
4
+
3
5
  This is a plugin for [Logstash](https://github.com/elastic/logstash).
4
6
 
5
7
  It is fully free and fully open source. The license is Apache 2.0, meaning you are pretty much free to use it however you want in whatever way.
@@ -89,31 +89,36 @@ class LogStash::Outputs::Http < LogStash::Outputs::Base
89
89
  validate_format!
90
90
  end # def register
91
91
 
92
- # TODO: (colin) the request call sequence + async handling will have to be reworked when using
93
- # Maticore >= 5.0. I will set a version constrain in the gemspec for this.
94
- def receive(event)
92
+ def multi_receive(events)
93
+ events.each {|event| receive(event, :parallel)}
94
+ client.execute!
95
+ end
96
+
97
+ # Once we no longer need to support Logstash < 2.2 (pre-ng-pipeline)
98
+ # We don't need to handle :background style requests
99
+ #
100
+ # We use :background style requests for Logstash < 2.2 because before the microbatching
101
+ # pipeline performance is greatly improved by having some degree of async behavior.
102
+ #
103
+ # In Logstash 2.2 and after things are much simpler, we just run each batch in parallel
104
+ # This will make performance much easier to reason about, and more importantly let us guarantee
105
+ # that if `multi_receive` returns all items have been sent.
106
+ def receive(event, async_type=:background)
95
107
  body = event_body(event)
96
108
 
97
109
  # Block waiting for a token
98
- token = @request_tokens.pop
110
+ token = @request_tokens.pop if async_type == :background
99
111
 
100
112
  # Send the request
101
113
  url = event.sprintf(@url)
102
114
  headers = event_headers(event)
103
115
 
104
116
  # Create an async request
105
- request = client.send(@http_method, url, :body => body, :headers => headers, :async => true)
106
-
107
- # with Maticore version < 0.5 using :async => true places the requests in an @async_requests
108
- # list which is used & cleaned by Client#execute! but we are not using it here and we must
109
- # purge it manually to avoid leaking requests.
110
- client.clear_pending
111
-
112
- # attach handlers before performing request
117
+ request = client.send(async_type).send(@http_method, url, :body => body, :headers => headers)
113
118
 
114
119
  request.on_complete do
115
120
  # Make sure we return the token to the pool
116
- @request_tokens << token
121
+ @request_tokens << token if async_type == :background
117
122
  end
118
123
 
119
124
  request.on_success do |response|
@@ -138,8 +143,11 @@ class LogStash::Outputs::Http < LogStash::Outputs::Base
138
143
  )
139
144
  end
140
145
 
141
- # Invoke it using the Manticore Executor (CachedThreadPool) directly
142
- request_async_background(request)
146
+ request.call if async_type == :background
147
+ end
148
+
149
+ def close
150
+ client.close
143
151
  end
144
152
 
145
153
  private
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-output-http'
4
- s.version = '2.0.5'
4
+ s.version = '2.1.0'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "This output lets you `PUT` or `POST` events to a generic HTTP(S) endpoint"
7
7
  s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
@@ -20,12 +20,8 @@ Gem::Specification.new do |s|
20
20
  s.metadata = { "logstash_plugin" => "true", "logstash_group" => "output" }
21
21
 
22
22
  # Gem dependencies
23
- s.add_runtime_dependency "logstash-core", ">= 2.0.0.beta2", "< 3.0.0"
24
- s.add_runtime_dependency "logstash-mixin-http_client", ">= 2.0.2", "< 3.0.0"
25
-
26
- # Constrain Maticore dependency to less than 0.5.0 because of changes in the async handling
27
- # see note in http.rb line 92-93
28
- s.add_runtime_dependency "manticore", "< 0.5.0"
23
+ s.add_runtime_dependency "logstash-core", ">= 2.0.0", "< 3.0.0"
24
+ s.add_runtime_dependency "logstash-mixin-http_client", ">= 2.2.0", "< 3.0.0"
29
25
 
30
26
  s.add_development_dependency 'logstash-devutils'
31
27
  s.add_development_dependency 'sinatra'
@@ -92,6 +92,8 @@ describe LogStash::Outputs::Http do
92
92
  let(:pool_max) { 10 }
93
93
  let(:num_reqs) { pool_max / 2 }
94
94
  let(:client) { subject.client }
95
+ let(:client_proxy) { subject.client.background }
96
+
95
97
  subject {
96
98
  LogStash::Outputs::Http.new("url" => url,
97
99
  "http_method" => method,
@@ -99,11 +101,16 @@ describe LogStash::Outputs::Http do
99
101
  }
100
102
 
101
103
  before do
104
+ allow(client).to receive(:background).and_return(client_proxy)
102
105
  subject.register
103
106
  end
104
107
 
108
+ after do
109
+ subject.close
110
+ end
111
+
105
112
  it "should receive all the requests" do
106
- expect(client).to receive(:send).
113
+ expect(client_proxy).to receive(:send).
107
114
  with(method.to_sym, url, anything).
108
115
  exactly(num_reqs).times.
109
116
  and_call_original
@@ -112,15 +119,17 @@ describe LogStash::Outputs::Http do
112
119
  end
113
120
  end
114
121
 
115
- shared_examples("verb behavior") do |method|
122
+ shared_examples("verb behavior") do |method, async_type|
116
123
  subject { LogStash::Outputs::Http.new("url" => url, "http_method" => method, "pool_max" => 1) }
117
124
 
118
125
  let(:expected_method) { method.clone.to_sym }
119
126
  let(:client) { subject.client }
127
+ let(:client_proxy) { subject.client.send(async_type) }
120
128
 
121
129
  before do
130
+ allow(client).to receive(async_type).and_return(client_proxy)
122
131
  subject.register
123
- allow(client).to receive(:send).
132
+ allow(client_proxy).to receive(:send).
124
133
  with(expected_method, url, anything).
125
134
  and_call_original
126
135
  allow(subject).to receive(:log_failure).with(any_args)
@@ -129,11 +138,11 @@ describe LogStash::Outputs::Http do
129
138
  context "performing a get" do
130
139
  describe "invoking the request" do
131
140
  before do
132
- subject.receive(event)
141
+ subject.receive(event, async_type)
133
142
  end
134
143
 
135
144
  it "should execute the request" do
136
- expect(client).to have_received(:send).
145
+ expect(client_proxy).to have_received(:send).
137
146
  with(expected_method, url, anything)
138
147
  end
139
148
  end
@@ -152,8 +161,13 @@ describe LogStash::Outputs::Http do
152
161
  let(:url) { "http://localhost:#{port}/bad"}
153
162
 
154
163
  before do
155
- subject.receive(event)
156
- wait_for_request
164
+ subject.receive(event, async_type)
165
+
166
+ if async_type == :background
167
+ wait_for_request
168
+ else
169
+ subject.client.execute!
170
+ end
157
171
  end
158
172
 
159
173
  it "should log a failure" do
@@ -164,8 +178,12 @@ describe LogStash::Outputs::Http do
164
178
  end
165
179
 
166
180
  LogStash::Outputs::Http::VALID_METHODS.each do |method|
167
- context "when using '#{method}'" do
168
- include_examples("verb behavior", method)
181
+ context "when using '#{method}' via :background" do
182
+ include_examples("verb behavior", method, :background)
183
+ end
184
+
185
+ context "when using '#{method}' via :parallel" do
186
+ include_examples("verb behavior", method, :parallel)
169
187
  end
170
188
  end
171
189
 
metadata CHANGED
@@ -1,126 +1,112 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-http
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.5
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-16 00:00:00.000000000 Z
11
+ date: 2015-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: logstash-core
15
- version_requirements: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - '>='
18
- - !ruby/object:Gem::Version
19
- version: 2.0.0.beta2
20
- - - <
21
- - !ruby/object:Gem::Version
22
- version: 3.0.0
23
14
  requirement: !ruby/object:Gem::Requirement
24
15
  requirements:
25
16
  - - '>='
26
17
  - !ruby/object:Gem::Version
27
- version: 2.0.0.beta2
18
+ version: 2.0.0
28
19
  - - <
29
20
  - !ruby/object:Gem::Version
30
21
  version: 3.0.0
22
+ name: logstash-core
31
23
  prerelease: false
32
24
  type: :runtime
33
- - !ruby/object:Gem::Dependency
34
- name: logstash-mixin-http_client
35
25
  version_requirements: !ruby/object:Gem::Requirement
36
26
  requirements:
37
27
  - - '>='
38
28
  - !ruby/object:Gem::Version
39
- version: 2.0.2
29
+ version: 2.0.0
40
30
  - - <
41
31
  - !ruby/object:Gem::Version
42
32
  version: 3.0.0
33
+ - !ruby/object:Gem::Dependency
43
34
  requirement: !ruby/object:Gem::Requirement
44
35
  requirements:
45
36
  - - '>='
46
37
  - !ruby/object:Gem::Version
47
- version: 2.0.2
38
+ version: 2.2.0
48
39
  - - <
49
40
  - !ruby/object:Gem::Version
50
41
  version: 3.0.0
42
+ name: logstash-mixin-http_client
51
43
  prerelease: false
52
44
  type: :runtime
53
- - !ruby/object:Gem::Dependency
54
- name: manticore
55
45
  version_requirements: !ruby/object:Gem::Requirement
56
46
  requirements:
57
- - - <
47
+ - - '>='
58
48
  - !ruby/object:Gem::Version
59
- version: 0.5.0
60
- requirement: !ruby/object:Gem::Requirement
61
- requirements:
49
+ version: 2.2.0
62
50
  - - <
63
51
  - !ruby/object:Gem::Version
64
- version: 0.5.0
65
- prerelease: false
66
- type: :runtime
52
+ version: 3.0.0
67
53
  - !ruby/object:Gem::Dependency
68
- name: logstash-devutils
69
- version_requirements: !ruby/object:Gem::Requirement
70
- requirements:
71
- - - '>='
72
- - !ruby/object:Gem::Version
73
- version: '0'
74
54
  requirement: !ruby/object:Gem::Requirement
75
55
  requirements:
76
56
  - - '>='
77
57
  - !ruby/object:Gem::Version
78
58
  version: '0'
59
+ name: logstash-devutils
79
60
  prerelease: false
80
61
  type: :development
81
- - !ruby/object:Gem::Dependency
82
- name: sinatra
83
62
  version_requirements: !ruby/object:Gem::Requirement
84
63
  requirements:
85
64
  - - '>='
86
65
  - !ruby/object:Gem::Version
87
66
  version: '0'
67
+ - !ruby/object:Gem::Dependency
88
68
  requirement: !ruby/object:Gem::Requirement
89
69
  requirements:
90
70
  - - '>='
91
71
  - !ruby/object:Gem::Version
92
72
  version: '0'
73
+ name: sinatra
93
74
  prerelease: false
94
75
  type: :development
95
- - !ruby/object:Gem::Dependency
96
- name: webrick
97
76
  version_requirements: !ruby/object:Gem::Requirement
98
77
  requirements:
99
78
  - - '>='
100
79
  - !ruby/object:Gem::Version
101
80
  version: '0'
81
+ - !ruby/object:Gem::Dependency
102
82
  requirement: !ruby/object:Gem::Requirement
103
83
  requirements:
104
84
  - - '>='
105
85
  - !ruby/object:Gem::Version
106
86
  version: '0'
87
+ name: webrick
107
88
  prerelease: false
108
89
  type: :development
90
+ version_requirements: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
109
95
  description: This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program
110
96
  email: info@elastic.co
111
97
  executables: []
112
98
  extensions: []
113
99
  extra_rdoc_files: []
114
100
  files:
115
- - lib/logstash/outputs/http.rb
116
- - spec/outputs/http_spec.rb
117
- - logstash-output-http.gemspec
118
- - README.md
119
101
  - CHANGELOG.md
120
102
  - CONTRIBUTORS
121
103
  - Gemfile
122
104
  - LICENSE
123
105
  - NOTICE.TXT
106
+ - README.md
107
+ - lib/logstash/outputs/http.rb
108
+ - logstash-output-http.gemspec
109
+ - spec/outputs/http_spec.rb
124
110
  homepage: http://www.elastic.co/guide/en/logstash/current/index.html
125
111
  licenses:
126
112
  - Apache License (2.0)
@@ -143,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
143
129
  version: '0'
144
130
  requirements: []
145
131
  rubyforge_project:
146
- rubygems_version: 2.1.9
132
+ rubygems_version: 2.4.8
147
133
  signing_key:
148
134
  specification_version: 4
149
135
  summary: This output lets you `PUT` or `POST` events to a generic HTTP(S) endpoint