fluent-plugin-elapsed-time 0.0.7 → 0.0.8

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: 95316fca33950f404743d84a29cba5533c1f09a7
4
- data.tar.gz: aac3ab464cfb475b7008971da6f0f8db41714ff0
3
+ metadata.gz: a9486c23f926fb9df5ffb3b43dc7a8f0c1f6cc8e
4
+ data.tar.gz: 5fc89bd6f09f28dae4bcd1506396e8dc046abf30
5
5
  SHA512:
6
- metadata.gz: 4c1dfa104a0ffbdcd0b67a348f219c29bc0fb2ae50fff4611d964eb44df7a3abde7c1903bfe1303ebcf802810008ade1bd7b4f15af16215d0119c3aa4732dc47
7
- data.tar.gz: ae092b3946153266d0da616916efd79645a85c15ab508856364ab51a624d833969e0a9b64096035ca6a00b8424211b526dbc5edb226f597060e1f1daadcbded1
6
+ metadata.gz: e3adf30806c1ea8f95e4debbd786bf03d9de8902e05f57fc168c3811cbb9e05d11ff274ce56232da350418e2b157d13e2fa30bbe32fb4ebb3449295d58796138
7
+ data.tar.gz: f82150ba8cf69d5b0157731ce284c9fc8b07e6b6c9760f03319b7f4fde6e09a3866a19a6918e96d7486ce9d0d59583c6659ac31ec4f745cbb8d18b81a237de6c
@@ -1,6 +1,8 @@
1
1
  rvm:
2
- - 1.9.3
3
- - 2.0.0
4
2
  - 2.1.*
3
+ - 2.2.*
4
+ - 2.3.0
5
5
  gemfile:
6
6
  - Gemfile
7
+ before_install:
8
+ - gem update bundler
@@ -1,3 +1,9 @@
1
+ ## 0.0.8 (2017/02/09)
2
+
3
+ Enhancement:
4
+
5
+ * Support v0.14
6
+
1
7
  ## 0.0.7 (2014/11/22)
2
8
 
3
9
  Changes:
@@ -3,7 +3,7 @@ $:.push File.expand_path('../lib', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
5
  gem.name = "fluent-plugin-elapsed-time"
6
- gem.version = "0.0.7"
6
+ gem.version = "0.0.8"
7
7
  gem.authors = ["Naotoshi Seo"]
8
8
  gem.email = "sonots@gmail.com"
9
9
  gem.homepage = "https://github.com/sonots/fluent-plugin-elapsed-time"
@@ -23,4 +23,5 @@ Gem::Specification.new do |gem|
23
23
  gem.add_development_dependency "rspec-its"
24
24
  gem.add_development_dependency "pry"
25
25
  gem.add_development_dependency "pry-nav"
26
+ gem.add_development_dependency "test-unit"
26
27
  end
@@ -7,6 +7,11 @@ module Fluent
7
7
  define_method("log") { $log }
8
8
  end
9
9
 
10
+ # Define `router` method of v0.12 to support v0.10 or earlier
11
+ unless method_defined?(:router)
12
+ define_method("router") { Fluent::Engine }
13
+ end
14
+
10
15
  config_param :tag, :string, :default => 'elapsed'
11
16
  config_param :add_tag_prefix, :string, :default => nil
12
17
  config_param :remove_tag_prefix, :string, :default => nil
@@ -29,6 +34,7 @@ module Fluent
29
34
  super
30
35
  @outputs = []
31
36
  @elapsed = {}
37
+ @emit_procs = []
32
38
  end
33
39
 
34
40
  # for test
@@ -51,6 +57,12 @@ module Fluent
51
57
 
52
58
  output = Plugin.new_output(type)
53
59
  output.configure(e)
60
+ emit_proc = if output.respond_to?(:emit_events)
61
+ Proc.new {|output, tag, es, _chain| output.emit_events(tag, es)}
62
+ else
63
+ Proc.new {|output, tag, es, _chain| output.emit(tag, es, NullOutputChain.instance)}
64
+ end
65
+ @emit_procs << emit_proc
54
66
  @outputs << output
55
67
  }
56
68
 
@@ -82,7 +94,9 @@ module Fluent
82
94
  chain = NullOutputChain.instance
83
95
  start = Time.now
84
96
  es.each do |time, record|
85
- @outputs.each {|output| output.emit(tag, OneEventStream.new(time, record), chain) }
97
+ @outputs.each_with_index {|output, idx|
98
+ @emit_procs[idx].call(output, tag, OneEventStream.new(time, record), chain)
99
+ }
86
100
  finish = Time.now
87
101
  emit_tag = @tag_proc.call(tag)
88
102
  elapsed(emit_tag) << (finish - start).to_f
@@ -93,7 +107,9 @@ module Fluent
93
107
  def emit_es(tag, es)
94
108
  chain = NullOutputChain.instance
95
109
  t = Time.now
96
- @outputs.each {|output| output.emit(tag, es, chain) }
110
+ @outputs.each_with_index {|output, idx|
111
+ @emit_procs[idx].call(output, tag, es,chain)
112
+ }
97
113
  emit_tag = @tag_proc.call(tag)
98
114
  elapsed(emit_tag) << (Time.now - t).to_f
99
115
  end
@@ -143,7 +159,7 @@ module Fluent
143
159
  avg = num == 0 ? 0 : elapsed.map(&:to_f).inject(:+) / num.to_f
144
160
  messages[tag] = {"max" => max, "avg" => avg, "num" => num}
145
161
  end
146
- messages.each {|tag, message| Engine.emit(tag, Engine.now, message) }
162
+ messages.each {|tag, message| router.emit(tag, Engine.now, message) }
147
163
  end
148
164
 
149
165
  private
@@ -65,44 +65,44 @@ describe Fluent::ElapsedTimeOutput do
65
65
  context 'each message' do
66
66
  let(:config) { CONFIG + %[each message]}
67
67
  before do
68
- Fluent::Engine.stub(:now).and_return(time)
68
+ allow(Fluent::Engine).to receive(:now).and_return(time)
69
69
  end
70
70
  it {
71
71
  driver.run { messages.each {|message| driver.emit({'message' => message}, time) } }
72
- driver.instance.elapsed.size.should == 4
72
+ expect(driver.instance.elapsed.size).to eq(4)
73
73
  }
74
74
  end
75
75
 
76
76
  context 'each es' do
77
77
  let(:config) { CONFIG + %[each es]}
78
78
  before do
79
- Fluent::Engine.stub(:now).and_return(time)
79
+ allow(Fluent::Engine).to receive(:now).and_return(time)
80
80
  end
81
81
  it {
82
82
  driver.run { messages.each {|message| driver.emit({'message' => message}, time) } }
83
- driver.instance.elapsed.size.should == 4
83
+ expect(driver.instance.elapsed.size).to eq(4)
84
84
  }
85
85
  end
86
86
 
87
87
  context 'each message with aggregate tag' do
88
88
  let(:config) { CONFIG + %[each message\naggregate tag\nadd_tag_prefix elapsed]}
89
89
  before do
90
- Fluent::Engine.stub(:now).and_return(time)
90
+ allow(Fluent::Engine).to receive(:now).and_return(time)
91
91
  end
92
92
  it {
93
93
  driver.run { messages.each {|message| driver.emit({'message' => message}, time) } }
94
- driver.instance.elapsed("elapsed.#{tag}").size.should == 4
94
+ expect(driver.instance.elapsed("elapsed.#{tag}").size).to eq(4)
95
95
  }
96
96
  end
97
97
 
98
98
  context 'each es with aggregate tag' do
99
99
  let(:config) { CONFIG + %[each es\naggregate tag\nadd_tag_prefix elapsed]}
100
100
  before do
101
- Fluent::Engine.stub(:now).and_return(time)
101
+ allow(Fluent::Engine).to receive(:now).and_return(time)
102
102
  end
103
103
  it {
104
104
  driver.run { messages.each {|message| driver.emit({'message' => message}, time) } }
105
- driver.instance.elapsed("elapsed.#{tag}").size.should == 4
105
+ expect(driver.instance.elapsed("elapsed.#{tag}").size).to eq(4)
106
106
  driver.instance.flush_emit
107
107
  }
108
108
  end
@@ -110,36 +110,36 @@ describe Fluent::ElapsedTimeOutput do
110
110
  context 'remove_tag_slice' do
111
111
  let(:config) { CONFIG + %[remove_tag_slice 0..-2\naggregate tag\nadd_tag_prefix elapsed]}
112
112
  before do
113
- Fluent::Engine.stub(:now).and_return(time)
113
+ allow(Fluent::Engine).to receive(:now).and_return(time)
114
114
  end
115
115
  let(:expected_tag) { tag.split('.')[0..-2].join('.') }
116
116
  it {
117
117
  driver.run { messages.each {|message| driver.emit({'message' => message}, time) } }
118
- driver.instance.elapsed("elapsed.#{expected_tag}").size.should == 4
118
+ expect(driver.instance.elapsed("elapsed.#{expected_tag}").size).to eq(4)
119
119
  }
120
120
  end
121
121
 
122
122
  context 'zero_emit true' do
123
123
  let(:config) { CONFIG + %[zero_emit true]}
124
124
  before do
125
- Fluent::Engine.stub(:now).and_return(time)
125
+ allow(Fluent::Engine).to receive(:now).and_return(time)
126
126
  end
127
127
  it {
128
128
  driver.run { messages.each {|message| driver.emit({'message' => message}, time) } }
129
- driver.instance.flush_emit["elapsed"]["num"].should == 4
130
- driver.instance.flush_emit["elapsed"].should == {"max" => 0, "avg" => 0, "num" => 0}
129
+ expect(driver.instance.flush_emit["elapsed"]["num"]).to eq(4)
130
+ expect(driver.instance.flush_emit["elapsed"]).to eq({"max" => 0, "avg" => 0, "num" => 0})
131
131
  }
132
132
  end
133
133
 
134
134
  context 'zero_emit false' do
135
135
  let(:config) { CONFIG }
136
136
  before do
137
- Fluent::Engine.stub(:now).and_return(time)
137
+ allow(Fluent::Engine).to receive(:now).and_return(time)
138
138
  end
139
139
  it {
140
140
  driver.run { messages.each {|message| driver.emit({'message' => message}, time) } }
141
- driver.instance.flush_emit["elapsed"]["num"].should == 4
142
- driver.instance.flush_emit.should == {}
141
+ expect(driver.instance.flush_emit["elapsed"]["num"]).to eq(4)
142
+ expect(driver.instance.flush_emit).to eq({})
143
143
  }
144
144
  end
145
145
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-elapsed-time
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naotoshi Seo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-25 00:00:00.000000000 Z
11
+ date: 2017-02-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -94,6 +94,20 @@ dependencies:
94
94
  - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: test-unit
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
97
111
  description: Fluentd plugin to measure elapsed time to process messages
98
112
  email: sonots@gmail.com
99
113
  executables: []
@@ -132,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
146
  version: '0'
133
147
  requirements: []
134
148
  rubyforge_project:
135
- rubygems_version: 2.2.2
149
+ rubygems_version: 2.5.2
136
150
  signing_key:
137
151
  specification_version: 4
138
152
  summary: Fluentd plugin to measure elapsed time to process messages