|
20 | 20 | describe LogStash::Instrument::MetricStore do |
21 | 21 | let(:namespaces) { [:root, :pipelines, :pipeline_01] } |
22 | 22 | let(:key) { :events_in } |
23 | | - let(:counter) { LogStash::Instrument::MetricType::Counter.new(namespaces, key) } |
| 23 | + let(:counter) { org.logstash.instrument.metrics.counter.LongCounter.new(key.to_s) } |
24 | 24 |
|
25 | 25 | context "when the metric object doesn't exist" do |
26 | 26 | it "store the object" do |
|
33 | 33 | end |
34 | 34 |
|
35 | 35 | context "when the metric object exist in the namespace" do |
36 | | - let(:new_counter) { LogStash::Instrument::MetricType::Counter.new(namespaces, key) } |
| 36 | + let(:new_counter) { org.logstash.instrument.metrics.counter.LongCounter.new(key.to_s) } |
37 | 37 |
|
38 | 38 | it "return the object" do |
39 | 39 | subject.fetch_or_store(namespaces, key, counter) |
|
53 | 53 | context "retrieving events" do |
54 | 54 | let(:metric_events) { |
55 | 55 | [ |
56 | | - [[:node, :sashimi, :pipelines, :pipeline01, :plugins, :"logstash-output-elasticsearch"], :event_in, :increment], |
57 | | - [[:node, :sashimi, :pipelines, :pipeline01], :processed_events_in, :increment], |
58 | | - [[:node, :sashimi, :pipelines, :pipeline01], :processed_events_out, :increment], |
59 | | - [[:node, :sashimi, :pipelines, :pipeline02], :processed_events_out, :increment], |
| 56 | + [[:node, :sashimi, :pipelines, :pipeline01, :plugins, :"logstash-output-elasticsearch"], :event_in], |
| 57 | + [[:node, :sashimi, :pipelines, :pipeline01], :processed_events_in], |
| 58 | + [[:node, :sashimi, :pipelines, :pipeline01], :processed_events_out], |
| 59 | + [[:node, :sashimi, :pipelines, :pipeline02], :processed_events_out], |
60 | 60 | ] |
61 | 61 | } |
62 | 62 |
|
63 | 63 | before :each do |
64 | 64 | # Lets add a few metrics in the store before trying to find them |
65 | | - metric_events.each do |namespaces, metric_key, action| |
66 | | - metric = subject.fetch_or_store(namespaces, metric_key, LogStash::Instrument::MetricType::Counter.new(namespaces, metric_key)) |
67 | | - metric.execute(action) |
| 65 | + metric_events.each do |namespaces, metric_key| |
| 66 | + metric = subject.fetch_or_store(namespaces, metric_key, org.logstash.instrument.metrics.counter.LongCounter.new(metric_key.to_s)) |
| 67 | + metric.increment |
68 | 68 | end |
69 | 69 | end |
70 | 70 |
|
|
96 | 96 |
|
97 | 97 | it "allow to retrieve a specific metrics" do |
98 | 98 | metrics = subject.get(:node, :sashimi, :pipelines, :pipeline01, :plugins, :"logstash-output-elasticsearch", :event_in) |
99 | | - 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))))))))) |
| 99 | + 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(org.logstash.instrument.metrics.counter.LongCounter))))))))) |
100 | 100 | end |
101 | 101 |
|
102 | 102 | context "with filtered keys" do |
|
142 | 142 |
|
143 | 143 | it "allow to retrieve a specific metrics" do |
144 | 144 | metrics = subject.get_with_path("node/sashimi/pipelines/pipeline01/plugins/logstash-output-elasticsearch/event_in") |
145 | | - 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))))))))) |
| 145 | + 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(org.logstash.instrument.metrics.counter.LongCounter))))))))) |
146 | 146 | end |
147 | 147 |
|
148 | 148 | context "with filtered keys" do |
|
260 | 260 | describe "#prune" do |
261 | 261 | let(:metric_events) { |
262 | 262 | [ |
263 | | - [[:node, :sashimi, :pipelines, :pipeline01, :plugins, :"logstash-output-elasticsearch"], :event_in, :increment], |
264 | | - [[:node, :sashimi, :pipelines, :pipeline01], :processed_events_in, :increment], |
265 | | - [[:node, :sashimi, :pipelines, :pipeline01], :processed_events_out, :increment], |
266 | | - [[:node, :sashimi, :pipelines, :pipeline02], :processed_events_out, :increment], |
| 263 | + [[:node, :sashimi, :pipelines, :pipeline01, :plugins, :"logstash-output-elasticsearch"], :event_in], |
| 264 | + [[:node, :sashimi, :pipelines, :pipeline01], :processed_events_in], |
| 265 | + [[:node, :sashimi, :pipelines, :pipeline01], :processed_events_out], |
| 266 | + [[:node, :sashimi, :pipelines, :pipeline02], :processed_events_out], |
267 | 267 | ] |
268 | 268 | } |
269 | 269 |
|
270 | 270 | before :each do |
271 | 271 | # Lets add a few metrics in the store before trying to find them |
272 | | - metric_events.each do |namespaces, metric_key, action| |
273 | | - metric = subject.fetch_or_store(namespaces, metric_key, LogStash::Instrument::MetricType::Counter.new(namespaces, metric_key)) |
274 | | - metric.execute(action) |
| 272 | + metric_events.each do |namespaces, metric_key| |
| 273 | + metric = subject.fetch_or_store(namespaces, metric_key, org.logstash.instrument.metrics.counter.LongCounter.new(metric_key.to_s)) |
| 274 | + metric.increment |
275 | 275 | end |
276 | 276 | end |
277 | 277 |
|
|
0 commit comments