fluent-plugin-measure_time 0.1.0 → 0.1.1
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 +4 -4
- data/CHANGELOG.md +7 -0
- data/README.md +2 -2
- data/fluent-plugin-measure_time.gemspec +1 -1
- data/lib/fluent/plugin/in_measure_time.rb +2 -2
- data/spec/in_measure_time_spec.rb +36 -20
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f2f3162b94cdaf1e70abdef53ae1cdca1b60f3c8
|
4
|
+
data.tar.gz: 41debb162108e360783ea14bbb9296a79b3eaf91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 116da97ef9fb6cea05e203ca22f58cad55e3317e52a3ee0c22b5a410a3e381f62338a889084f7844e0b41add505297e3a00e3a2c3b3d1f8c54db476c4e88a860
|
7
|
+
data.tar.gz: 29c5f059fe191a338bc05069aaa3e8d9b4503e59c72a5e6ee8cba1554df96bfd6ad99e7eef315e00852cc64aa26151252abf307466701b04bad4fb2b6f79d5e3
|
data/CHANGELOG.md
CHANGED
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.
|
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 = {
|
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 = {
|
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
|
-
<
|
56
|
+
<measure_time>
|
56
57
|
tag test
|
57
58
|
interval 10
|
58
59
|
hook on_message
|
59
|
-
</
|
60
|
+
</measure_time>
|
60
61
|
]}
|
61
|
-
let(:subject) { driver.instance.
|
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
|
-
<
|
70
|
-
tag
|
70
|
+
<measure_time>
|
71
|
+
tag measure_time
|
71
72
|
interval 1
|
72
|
-
|
73
|
-
|
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.
|
80
|
-
triple[0].should == '
|
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
|
-
<
|
100
|
+
<measure_time>
|
101
101
|
tag test
|
102
102
|
interval 10
|
103
103
|
hook emit
|
104
|
-
</
|
104
|
+
</measure_time>
|
105
105
|
]}
|
106
|
-
let(:subject) { driver.instance.
|
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
|
-
<
|
115
|
-
tag
|
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
|
-
</
|
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.
|
124
|
-
triple[0].should == '
|
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
|