logstash-core 5.0.0.alpha3.snapshot5-java → 5.0.0.alpha3.snapshot6-java

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.

Potentially problematic release.


This version of logstash-core might be problematic. Click here for more details.

Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/lib/logstash-core/version.rb +1 -1
  3. data/lib/logstash/api/{lib/helpers/app_helpers.rb → app_helpers.rb} +0 -0
  4. data/lib/logstash/api/command_factory.rb +34 -0
  5. data/lib/logstash/api/commands/base.rb +25 -0
  6. data/lib/logstash/api/commands/stats.rb +105 -0
  7. data/lib/logstash/api/commands/system/basicinfo_command.rb +23 -0
  8. data/lib/logstash/api/commands/system/plugins_command.rb +35 -0
  9. data/lib/logstash/api/modules/base.rb +41 -0
  10. data/lib/logstash/api/modules/node.rb +24 -0
  11. data/lib/logstash/api/modules/node_stats.rb +59 -0
  12. data/lib/logstash/api/modules/plugins.rb +15 -0
  13. data/lib/logstash/api/modules/root.rb +15 -0
  14. data/lib/logstash/api/modules/stats.rb +63 -0
  15. data/lib/logstash/api/rack_app.rb +33 -0
  16. data/lib/logstash/api/service.rb +73 -0
  17. data/lib/logstash/instrument/metric_store.rb +11 -1
  18. data/lib/logstash/instrument/periodic_poller/base.rb +2 -0
  19. data/lib/logstash/instrument/periodic_poller/jvm.rb +47 -2
  20. data/lib/logstash/util/thread_dump.rb +55 -0
  21. data/lib/logstash/version.rb +1 -1
  22. data/lib/logstash/webserver.rb +15 -49
  23. data/locales/en.yml +5 -5
  24. data/logstash-core.gemspec +3 -3
  25. data/spec/api/lib/api/node_spec.rb +2 -2
  26. data/spec/api/lib/api/node_stats_spec.rb +32 -57
  27. data/spec/api/lib/api/plugins_spec.rb +2 -2
  28. data/spec/api/lib/api/root_spec.rb +2 -2
  29. data/spec/api/lib/api/support/resource_dsl_methods.rb +47 -0
  30. data/spec/api/lib/commands/stats.rb +47 -0
  31. data/spec/api/spec_helper.rb +2 -5
  32. data/spec/logstash/agent_spec.rb +1 -1
  33. data/spec/logstash/instrument/periodic_poller/jvm_spec.rb +45 -0
  34. metadata +30 -38
  35. data/lib/logstash/api/init.ru +0 -31
  36. data/lib/logstash/api/lib/app.rb +0 -40
  37. data/lib/logstash/api/lib/app/command.rb +0 -29
  38. data/lib/logstash/api/lib/app/command_factory.rb +0 -29
  39. data/lib/logstash/api/lib/app/commands/stats/events_command.rb +0 -13
  40. data/lib/logstash/api/lib/app/commands/stats/hotthreads_command.rb +0 -120
  41. data/lib/logstash/api/lib/app/commands/stats/memory_command.rb +0 -25
  42. data/lib/logstash/api/lib/app/commands/system/basicinfo_command.rb +0 -15
  43. data/lib/logstash/api/lib/app/commands/system/plugins_command.rb +0 -28
  44. data/lib/logstash/api/lib/app/modules/node.rb +0 -25
  45. data/lib/logstash/api/lib/app/modules/node_stats.rb +0 -51
  46. data/lib/logstash/api/lib/app/modules/plugins.rb +0 -15
  47. data/lib/logstash/api/lib/app/modules/stats.rb +0 -21
  48. data/lib/logstash/api/lib/app/root.rb +0 -13
  49. data/lib/logstash/api/lib/app/service.rb +0 -61
  50. data/lib/logstash/api/lib/app/stats.rb +0 -56
  51. data/spec/api/lib/api/stats_spec.rb +0 -19
  52. data/spec/api/lib/commands/events_spec.rb +0 -17
  53. data/spec/api/lib/commands/jvm_spec.rb +0 -45
@@ -1,68 +1,43 @@
1
1
  # encoding: utf-8
2
2
  require_relative "../../spec_helper"
3
3
  require "sinatra"
4
- require "app/modules/node_stats"
4
+ require "logstash/api/modules/node_stats"
5
5
  require "logstash/json"
6
6
 
7
- describe LogStash::Api::NodeStats do
8
-
7
+ describe LogStash::Api::Modules::NodeStats do
9
8
  include Rack::Test::Methods
9
+ extend ResourceDSLMethods
10
10
 
11
- def app()
11
+ def app() # Used by Rack::Test::Methods
12
12
  described_class
13
13
  end
14
14
 
15
- let(:payload) { LogStash::Json.load(last_response.body) }
16
-
17
- context "#root" do
18
-
19
- before(:all) do
20
- do_request { get "/" }
21
- end
22
-
23
- it "respond OK" do
24
- expect(last_response).to be_ok
25
- end
26
-
27
- ["events", "jvm"].each do |key|
28
- it "contains #{key} information" do
29
- expect(payload).to include(key)
30
- end
31
- end
32
- end
33
-
34
- context "#events" do
35
-
36
- let(:payload) { LogStash::Json.load(last_response.body) }
37
-
38
- before(:all) do
39
- do_request { get "/events" }
40
- end
41
-
42
- it "respond OK" do
43
- expect(last_response).to be_ok
44
- end
45
-
46
- it "contains events information" do
47
- expect(payload).to include("events")
48
- end
49
- end
50
-
51
- context "#jvm" do
52
-
53
- let(:payload) { LogStash::Json.load(last_response.body) }
54
-
55
- before(:all) do
56
- do_request { get "/jvm" }
57
- end
58
-
59
- it "respond OK" do
60
- expect(last_response).to be_ok
61
- end
62
-
63
- it "contains memory information" do
64
- expect(payload).to include("mem")
65
- end
66
- end
67
-
15
+ # DSL describing response structure
16
+ root_structure = {
17
+ "events"=>{
18
+ "in"=>Numeric,
19
+ "filtered"=>Numeric,
20
+ "out"=>Numeric
21
+ },
22
+ "jvm"=>{
23
+ "threads"=>{
24
+ "count"=>Numeric,
25
+ "peak_count"=>Numeric
26
+ }
27
+ },
28
+ "process"=>{
29
+ "peak_open_file_descriptors"=>Numeric,
30
+ "max_file_descriptors"=>Numeric,
31
+ "open_file_descriptors"=>Numeric,
32
+ "mem"=>{
33
+ "total_virtual_in_bytes"=>Numeric
34
+ },
35
+ "cpu"=>{
36
+ "total_in_millis"=>Numeric,
37
+ "percent"=>Numeric
38
+ }
39
+ }
40
+ }
41
+
42
+ test_api_and_resources(root_structure)
68
43
  end
@@ -1,10 +1,10 @@
1
1
  # encoding: utf-8
2
2
  require_relative "../../spec_helper"
3
3
  require "sinatra"
4
- require "app/modules/plugins"
4
+ require "logstash/api/modules/plugins"
5
5
  require "logstash/json"
6
6
 
7
- describe LogStash::Api::Plugins do
7
+ describe LogStash::Api::Modules::Plugins do
8
8
 
9
9
  include Rack::Test::Methods
10
10
 
@@ -1,10 +1,10 @@
1
1
  # encoding: utf-8
2
2
  require_relative "../../spec_helper"
3
3
  require "sinatra"
4
- require "app/root"
4
+ require "logstash/api/modules/root"
5
5
  require "logstash/json"
6
6
 
7
- describe LogStash::Api::Root do
7
+ describe LogStash::Api::Modules::Root do
8
8
 
9
9
  include Rack::Test::Methods
10
10
 
@@ -0,0 +1,47 @@
1
+ module ResourceDSLMethods
2
+ # Convert a nested hash to a mapping of key paths to expected classes
3
+ def hash_to_mapping(h, path=[], mapping={})
4
+ h.each do |k,v|
5
+ if v.is_a?(Hash)
6
+ hash_to_mapping(v, path + [k], mapping)
7
+ else
8
+ full_path = path + [k]
9
+ mapping[full_path] = v
10
+ end
11
+ end
12
+ mapping
13
+ end
14
+
15
+ def test_api(expected, path)
16
+ context "GET #{path}" do
17
+ let(:payload) { LogStash::Json.load(last_response.body) }
18
+
19
+ before(:all) do
20
+ do_request { get path }
21
+ end
22
+
23
+ it "should respond OK" do
24
+ expect(last_response).to be_ok
25
+ end
26
+
27
+ hash_to_mapping(expected).each do |path,klass|
28
+ dotted = path.join(".")
29
+
30
+ it "should set '#{dotted}' to be a '#{klass}'" do
31
+ path_value = path.reduce(payload) {|acc,v| acc[v]}
32
+ expect(path_value).to be_a(klass), "could not find '#{dotted}' in #{payload}"
33
+ end
34
+ end
35
+ end
36
+
37
+ yield if block_given? # Add custom expectations
38
+ end
39
+
40
+ def test_api_and_resources(expected)
41
+ test_api(expected, "/")
42
+
43
+ expected.keys.each do |key|
44
+ test_api({key => expected[key]}, "/#{key}")
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,47 @@
1
+ # encoding: utf-8
2
+ require_relative "../../spec_helper"
3
+
4
+ describe LogStash::Api::Commands::Stats do
5
+
6
+ let(:report_method) { :run }
7
+ subject(:report) { do_request { report_class.new.send(report_method) } }
8
+
9
+ let(:report_class) { described_class }
10
+
11
+ describe "#events" do
12
+ let(:report_method) { :events }
13
+
14
+ it "return events information" do
15
+ expect(report.keys).to include(:in, :filtered, :out)
16
+ end
17
+ end
18
+
19
+ describe "#hot_threads" do
20
+ let(:report_method) { :hot_threads }
21
+
22
+ it "should return hot threads information as a string" do
23
+ expect(report.to_s).to be_a(String)
24
+ end
25
+
26
+ it "should return hot threads info as a hash" do
27
+ expect(report.to_hash).to be_a(Hash)
28
+ end
29
+ end
30
+
31
+ describe "memory stats" do
32
+ let(:report_method) { :memory }
33
+
34
+ it "return hot threads information" do
35
+ expect(report).not_to be_empty
36
+ end
37
+
38
+ it "return heap information" do
39
+ expect(report.keys).to include(:heap_used_in_bytes)
40
+ end
41
+
42
+ it "return non heap information" do
43
+ expect(report.keys).to include(:non_heap_used_in_bytes)
44
+ end
45
+
46
+ end
47
+ end
@@ -2,16 +2,13 @@
2
2
  API_ROOT = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "lib", "logstash", "api"))
3
3
 
4
4
  require "logstash/devutils/rspec/spec_helper"
5
+ require "api/lib/api/support/resource_dsl_methods"
5
6
 
6
7
  require "logstash/settings"
7
8
  require 'rack/test'
8
9
  require 'rspec'
9
10
  require "json"
10
11
 
11
- ENV['RACK_ENV'] = 'test'
12
-
13
- Rack::Builder.parse_file(File.join(API_ROOT, 'init.ru'))
14
-
15
12
  def read_fixture(name)
16
13
  path = File.join(File.dirname(__FILE__), "fixtures", name)
17
14
  File.read(path)
@@ -80,7 +77,7 @@ end
80
77
 
81
78
  ##
82
79
  # Method used to wrap up a request in between of a running
83
- # pipeline, this makes the hole execution model easier and
80
+ # pipeline, this makes the whole execution model easier and
84
81
  # more contained as some threads might go wild.
85
82
  ##
86
83
  def do_request(&block)
@@ -373,7 +373,7 @@ describe LogStash::Agent do
373
373
  @t.join
374
374
  end
375
375
 
376
- it "resets the metric collector" do
376
+ xit "resets the metric collector" do
377
377
  # We know that the store has more events coming in.
378
378
  sleep(0.01) while dummy_output.events.size < new_config_generator_counter
379
379
  snapshot = LogStash::Instrument::Collector.instance.snapshot_metric
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+ require 'logstash/instrument/periodic_poller/jvm'
3
+
4
+ describe LogStash::Instrument::PeriodicPoller::JVM do
5
+ let(:metric) { LogStash::Instrument::Metric.new }
6
+ let(:options) { {} }
7
+ subject(:jvm) { described_class.new(metric, options) }
8
+
9
+ it "should initialize cleanly" do
10
+ expect { jvm }.not_to raise_error
11
+ end
12
+
13
+ describe "collections" do
14
+ subject(:collection) { jvm.collect }
15
+
16
+ it "should run cleanly" do
17
+ expect { collection }.not_to raise_error
18
+ end
19
+
20
+ describe "metrics" do
21
+ let(:snapshot_store) { metric.collector.snapshot_metric.metric_store }
22
+ subject(:jvm_metrics) { snapshot_store.get_shallow(:jvm, :process) }
23
+
24
+ # Make looking up metric paths easy when given varargs of keys
25
+ # e.g. mval(:parent, :child)
26
+ def mval(*metric_path)
27
+ metric_path.reduce(jvm_metrics) {|acc,k| acc[k]}.value
28
+ end
29
+
30
+ [
31
+ :max_file_descriptors,
32
+ :open_file_descriptors,
33
+ :peak_open_file_descriptors,
34
+ [:mem, :total_virtual_in_bytes],
35
+ [:cpu, :total_in_millis],
36
+ [:cpu, :percent]
37
+ ].each do |path|
38
+ path = Array(path)
39
+ it "should have a value for #{path} that is Numeric" do
40
+ expect(mval(*path)).to be_a(Numeric)
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
metadata CHANGED
@@ -1,21 +1,21 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0.alpha3.snapshot5
4
+ version: 5.0.0.alpha3.snapshot6
5
5
  platform: java
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-26 00:00:00.000000000 Z
11
+ date: 2016-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
15
15
  requirements:
16
16
  - - '='
17
17
  - !ruby/object:Gem::Version
18
- version: 5.0.0.alpha3.snapshot5
18
+ version: 5.0.0.alpha3.snapshot6
19
19
  name: logstash-core-event-java
20
20
  prerelease: false
21
21
  type: :runtime
@@ -23,7 +23,7 @@ dependencies:
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 5.0.0.alpha3.snapshot5
26
+ version: 5.0.0.alpha3.snapshot6
27
27
  - !ruby/object:Gem::Dependency
28
28
  requirement: !ruby/object:Gem::Requirement
29
29
  requirements:
@@ -147,10 +147,7 @@ dependencies:
147
147
  requirements:
148
148
  - - ~>
149
149
  - !ruby/object:Gem::Version
150
- version: '2.16'
151
- - - '>='
152
- - !ruby/object:Gem::Version
153
- version: 2.16.0
150
+ version: 3.4.0
154
151
  name: puma
155
152
  prerelease: false
156
153
  type: :runtime
@@ -158,10 +155,7 @@ dependencies:
158
155
  requirements:
159
156
  - - ~>
160
157
  - !ruby/object:Gem::Version
161
- version: '2.16'
162
- - - '>='
163
- - !ruby/object:Gem::Version
164
- version: 2.16.0
158
+ version: 3.4.0
165
159
  - !ruby/object:Gem::Dependency
166
160
  requirement: !ruby/object:Gem::Requirement
167
161
  requirements:
@@ -195,15 +189,15 @@ dependencies:
195
189
  requirements:
196
190
  - - ~>
197
191
  - !ruby/object:Gem::Version
198
- version: 0.3.1
199
- name: jruby-monitoring
192
+ version: 0.4.2
193
+ name: jrmonitor
200
194
  prerelease: false
201
195
  type: :runtime
202
196
  version_requirements: !ruby/object:Gem::Requirement
203
197
  requirements:
204
198
  - - ~>
205
199
  - !ruby/object:Gem::Version
206
- version: 0.3.1
200
+ version: 0.4.2
207
201
  - !ruby/object:Gem::Dependency
208
202
  requirement: !ruby/object:Gem::Requirement
209
203
  requirements:
@@ -299,23 +293,20 @@ files:
299
293
  - lib/logstash-core/logstash-core.rb
300
294
  - lib/logstash-core/version.rb
301
295
  - lib/logstash/agent.rb
302
- - lib/logstash/api/init.ru
303
- - lib/logstash/api/lib/app.rb
304
- - lib/logstash/api/lib/app/command.rb
305
- - lib/logstash/api/lib/app/command_factory.rb
306
- - lib/logstash/api/lib/app/commands/stats/events_command.rb
307
- - lib/logstash/api/lib/app/commands/stats/hotthreads_command.rb
308
- - lib/logstash/api/lib/app/commands/stats/memory_command.rb
309
- - lib/logstash/api/lib/app/commands/system/basicinfo_command.rb
310
- - lib/logstash/api/lib/app/commands/system/plugins_command.rb
311
- - lib/logstash/api/lib/app/modules/node.rb
312
- - lib/logstash/api/lib/app/modules/node_stats.rb
313
- - lib/logstash/api/lib/app/modules/plugins.rb
314
- - lib/logstash/api/lib/app/modules/stats.rb
315
- - lib/logstash/api/lib/app/root.rb
316
- - lib/logstash/api/lib/app/service.rb
317
- - lib/logstash/api/lib/app/stats.rb
318
- - lib/logstash/api/lib/helpers/app_helpers.rb
296
+ - lib/logstash/api/app_helpers.rb
297
+ - lib/logstash/api/command_factory.rb
298
+ - lib/logstash/api/commands/base.rb
299
+ - lib/logstash/api/commands/stats.rb
300
+ - lib/logstash/api/commands/system/basicinfo_command.rb
301
+ - lib/logstash/api/commands/system/plugins_command.rb
302
+ - lib/logstash/api/modules/base.rb
303
+ - lib/logstash/api/modules/node.rb
304
+ - lib/logstash/api/modules/node_stats.rb
305
+ - lib/logstash/api/modules/plugins.rb
306
+ - lib/logstash/api/modules/root.rb
307
+ - lib/logstash/api/modules/stats.rb
308
+ - lib/logstash/api/rack_app.rb
309
+ - lib/logstash/api/service.rb
319
310
  - lib/logstash/codecs/base.rb
320
311
  - lib/logstash/config/config_ast.rb
321
312
  - lib/logstash/config/cpu_core_strategy.rb
@@ -383,6 +374,7 @@ files:
383
374
  - lib/logstash/util/prctl.rb
384
375
  - lib/logstash/util/retryable.rb
385
376
  - lib/logstash/util/socket_peer.rb
377
+ - lib/logstash/util/thread_dump.rb
386
378
  - lib/logstash/util/unicode_trimmer.rb
387
379
  - lib/logstash/util/worker_threads_default_printer.rb
388
380
  - lib/logstash/util/wrapped_synchronous_queue.rb
@@ -394,9 +386,8 @@ files:
394
386
  - spec/api/lib/api/node_stats_spec.rb
395
387
  - spec/api/lib/api/plugins_spec.rb
396
388
  - spec/api/lib/api/root_spec.rb
397
- - spec/api/lib/api/stats_spec.rb
398
- - spec/api/lib/commands/events_spec.rb
399
- - spec/api/lib/commands/jvm_spec.rb
389
+ - spec/api/lib/api/support/resource_dsl_methods.rb
390
+ - spec/api/lib/commands/stats.rb
400
391
  - spec/api/spec_helper.rb
401
392
  - spec/conditionals_spec.rb
402
393
  - spec/logstash/agent_spec.rb
@@ -417,6 +408,7 @@ files:
417
408
  - spec/logstash/instrument/metric_type/gauge_spec.rb
418
409
  - spec/logstash/instrument/namespaced_metric_spec.rb
419
410
  - spec/logstash/instrument/null_metric_spec.rb
411
+ - spec/logstash/instrument/periodic_poller/jvm_spec.rb
420
412
  - spec/logstash/java_integration_spec.rb
421
413
  - spec/logstash/json_spec.rb
422
414
  - spec/logstash/output_delegator_spec.rb
@@ -470,9 +462,8 @@ test_files:
470
462
  - spec/api/lib/api/node_stats_spec.rb
471
463
  - spec/api/lib/api/plugins_spec.rb
472
464
  - spec/api/lib/api/root_spec.rb
473
- - spec/api/lib/api/stats_spec.rb
474
- - spec/api/lib/commands/events_spec.rb
475
- - spec/api/lib/commands/jvm_spec.rb
465
+ - spec/api/lib/api/support/resource_dsl_methods.rb
466
+ - spec/api/lib/commands/stats.rb
476
467
  - spec/api/spec_helper.rb
477
468
  - spec/conditionals_spec.rb
478
469
  - spec/logstash/agent_spec.rb
@@ -493,6 +484,7 @@ test_files:
493
484
  - spec/logstash/instrument/metric_type/gauge_spec.rb
494
485
  - spec/logstash/instrument/namespaced_metric_spec.rb
495
486
  - spec/logstash/instrument/null_metric_spec.rb
487
+ - spec/logstash/instrument/periodic_poller/jvm_spec.rb
496
488
  - spec/logstash/java_integration_spec.rb
497
489
  - spec/logstash/json_spec.rb
498
490
  - spec/logstash/output_delegator_spec.rb