fluent-plugin-measure_time 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 193e1f487b71b8b3e05144ada9ef36651b95d230
4
- data.tar.gz: d0a5363194ca0c40b26d242dff97d703e7850c11
3
+ metadata.gz: f2f3162b94cdaf1e70abdef53ae1cdca1b60f3c8
4
+ data.tar.gz: 41debb162108e360783ea14bbb9296a79b3eaf91
5
5
  SHA512:
6
- metadata.gz: c76cda2d36d046e9496509fe3f139394660b1e2791294489bcfbb1c78706af03830886e972f081ef6c07a77512d059a12b7a405ddfd64e49c35f93eeb204b038
7
- data.tar.gz: cbdd31735b323db8d30d5292b66cf939131f491b07968312f00691684859310722d497c3cc20ae55c87fc3012414e2c672db4e1d4eb70b1d1ec4650bf49a2d1c
6
+ metadata.gz: 116da97ef9fb6cea05e203ca22f58cad55e3317e52a3ee0c22b5a410a3e381f62338a889084f7844e0b41add505297e3a00e3a2c3b3d1f8c54db476c4e88a860
7
+ data.tar.gz: 29c5f059fe191a338bc05069aaa3e8d9b4503e59c72a5e6ee8cba1554df96bfd6ad99e7eef315e00852cc64aa26151252abf307466701b04bad4fb2b6f79d5e3
data/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## 0.1.1 (2014/04/12)
2
+
3
+ Fixes:
4
+
5
+ * Fix emit messages
6
+
1
7
  ## 0.1.0 (2014/04/12)
2
8
 
3
9
  First release
10
+
data/README.md CHANGED
@@ -15,7 +15,7 @@ Use RubyGems:
15
15
 
16
16
  This plugin is doing something tricky, which extends arbitrary plugins so that it can use `<measure_time></measure_time>` directive to measure elapsed times.
17
17
 
18
- Example:
18
+ **Example 1:**
19
19
 
20
20
  ```apache
21
21
  <source>
@@ -45,7 +45,7 @@ measure_time: {"time":0.000849735,"class":"Fluent::ForwardInput","hook":"on_mess
45
45
 
46
46
  where `time` denotes the measured elapsed time, and `class`, `hook`, and `object_id` denotes the hooked class, the hooked method, and the object id of the plugin instance.
47
47
 
48
- Example: interval
48
+ **Example 2: interval**
49
49
 
50
50
  With `interval` option, this plugin compute statistics of measured elapsed times in each interval
51
51
 
@@ -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-measure_time"
6
- gem.version = "0.1.0"
6
+ gem.version = "0.1.1"
7
7
  gem.authors = ["Naotoshi Seo"]
8
8
  gem.email = "sonots@gmail.com"
9
9
  gem.homepage = "https://github.com/sonots/fluent-plugin-measure_time"
@@ -44,7 +44,7 @@ module Fluent
44
44
  unless @hook = conf['hook']
45
45
  raise Fluent::ConfigError, '`hook` option must be specified in <measure_time></measure_time> directive'
46
46
  end
47
- @hook_msg = {"class" => @klass, "hook" => @hook, "object_id" => @plugin.object_id}
47
+ @hook_msg = {:class => @klass.to_s, :hook => @hook.to_s, :object_id => @plugin.object_id.to_s}
48
48
  @interval = conf['interval'].to_i if conf['interval']
49
49
  @add_or_emit_proc =
50
50
  if @interval
@@ -55,7 +55,7 @@ module Fluent
55
55
  else
56
56
  # emit information immediately
57
57
  Proc.new {|elapsed|
58
- msg = {"time" => elapsed}.merge(@hook_msg)
58
+ msg = {:time => elapsed}.merge(@hook_msg)
59
59
  ::Fluent::Engine.emit(@tag, ::Fluent::Engine.now, msg)
60
60
  }
61
61
  end
@@ -19,6 +19,7 @@ describe "extends Fluent::ForwardInput" do
19
19
  before { Fluent::Test.setup }
20
20
 
21
21
  def create_driver(conf=CONFIG)
22
+ Fluent::MeasureTimeInput.new.configure("")
22
23
  Fluent::Test::InputTestDriver.new(Fluent::ForwardInput).configure(conf)
23
24
  end
24
25
 
@@ -52,13 +53,13 @@ describe "extends Fluent::ForwardInput" do
52
53
 
53
54
  describe 'test configure' do
54
55
  let(:config) {CONFIG + %[
55
- <measure>
56
+ <measure_time>
56
57
  tag test
57
58
  interval 10
58
59
  hook on_message
59
- </measure>
60
+ </measure_time>
60
61
  ]}
61
- let(:subject) { driver.instance.measure }
62
+ let(:subject) { driver.instance.measure_time }
62
63
  its(:tag) { should == 'test' }
63
64
  its(:interval) { should == 10 }
64
65
  its(:hook) { should == 'on_message' }
@@ -66,19 +67,18 @@ describe "extends Fluent::ForwardInput" do
66
67
 
67
68
  describe 'test emit' do
68
69
  let(:config) {CONFIG + %[
69
- <measure>
70
- tag measure
70
+ <measure_time>
71
+ tag measure_time
71
72
  interval 1
72
- # hook Fluent::ForwardInput::Handler.on_read # not support inner class yet
73
- hook Fluent::ForwardInput.on_message
74
- </measure>
73
+ hook on_message
74
+ </measure_time>
75
75
  ]}
76
76
  it 'should flush' do
77
77
  d = driver.instance
78
78
  d.__send__(:on_message, ['tag1', 0, {'a'=>1}].to_msgpack)
79
- triple = d.measure.flush(0)
80
- triple[0].should == 'measure'
81
- triple[2].keys.should =~ [:num, :max, :avg]
79
+ triple = d.measure_time.flush(0)
80
+ triple[0].should == 'measure_time'
81
+ triple[2].keys.should =~ [:num, :max, :avg, :class, :hook, :object_id]
82
82
  end
83
83
  end
84
84
  end
@@ -97,13 +97,13 @@ describe "extends Fluent::StdoutOutput" do
97
97
 
98
98
  describe 'test configure' do
99
99
  let(:config) {CONFIG + %[
100
- <measure>
100
+ <measure_time>
101
101
  tag test
102
102
  interval 10
103
103
  hook emit
104
- </measure>
104
+ </measure_time>
105
105
  ]}
106
- let(:subject) { driver.instance.instance_variable_get(:@measure) }
106
+ let(:subject) { driver.instance.measure_time }
107
107
  its(:tag) { should == 'test' }
108
108
  its(:interval) { should == 10 }
109
109
  its(:hook) { should == 'emit' }
@@ -111,18 +111,34 @@ describe "extends Fluent::StdoutOutput" do
111
111
 
112
112
  describe 'test emit' do
113
113
  let(:config) {CONFIG + %[
114
- <measure>
115
- tag measure
114
+ <measure_time>
115
+ tag measure_time
116
+ hook emit
117
+ </measure_time>
118
+ ]}
119
+ it 'should flush' do
120
+ time = Fluent::Engine.now
121
+ Fluent::Engine.stub(:now).and_return(time)
122
+ Fluent::Engine.should_receive(:emit) # .with("measure_time", time, {})
123
+ d = driver.instance
124
+ d.emit('tag1', Fluent::OneEventStream.new(0, {'a'=>1}), Fluent::NullOutputChain.instance)
125
+ end
126
+ end
127
+
128
+ describe 'test interval' do
129
+ let(:config) {CONFIG + %[
130
+ <measure_time>
131
+ tag measure_time
116
132
  interval 1
117
133
  hook emit
118
- </measure>
134
+ </measure_time>
119
135
  ]}
120
136
  it 'should flush' do
121
137
  d = driver.instance
122
138
  d.emit('tag1', Fluent::OneEventStream.new(0, {'a'=>1}), Fluent::NullOutputChain.instance)
123
- triple = d.measure.flush(0)
124
- triple[0].should == 'measure'
125
- triple[2].keys.should =~ [:num, :max, :avg]
139
+ triple = d.measure_time.flush(0)
140
+ triple[0].should == 'measure_time'
141
+ triple[2].keys.should =~ [:num, :max, :avg, :class, :hook, :object_id]
126
142
  end
127
143
  end
128
144
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-measure_time
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naotoshi Seo