logstash-core 6.0.0.alpha2-java → 6.0.0.beta1-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.
Files changed (110) hide show
  1. checksums.yaml +5 -5
  2. data/gemspec_jars.rb +6 -4
  3. data/lib/logstash-core/logstash-core.jar +0 -0
  4. data/lib/logstash-core/logstash-core.rb +2 -2
  5. data/lib/logstash-core/version.rb +1 -1
  6. data/lib/logstash-core_jars.rb +14 -10
  7. data/lib/logstash/agent.rb +4 -2
  8. data/lib/logstash/api/commands/default_metadata.rb +1 -1
  9. data/lib/logstash/api/commands/hot_threads_reporter.rb +8 -2
  10. data/lib/logstash/api/commands/node.rb +2 -2
  11. data/lib/logstash/api/commands/stats.rb +2 -2
  12. data/lib/logstash/bootstrap_check/bad_ruby.rb +2 -2
  13. data/lib/logstash/bootstrap_check/default_config.rb +2 -3
  14. data/lib/logstash/compiler.rb +12 -12
  15. data/lib/logstash/compiler/lscl.rb +17 -7
  16. data/lib/logstash/compiler/treetop_monkeypatches.rb +1 -0
  17. data/lib/logstash/config/config_ast.rb +11 -1
  18. data/lib/logstash/config/mixin.rb +5 -0
  19. data/lib/logstash/config/modules_common.rb +101 -0
  20. data/lib/logstash/config/source/base.rb +75 -0
  21. data/lib/logstash/config/source/local.rb +52 -50
  22. data/lib/logstash/config/source/modules.rb +55 -0
  23. data/lib/logstash/config/source/multi_local.rb +54 -10
  24. data/lib/logstash/config/source_loader.rb +1 -0
  25. data/lib/logstash/config/string_escape.rb +27 -0
  26. data/lib/logstash/elasticsearch_client.rb +142 -0
  27. data/lib/logstash/environment.rb +5 -1
  28. data/lib/logstash/event.rb +0 -1
  29. data/lib/logstash/instrument/global_metrics.rb +13 -0
  30. data/lib/logstash/instrument/metric_store.rb +16 -13
  31. data/lib/logstash/instrument/metric_type/counter.rb +6 -18
  32. data/lib/logstash/instrument/metric_type/gauge.rb +6 -12
  33. data/lib/logstash/instrument/periodic_poller/dlq.rb +19 -0
  34. data/lib/logstash/instrument/periodic_pollers.rb +3 -1
  35. data/lib/logstash/logging/logger.rb +43 -14
  36. data/lib/logstash/modules/cli_parser.rb +74 -0
  37. data/lib/logstash/modules/elasticsearch_config.rb +22 -0
  38. data/lib/logstash/modules/elasticsearch_importer.rb +37 -0
  39. data/lib/logstash/modules/elasticsearch_resource.rb +10 -0
  40. data/lib/logstash/modules/file_reader.rb +36 -0
  41. data/lib/logstash/modules/kibana_base.rb +24 -0
  42. data/lib/logstash/modules/kibana_client.rb +122 -0
  43. data/lib/logstash/modules/kibana_config.rb +125 -0
  44. data/lib/logstash/modules/kibana_dashboards.rb +36 -0
  45. data/lib/logstash/modules/kibana_importer.rb +17 -0
  46. data/lib/logstash/modules/kibana_resource.rb +10 -0
  47. data/lib/logstash/modules/kibana_settings.rb +40 -0
  48. data/lib/logstash/modules/logstash_config.rb +120 -0
  49. data/lib/logstash/modules/resource_base.rb +38 -0
  50. data/lib/logstash/modules/scaffold.rb +50 -0
  51. data/lib/logstash/modules/settings_merger.rb +23 -0
  52. data/lib/logstash/modules/util.rb +17 -0
  53. data/lib/logstash/namespace.rb +1 -0
  54. data/lib/logstash/pipeline.rb +66 -27
  55. data/lib/logstash/pipeline_settings.rb +1 -0
  56. data/lib/logstash/plugins/registry.rb +1 -0
  57. data/lib/logstash/runner.rb +47 -3
  58. data/lib/logstash/settings.rb +20 -1
  59. data/lib/logstash/util/dead_letter_queue_manager.rb +1 -1
  60. data/lib/logstash/util/safe_uri.rb +146 -11
  61. data/lib/logstash/util/thread_dump.rb +4 -3
  62. data/lib/logstash/util/wrapped_acked_queue.rb +28 -24
  63. data/lib/logstash/util/wrapped_synchronous_queue.rb +19 -20
  64. data/lib/logstash/version.rb +1 -1
  65. data/locales/en.yml +56 -1
  66. data/logstash-core.gemspec +6 -4
  67. data/spec/logstash/agent/converge_spec.rb +2 -2
  68. data/spec/logstash/agent_spec.rb +11 -3
  69. data/spec/logstash/api/modules/logging_spec.rb +13 -7
  70. data/spec/logstash/api/modules/node_plugins_spec.rb +23 -5
  71. data/spec/logstash/api/modules/node_spec.rb +17 -15
  72. data/spec/logstash/api/modules/node_stats_spec.rb +0 -1
  73. data/spec/logstash/api/modules/plugins_spec.rb +40 -9
  74. data/spec/logstash/api/modules/root_spec.rb +0 -1
  75. data/spec/logstash/api/rack_app_spec.rb +2 -1
  76. data/spec/logstash/compiler/compiler_spec.rb +54 -7
  77. data/spec/logstash/config/config_ast_spec.rb +47 -8
  78. data/spec/logstash/config/mixin_spec.rb +14 -2
  79. data/spec/logstash/config/pipeline_config_spec.rb +7 -7
  80. data/spec/logstash/config/source/local_spec.rb +5 -2
  81. data/spec/logstash/config/source/multi_local_spec.rb +56 -10
  82. data/spec/logstash/config/source_loader_spec.rb +1 -1
  83. data/spec/logstash/config/string_escape_spec.rb +24 -0
  84. data/spec/logstash/event_spec.rb +9 -0
  85. data/spec/logstash/filters/base_spec.rb +1 -1
  86. data/spec/logstash/instrument/metric_store_spec.rb +2 -3
  87. data/spec/logstash/instrument/metric_type/counter_spec.rb +0 -12
  88. data/spec/logstash/instrument/metric_type/gauge_spec.rb +1 -8
  89. data/spec/logstash/instrument/periodic_poller/dlq_spec.rb +17 -0
  90. data/spec/logstash/instrument/periodic_poller/jvm_spec.rb +1 -1
  91. data/spec/logstash/legacy_ruby_event_spec.rb +0 -9
  92. data/spec/logstash/legacy_ruby_timestamp_spec.rb +19 -14
  93. data/spec/logstash/modules/cli_parser_spec.rb +129 -0
  94. data/spec/logstash/modules/logstash_config_spec.rb +56 -0
  95. data/spec/logstash/modules/scaffold_spec.rb +239 -0
  96. data/spec/logstash/pipeline_dlq_commit_spec.rb +1 -1
  97. data/spec/logstash/pipeline_spec.rb +87 -20
  98. data/spec/logstash/runner_spec.rb +122 -5
  99. data/spec/logstash/setting_spec.rb +2 -2
  100. data/spec/logstash/settings/splittable_string_array_spec.rb +51 -0
  101. data/spec/logstash/timestamp_spec.rb +8 -2
  102. data/spec/logstash/util/safe_uri_spec.rb +16 -0
  103. data/spec/logstash/util/wrapped_acked_queue_spec.rb +63 -0
  104. data/spec/logstash/util/wrapped_synchronous_queue_spec.rb +0 -22
  105. data/spec/support/helpers.rb +1 -1
  106. data/spec/support/matchers.rb +21 -4
  107. metadata +102 -19
  108. data/lib/logstash/instrument/metric_type/base.rb +0 -31
  109. data/lib/logstash/program.rb +0 -14
  110. data/lib/logstash/string_interpolation.rb +0 -18
@@ -6,6 +6,8 @@ require "logstash/config/grammar"
6
6
  require "logstash/config/config_ast"
7
7
 
8
8
  describe LogStashConfigParser do
9
+ let(:settings) { mock_settings({}) }
10
+
9
11
  context '#parse' do
10
12
  context "valid configuration" do
11
13
  it "should permit single-quoted attribute names" do
@@ -77,7 +79,7 @@ describe LogStashConfigParser do
77
79
  }
78
80
  CONFIG
79
81
  subject { LogStashConfigParser.new }
80
-
82
+
81
83
  it "should compile successfully" do
82
84
  result = subject.parse(config)
83
85
  expect(result).not_to(be_nil)
@@ -142,12 +144,50 @@ describe LogStashConfigParser do
142
144
  expect(config).to be_nil
143
145
  end
144
146
  end
147
+
148
+ context "when config.support_escapes" do
149
+ let(:parser) { LogStashConfigParser.new }
150
+
151
+ let(:processed_value) { 'The computer says, "No"' }
152
+
153
+ let(:config) {
154
+ parser.parse(%q(
155
+ input {
156
+ foo {
157
+ bar => "The computer says, \"No\""
158
+ }
159
+ }
160
+ ))
161
+ }
162
+
163
+ let(:compiled_string) { eval(config.recursive_select(LogStash::Config::AST::String).first.compile) }
164
+
165
+ before do
166
+ config.process_escape_sequences = escapes
167
+ end
168
+
169
+ context "is enabled" do
170
+ let(:escapes) { true }
171
+
172
+ it "should process escape sequences" do
173
+ expect(compiled_string).to be == processed_value
174
+ end
175
+ end
176
+
177
+ context "is false" do
178
+ let(:escapes) { false }
179
+
180
+ it "should not process escape sequences" do
181
+ expect(compiled_string).not_to be == processed_value
182
+ end
183
+ end
184
+ end
145
185
  end
146
186
 
147
187
  context "when using two plugin sections of the same type" do
148
188
  let(:pipeline_klass) do
149
189
  Class.new do
150
- def initialize(config)
190
+ def initialize(config, settings)
151
191
  grammar = LogStashConfigParser.new
152
192
  @config = grammar.parse(config)
153
193
  @code = @config.compile
@@ -166,7 +206,7 @@ describe LogStashConfigParser do
166
206
 
167
207
 
168
208
  it "should create a pipeline with both sections" do
169
- generated_objects = pipeline_klass.new(config_string).instance_variable_get("@generated_objects")
209
+ generated_objects = pipeline_klass.new(config_string, settings).instance_variable_get("@generated_objects")
170
210
  filters = generated_objects.keys.map(&:to_s).select {|obj_name| obj_name.match(/^filter.+?_\d+$/) }
171
211
  expect(filters.size).to eq(2)
172
212
  end
@@ -181,14 +221,13 @@ describe LogStashConfigParser do
181
221
 
182
222
 
183
223
  it "should create a pipeline with both sections" do
184
- generated_objects = pipeline_klass.new(config_string).instance_variable_get("@generated_objects")
224
+ generated_objects = pipeline_klass.new(config_string, settings).instance_variable_get("@generated_objects")
185
225
  outputs = generated_objects.keys.map(&:to_s).select {|obj_name| obj_name.match(/^output.+?_\d+$/) }
186
226
  expect(outputs.size).to eq(2)
187
227
  end
188
228
  end
189
229
  end
190
230
  context "when creating two instances of the same configuration" do
191
-
192
231
  let(:config_string) {
193
232
  "input { generator { } }
194
233
  filter {
@@ -201,7 +240,7 @@ describe LogStashConfigParser do
201
240
 
202
241
  let(:pipeline_klass) do
203
242
  Class.new do
204
- def initialize(config)
243
+ def initialize(config, settings)
205
244
  grammar = LogStashConfigParser.new
206
245
  @config = grammar.parse(config)
207
246
  @code = @config.compile
@@ -213,8 +252,8 @@ describe LogStashConfigParser do
213
252
 
214
253
  describe "generated conditional functionals" do
215
254
  it "should be created per instance" do
216
- instance_1 = pipeline_klass.new(config_string)
217
- instance_2 = pipeline_klass.new(config_string)
255
+ instance_1 = pipeline_klass.new(config_string, settings)
256
+ instance_2 = pipeline_klass.new(config_string, settings)
218
257
  generated_method_1 = instance_1.instance_variable_get("@generated_objects")[:cond_func_1]
219
258
  generated_method_2 = instance_2.instance_variable_get("@generated_objects")[:cond_func_1]
220
259
  expect(generated_method_1).to_not be(generated_method_2)
@@ -192,8 +192,8 @@ describe LogStash::Config::Mixin do
192
192
  expect(clone.uri.to_s).to eql(uri_hidden)
193
193
  end
194
194
 
195
- it "should make the real URI object available under #uri" do
196
- expect(subject.uri.uri).to be_a(::URI)
195
+ it "should make the real java.net.URI object available under #uri" do
196
+ expect(subject.uri.uri).to be_a(java.net.URI)
197
197
  end
198
198
 
199
199
  it "should obfuscate original_params" do
@@ -369,11 +369,13 @@ describe LogStash::Config::Mixin do
369
369
  before do
370
370
  ENV["FunString"] = "fancy"
371
371
  ENV["FunBool"] = "true"
372
+ ENV["SERVER_LS_TEST_ADDRESS"] = "some.host.address.tld"
372
373
  end
373
374
 
374
375
  after do
375
376
  ENV.delete("FunString")
376
377
  ENV.delete("FunBool")
378
+ ENV.delete("SERVER_LS_TEST_ADDRESS")
377
379
  end
378
380
 
379
381
  subject do
@@ -397,6 +399,16 @@ describe LogStash::Config::Mixin do
397
399
  expect(subject.nestedArray).to(be == { "level1" => [{ "key1" => "http://fancy:8080/blah.txt" }, { "key2" => "http://fancy:8080/foo.txt" }] })
398
400
  expect(subject.deepHash).to(be == { "level1" => { "level2" => { "level3" => { "key1" => "http://fancy:8080/blah.txt" } } } })
399
401
  end
402
+
403
+ it "should validate settings after interpolating ENV variables" do
404
+ expect {
405
+ Class.new(LogStash::Filters::Base) do
406
+ include LogStash::Config::Mixin
407
+ config_name "test"
408
+ config :server_address, :validate => :uri
409
+ end.new({"server_address" => "${SERVER_LS_TEST_ADDRESS}"})
410
+ }.not_to raise_error
411
+ end
400
412
  end
401
413
 
402
414
  context "should support $ in values" do
@@ -7,13 +7,13 @@ describe LogStash::Config::PipelineConfig do
7
7
  let(:pipeline_id) { :main }
8
8
  let(:ordered_config_parts) do
9
9
  [
10
- org.logstash.common.SourceWithMetadata.new("file", "/tmp/1", "input { generator1 }"),
11
- org.logstash.common.SourceWithMetadata.new("file", "/tmp/2", "input { generator2 }"),
12
- org.logstash.common.SourceWithMetadata.new("file", "/tmp/3", "input { generator3 }"),
13
- org.logstash.common.SourceWithMetadata.new("file", "/tmp/4", "input { generator4 }"),
14
- org.logstash.common.SourceWithMetadata.new("file", "/tmp/5", "input { generator5 }"),
15
- org.logstash.common.SourceWithMetadata.new("file", "/tmp/6", "input { generator6 }"),
16
- org.logstash.common.SourceWithMetadata.new("string", "config_string", "input { generator1 }"),
10
+ org.logstash.common.SourceWithMetadata.new("file", "/tmp/1", 0, 0, "input { generator1 }"),
11
+ org.logstash.common.SourceWithMetadata.new("file", "/tmp/2", 0, 0, "input { generator2 }"),
12
+ org.logstash.common.SourceWithMetadata.new("file", "/tmp/3", 0, 0, "input { generator3 }"),
13
+ org.logstash.common.SourceWithMetadata.new("file", "/tmp/4", 0, 0, "input { generator4 }"),
14
+ org.logstash.common.SourceWithMetadata.new("file", "/tmp/5", 0, 0, "input { generator5 }"),
15
+ org.logstash.common.SourceWithMetadata.new("file", "/tmp/6", 0, 0, "input { generator6 }"),
16
+ org.logstash.common.SourceWithMetadata.new("string", "config_string", 0, 0, "input { generator1 }"),
17
17
  ]
18
18
  end
19
19
 
@@ -288,13 +288,15 @@ describe LogStash::Config::Source::Local do
288
288
  let(:settings) do
289
289
  mock_settings(
290
290
  "config.string" => "#{filter_block} #{output_block}",
291
- "path.config" => config_file
291
+ "path.config" => config_file,
292
+ "modules.cli" => [],
293
+ "modules" => []
292
294
  )
293
295
  end
294
296
 
295
297
  # this should be impossible as the bootstrap checks should catch this
296
298
  it "raises an exception" do
297
- expect { subject.pipeline_configs }.to raise_error
299
+ expect { subject.pipeline_configs }.to raise_error(LogStash::ConfigurationError)
298
300
  end
299
301
  end
300
302
 
@@ -367,6 +369,7 @@ describe LogStash::Config::Source::Local do
367
369
  file = Stud::Temporary.file
368
370
  path = file.path
369
371
  file.write(config_string)
372
+ file.close # we need to flush the write
370
373
  path
371
374
  end
372
375
  let(:settings) { mock_settings( "path.config" => config_path) }
@@ -18,10 +18,52 @@ describe LogStash::Config::Source::MultiLocal do
18
18
  allow(subject).to receive(:pipelines_yaml_location).and_return(pipelines_yaml_location)
19
19
  end
20
20
 
21
+ describe "#config_conflict?" do
22
+ context "when `config.string` is set" do
23
+ let(:settings) do
24
+ mock_settings("config.string" => "input {} output {}")
25
+ end
26
+ it "returns false" do
27
+ expect(subject.config_conflict?).to be_falsey
28
+ expect(subject.conflict_messages).to be_empty
29
+ end
30
+ end
31
+
32
+ context "when `config.path` is set" do
33
+ let(:config_file) { temporary_file("") }
34
+
35
+ let(:settings) do
36
+ mock_settings("path.config" => config_file)
37
+ end
38
+ it "returns false" do
39
+ expect(subject.config_conflict?).to be_falsey
40
+ expect(subject.conflict_messages).to be_empty
41
+ end
42
+ end
43
+
44
+ context "when `pipelines.yml` is not set" do
45
+ let(:pipelines_yaml_location) { ::File.join(Stud::Temporary.pathname, "pipelines.yml") }
46
+ it "returns true with messages" do
47
+ expect(subject.config_conflict?).to be_truthy
48
+ expect(subject.conflict_messages).to include(/Failed to read pipelines yaml file. Location:/)
49
+ end
50
+ end
51
+
52
+ context "when `pipelines.yml` is only comments" do
53
+ before(:each) do
54
+ allow(subject).to receive(:read_pipelines_from_yaml).and_return(::YAML.load("# blah\n# blah\n# blah\n"))
55
+ end
56
+ it "returns true with messages" do
57
+ expect(subject.config_conflict?).to be_truthy
58
+ expect(subject.conflict_messages).to include(/Pipelines YAML file is empty. Location:/)
59
+ end
60
+ end
61
+ end
62
+
21
63
  describe "#match?" do
22
64
  context "when `config.string` is set" do
23
65
  let(:settings) do
24
- mock_settings("config.string" => "")
66
+ mock_settings("config.string" => "input {} output {}")
25
67
  end
26
68
  it "returns false" do
27
69
  expect(subject.match?).to be_falsey
@@ -29,7 +71,7 @@ describe LogStash::Config::Source::MultiLocal do
29
71
  end
30
72
 
31
73
  context "when `config.path` are set`" do
32
- let(:config_file) { temporary_file("") }
74
+ let(:config_file) { temporary_file("input {} output {}") }
33
75
 
34
76
  let(:settings) do
35
77
  mock_settings("path.config" => config_file)
@@ -42,27 +84,31 @@ describe LogStash::Config::Source::MultiLocal do
42
84
 
43
85
  context "when both `config.string` and `path.config` are set" do
44
86
  let(:settings) do
45
- mock_settings("config.string" => "", "path.config" => temporary_file(""))
87
+ mock_settings("config.string" => "input {} output {}", "path.config" => temporary_file("input {} output {}"))
46
88
  end
47
89
  it "returns false" do
48
90
  expect(subject.match?).to be_falsey
49
91
  end
50
92
  end
51
93
 
52
- context "when neither `config.path` nor `path.config` are set`" do
94
+ context "when neither `config.path` nor `path.config` are set` and pipelines.yml has configs" do
95
+ before do
96
+ allow(subject).to receive(:invalid_pipelines_detected?).and_return(false)
97
+ end
53
98
  it "returns true" do
54
99
  expect(subject.match?).to be_truthy
55
100
  end
56
101
  end
57
102
  end
103
+
58
104
  describe "#detect_duplicate_pipelines" do
59
105
  let(:retrieved_pipelines) { [{}] }
60
106
  let(:retrieved_pipelines_configs) { retrieved_pipelines.map {|h| mock_settings(h) } }
61
107
  context "when there are duplicate pipeline ids" do
62
108
  let(:retrieved_pipelines) do
63
109
  [
64
- {"pipeline.id" => "main", "config.string" => ""},
65
- {"pipeline.id" => "main", "config.string" => ""},
110
+ {"pipeline.id" => "main", "config.string" => "input {} output {}"},
111
+ {"pipeline.id" => "main", "config.string" => "input {} output {}"},
66
112
  ]
67
113
  end
68
114
  it "should raise a ConfigurationError" do
@@ -72,8 +118,8 @@ describe LogStash::Config::Source::MultiLocal do
72
118
  context "when there are no duplicate pipeline ids" do
73
119
  let(:retrieved_pipelines) do
74
120
  [
75
- {"pipeline.id" => "main", "config.string" => ""},
76
- {"pipeline.id" => "backup", "config.string" => ""},
121
+ {"pipeline.id" => "main", "config.string" => "input {} output {}"},
122
+ {"pipeline.id" => "backup", "config.string" => "input {} output {}"},
77
123
  ]
78
124
  end
79
125
  it "should not raise an error" do
@@ -85,8 +131,8 @@ describe LogStash::Config::Source::MultiLocal do
85
131
  describe "#pipeline_configs" do
86
132
  let(:retrieved_pipelines) do
87
133
  [
88
- { "pipeline.id" => "main", "config.string" => "" },
89
- { "pipeline.id" => "backup", "config.string" => "" }
134
+ { "pipeline.id" => "main", "config.string" => "input {} output {}" },
135
+ { "pipeline.id" => "backup", "config.string" => "input {} output {}" }
90
136
  ]
91
137
  end
92
138
  before(:each) do
@@ -4,7 +4,7 @@ require "logstash/config/source/base"
4
4
  require_relative "../../support/helpers"
5
5
 
6
6
  def temporary_pipeline_config(id, source, reader = "random_reader")
7
- config_part = org.logstash.common.SourceWithMetadata.new("local", "...", "input {} output {}")
7
+ config_part = org.logstash.common.SourceWithMetadata.new("local", "...", 0, 0, "input {} output {}")
8
8
  LogStash::Config::PipelineConfig.new(source, id, [config_part], LogStash::SETTINGS)
9
9
  end
10
10
 
@@ -0,0 +1,24 @@
1
+
2
+ require "logstash/config/string_escape"
3
+
4
+ describe LogStash::Config::StringEscape do
5
+ let(:result) { described_class.process_escapes(text) }
6
+
7
+ table = {
8
+ '\\"' => '"',
9
+ "\\'" => "'",
10
+ "\\n" => "\n",
11
+ "\\r" => "\r",
12
+ "\\t" => "\t",
13
+ "\\\\" => "\\",
14
+ }
15
+
16
+ table.each do |input, expected|
17
+ context "when processing #{input.inspect}" do
18
+ let(:text) { input }
19
+ it "should produce #{expected.inspect}" do
20
+ expect(result).to be == expected
21
+ end
22
+ end
23
+ end
24
+ end
@@ -84,6 +84,15 @@ describe LogStash::Event do
84
84
  expect(e.get("foo")).to eq("bar")
85
85
  end
86
86
 
87
+ it "should propagate changes to mutable strings to java APIs" do
88
+ e = LogStash::Event.new()
89
+ e.to_java.setField("foo", "bar")
90
+ expect(e.get("foo")).to eq("bar")
91
+ e.get("foo").gsub!(/bar/, 'pff')
92
+ expect(e.get("foo")).to eq("pff")
93
+ expect(e.to_java.getField("foo")).to eq("pff")
94
+ end
95
+
87
96
  it "should set deep hash values" do
88
97
  e = LogStash::Event.new()
89
98
  expect(e.set("[foo][bar]", "baz")).to eq("baz")
@@ -24,7 +24,7 @@ describe LogStash::Filters::Base do
24
24
  end
25
25
 
26
26
  it "should provide class public API" do
27
- [:register, :filter, :multi_filter, :execute, :threadsafe?, :filter_matched, :filter?, :close].each do |method|
27
+ [:register, :filter, :multi_filter, :execute, :threadsafe?, :close].each do |method|
28
28
  expect(subject).to respond_to(method)
29
29
  end
30
30
  end
@@ -1,6 +1,5 @@
1
1
  # encoding: utf-8
2
2
  require "logstash/instrument/metric_store"
3
- require "logstash/instrument/metric_type/base"
4
3
 
5
4
  describe LogStash::Instrument::MetricStore do
6
5
  let(:namespaces) { [ :root, :pipelines, :pipeline_01 ] }
@@ -81,7 +80,7 @@ describe LogStash::Instrument::MetricStore do
81
80
 
82
81
  it "allow to retrieve a specific metrics" do
83
82
  metrics = subject.get(:node, :sashimi, :pipelines, :pipeline01, :plugins, :"logstash-output-elasticsearch", :event_in)
84
- expect(metrics).to match(a_hash_including(:node => a_hash_including(:sashimi => a_hash_including(:pipelines => a_hash_including(:pipeline01 => a_hash_including(:plugins => a_hash_including(:"logstash-output-elasticsearch" => a_hash_including(:event_in => be_kind_of(LogStash::Instrument::MetricType::Base)))))))))
83
+ expect(metrics).to match(a_hash_including(:node => a_hash_including(:sashimi => a_hash_including(:pipelines => a_hash_including(:pipeline01 => a_hash_including(:plugins => a_hash_including(:"logstash-output-elasticsearch" => a_hash_including(:event_in => be_kind_of(LogStash::Instrument::MetricType::Counter)))))))))
85
84
  end
86
85
 
87
86
  context "with filtered keys" do
@@ -127,7 +126,7 @@ describe LogStash::Instrument::MetricStore do
127
126
 
128
127
  it "allow to retrieve a specific metrics" do
129
128
  metrics = subject.get_with_path("node/sashimi/pipelines/pipeline01/plugins/logstash-output-elasticsearch/event_in")
130
- expect(metrics).to match(a_hash_including(:node => a_hash_including(:sashimi => a_hash_including(:pipelines => a_hash_including(:pipeline01 => a_hash_including(:plugins => a_hash_including(:"logstash-output-elasticsearch" => a_hash_including(:event_in => be_kind_of(LogStash::Instrument::MetricType::Base)))))))))
129
+ expect(metrics).to match(a_hash_including(:node => a_hash_including(:sashimi => a_hash_including(:pipelines => a_hash_including(:pipeline01 => a_hash_including(:plugins => a_hash_including(:"logstash-output-elasticsearch" => a_hash_including(:event_in => be_kind_of(LogStash::Instrument::MetricType::Counter)))))))))
131
130
  end
132
131
 
133
132
  context "with filtered keys" do
@@ -14,22 +14,10 @@ describe LogStash::Instrument::MetricType::Counter do
14
14
  end
15
15
  end
16
16
 
17
- describe "#decrement" do
18
- it "decrement the counter" do
19
- expect{ subject.decrement }.to change { subject.value }.by(-1)
20
- end
21
- end
22
-
23
17
  context "When serializing to JSON" do
24
18
  it "serializes the value" do
25
19
  expect(LogStash::Json.dump(subject)).to eq("0")
26
20
  end
27
21
  end
28
22
 
29
- context "When creating a hash " do
30
- it "creates the hash from all the values" do
31
- metric_hash = { key => 0 }
32
- expect(subject.to_hash).to match(metric_hash)
33
- end
34
- end
35
23
  end
@@ -26,12 +26,5 @@ describe LogStash::Instrument::MetricType::Gauge do
26
26
  end
27
27
  end
28
28
 
29
- context "When creating a hash " do
30
- it "creates the hash from all the values" do
31
- metric_hash = {
32
- key => value
33
- }
34
- expect(subject.to_hash).to match(metric_hash)
35
- end
36
- end
29
+
37
30
  end