fluent-plugin-stats 0.3.4 → 0.3.5
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 +17 -3
- data/fluent-plugin-stats.gemspec +2 -1
- data/lib/fluent/plugin/out_stats.rb +66 -30
- data/spec/out_stats_spec.rb +67 -29
- data/spec/spec_helper.rb +1 -0
- metadata +34 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bf27cb39ed1dd976c0c6722b0be301d03e57eac9
|
4
|
+
data.tar.gz: 95384c6fe1303b54e722158db18685924dc9718e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ee9239994adaa274869f4a7d73ea8c6864dd808acfbe3392f89bf2566fb5692b4d323e64806c0e6bb454044c87fe69f08e75a183b7f18c5c4712ac4a8cddef5
|
7
|
+
data.tar.gz: 63af8f6ead4b5982e9505656c03cbe8dde5301d6e0e42d2839267eb36d24cec47267589962f2071db41805a897d428c441cdc8b08288cf8116eaea333c477600
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -96,9 +96,23 @@ then output bocomes as belows:
|
|
96
96
|
|
97
97
|
Remove tag suffix for output message.
|
98
98
|
|
99
|
-
|
100
|
-
|
101
|
-
|
99
|
+
* remove_tag_slice *min..max*
|
100
|
+
|
101
|
+
Remove tag parts by slice function. FYI: This option behaves like `tag.split('.').slice(min..max)`.
|
102
|
+
|
103
|
+
For example,
|
104
|
+
|
105
|
+
remove_tag_slice 0..-2
|
106
|
+
|
107
|
+
changes an input tag `foo.bar.host1` to `foo.bar`.
|
108
|
+
|
109
|
+
* aggregate
|
110
|
+
|
111
|
+
Aggregation unit. One of `all`, `in_tag`, `out_tag` can be specified. Default is `in_tag`.
|
112
|
+
|
113
|
+
* `all` calculate stats for all input messages and emit one message in each interval.
|
114
|
+
* `in_tag` calculate stats for each input tag seperately.
|
115
|
+
* `out_tag` calculate stats for for each tag *modified* by `add_tag_prefix`, `remove_tag_prefix`, or `remove_tag_slice`.
|
102
116
|
|
103
117
|
- store_file
|
104
118
|
|
data/fluent-plugin-stats.gemspec
CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "fluent-plugin-stats"
|
6
|
-
s.version = "0.3.
|
6
|
+
s.version = "0.3.5"
|
7
7
|
s.authors = ["Naotoshi Seo"]
|
8
8
|
s.email = ["sonots@gmail.com"]
|
9
9
|
s.homepage = "https://github.com/sonots/fluent-plugin-stats"
|
@@ -21,6 +21,7 @@ Gem::Specification.new do |s|
|
|
21
21
|
s.add_runtime_dependency "fluentd"
|
22
22
|
s.add_development_dependency "rake"
|
23
23
|
s.add_development_dependency "rspec"
|
24
|
+
s.add_development_dependency "rspec-its"
|
24
25
|
s.add_development_dependency "pry"
|
25
26
|
s.add_development_dependency "pry-nav"
|
26
27
|
end
|
@@ -30,7 +30,8 @@ class Fluent::StatsOutput < Fluent::Output
|
|
30
30
|
config_param :remove_tag_prefix, :string, :default => nil
|
31
31
|
config_param :add_tag_suffix, :string, :default => nil
|
32
32
|
config_param :remove_tag_suffix, :string, :default => nil
|
33
|
-
config_param :
|
33
|
+
config_param :remove_tag_slice, :string, :default => nil
|
34
|
+
config_param :aggregate, :string, :default => 'in_tag'
|
34
35
|
config_param :store_file, :string, :default => nil
|
35
36
|
config_param :zero_emit, :bool, :default => false
|
36
37
|
|
@@ -52,20 +53,24 @@ class Fluent::StatsOutput < Fluent::Output
|
|
52
53
|
@min_keys = @min_keys ? @min_keys.split(',') : []
|
53
54
|
@avg_keys = @avg_keys ? @avg_keys.split(',') : []
|
54
55
|
|
55
|
-
unless ['tag', 'all'].include?(@aggregate)
|
56
|
-
raise Fluent::ConfigError, "aggregate allows tag/all"
|
57
|
-
end
|
58
|
-
|
59
56
|
case @aggregate
|
57
|
+
when 'tag' # obsolete
|
58
|
+
@aggregate = 'in_tag'
|
60
59
|
when 'all'
|
61
60
|
raise Fluent::ConfigError, "tag must be specified for aggregate all" if @tag.nil?
|
62
61
|
end
|
63
62
|
|
64
|
-
|
63
|
+
unless ['in_tag', 'out_tag', 'all'].include?(@aggregate)
|
64
|
+
raise Fluent::ConfigError, "aggregate allows in_tag/out_tag/all"
|
65
|
+
end
|
66
|
+
|
67
|
+
if @tag.nil? and @add_tag_prefix.nil? and @remove_tag_prefix.nil? and @add_tag_suffix.nil? and @remove_tag_suffix.nil? and @remove_tag_slice.nil?
|
65
68
|
@add_tag_prefix = 'stats' # not ConfigError for lower version compatibility
|
66
69
|
end
|
67
70
|
@tag_proc = tag_proc
|
68
71
|
|
72
|
+
@aggregate_proc = aggregate_proc(@tag_proc)
|
73
|
+
|
69
74
|
@matches = {}
|
70
75
|
@mutex = Mutex.new
|
71
76
|
end
|
@@ -73,14 +78,14 @@ class Fluent::StatsOutput < Fluent::Output
|
|
73
78
|
def initial_matches(prev_matches = nil)
|
74
79
|
if @zero_emit && prev_matches
|
75
80
|
matches = {}
|
76
|
-
prev_matches.keys.each do |
|
77
|
-
next unless prev_matches[
|
78
|
-
matches[
|
81
|
+
prev_matches.keys.each do |aggregate_key|
|
82
|
+
next unless prev_matches[aggregate_key][:count] > 0 # Prohibit to emit anymore
|
83
|
+
matches[aggregate_key] = { :count => 0, :sum => {}, :max => {}, :min => {}, :avg => {} }
|
79
84
|
# ToDo: would want default configuration for :max, :min
|
80
|
-
prev_matches[
|
81
|
-
prev_matches[
|
82
|
-
prev_matches[
|
83
|
-
prev_matches[
|
85
|
+
prev_matches[aggregate_key][:sum].keys.each {|key| matches[aggregate_key][:sum][key] = 0 }
|
86
|
+
prev_matches[aggregate_key][:max].keys.each {|key| matches[aggregate_key][:max][key] = 0 }
|
87
|
+
prev_matches[aggregate_key][:min].keys.each {|key| matches[aggregate_key][:min][key] = 0 }
|
88
|
+
prev_matches[aggregate_key][:avg].keys.each {|key| matches[aggregate_key][:avg][key] = 0 }
|
84
89
|
end
|
85
90
|
matches
|
86
91
|
else
|
@@ -103,8 +108,6 @@ class Fluent::StatsOutput < Fluent::Output
|
|
103
108
|
|
104
109
|
# Called when new line comes. This method actually does not emit
|
105
110
|
def emit(tag, es, chain)
|
106
|
-
_tag = tag
|
107
|
-
tag = 'all' if @aggregate == 'all'
|
108
111
|
# stats
|
109
112
|
matches = { :count => 0, :sum => {}, :max => {}, :min => {}, :avg => {} }
|
110
113
|
es.each do |time, record|
|
@@ -144,25 +147,27 @@ class Fluent::StatsOutput < Fluent::Output
|
|
144
147
|
matches[:count] += 1
|
145
148
|
end
|
146
149
|
|
150
|
+
aggregate_key = @aggregate_proc.call(tag)
|
151
|
+
|
147
152
|
# thread safe merge
|
148
|
-
@matches[
|
153
|
+
@matches[aggregate_key] ||= { :count => 0, :sum => {}, :max => {}, :min => {}, :avg => {} }
|
149
154
|
@mutex.synchronize do
|
150
155
|
matches[:sum].keys.each do |key|
|
151
|
-
@matches[
|
156
|
+
@matches[aggregate_key][:sum][key] = sum(@matches[aggregate_key][:sum][key], matches[:sum][key])
|
152
157
|
end
|
153
158
|
matches[:max].keys.each do |key|
|
154
|
-
@matches[
|
159
|
+
@matches[aggregate_key][:max][key] = max(@matches[aggregate_key][:max][key], matches[:max][key])
|
155
160
|
end
|
156
161
|
matches[:min].keys.each do |key|
|
157
|
-
@matches[
|
162
|
+
@matches[aggregate_key][:min][key] = min(@matches[aggregate_key][:min][key], matches[:min][key])
|
158
163
|
end
|
159
164
|
matches[:avg].keys.each do |key|
|
160
|
-
@matches[
|
165
|
+
@matches[aggregate_key][:avg][key] = sum(@matches[aggregate_key][:avg][key], matches[:avg][key]) # sum yet
|
161
166
|
end
|
162
|
-
@matches[
|
167
|
+
@matches[aggregate_key][:count] += matches[:count]
|
163
168
|
end
|
164
169
|
|
165
|
-
log.trace "out_stats: tag:#{
|
170
|
+
log.trace "out_stats: tag:#{tag} @matches:#{@matches}"
|
166
171
|
|
167
172
|
chain.next
|
168
173
|
rescue => e
|
@@ -197,7 +202,15 @@ class Fluent::StatsOutput < Fluent::Output
|
|
197
202
|
log.trace("out_stats: flushed_matches:#{flushed_matches} @matches:#{@matches}") unless flushed_matches.empty?
|
198
203
|
|
199
204
|
flushed_matches.each do |tag, matches|
|
200
|
-
|
205
|
+
case @aggregate
|
206
|
+
when 'all'
|
207
|
+
emit_tag = @tag
|
208
|
+
when 'in_tag'
|
209
|
+
emit_tag = @tag_proc.call(tag)
|
210
|
+
when 'out_tag'
|
211
|
+
emit_tag = tag
|
212
|
+
else
|
213
|
+
end
|
201
214
|
report_time(" emit_tag:#{emit_tag} matches:#{matches}") do
|
202
215
|
output = generate_output(matches)
|
203
216
|
Fluent::Engine.emit(emit_tag, time, output) if output and !output.empty?
|
@@ -319,7 +332,30 @@ class Fluent::StatsOutput < Fluent::Output
|
|
319
332
|
transform_keys(hash) { |key| key.to_s }
|
320
333
|
end
|
321
334
|
|
335
|
+
def aggregate_proc(tag_proc)
|
336
|
+
case @aggregate
|
337
|
+
when 'all'
|
338
|
+
Proc.new {|tag| :all }
|
339
|
+
when 'in_tag'
|
340
|
+
Proc.new {|tag| tag }
|
341
|
+
when 'out_tag'
|
342
|
+
Proc.new {|tag| tag_proc.call(tag) }
|
343
|
+
end
|
344
|
+
end
|
345
|
+
|
322
346
|
def tag_proc
|
347
|
+
tag_slice_proc =
|
348
|
+
if @remove_tag_slice
|
349
|
+
lindex, rindex = @remove_tag_slice.split('..', 2)
|
350
|
+
if lindex.nil? or rindex.nil? or lindex !~ /^-?\d+$/ or rindex !~ /^-?\d+$/
|
351
|
+
raise Fluent::ConfigError, "out_grepcounter: remove_tag_slice must be formatted like [num]..[num]"
|
352
|
+
end
|
353
|
+
l, r = lindex.to_i, rindex.to_i
|
354
|
+
Proc.new {|tag| (tags = tag.split('.')[l..r]).nil? ? "" : tags.join('.') }
|
355
|
+
else
|
356
|
+
Proc.new {|tag| tag }
|
357
|
+
end
|
358
|
+
|
323
359
|
rstrip = Proc.new {|str, substr| str.chomp(substr) }
|
324
360
|
lstrip = Proc.new {|str, substr| str.start_with?(substr) ? str[substr.size..-1] : str }
|
325
361
|
tag_prefix = "#{rstrip.call(@add_tag_prefix, '.')}." if @add_tag_prefix
|
@@ -327,16 +363,16 @@ class Fluent::StatsOutput < Fluent::Output
|
|
327
363
|
tag_prefix_match = "#{rstrip.call(@remove_tag_prefix, '.')}." if @remove_tag_prefix
|
328
364
|
tag_suffix_match = ".#{lstrip.call(@remove_tag_suffix, '.')}" if @remove_tag_suffix
|
329
365
|
tag_fixed = @tag if @tag
|
330
|
-
if
|
331
|
-
Proc.new {|tag|
|
332
|
-
elsif tag_prefix_match and tag_suffix_match
|
333
|
-
Proc.new {|tag| "#{tag_prefix}#{rstrip.call(lstrip.call(tag, tag_prefix_match), tag_suffix_match)}#{tag_suffix}" }
|
366
|
+
if tag_prefix_match and tag_suffix_match
|
367
|
+
Proc.new {|tag| "#{tag_prefix}#{rstrip.call(lstrip.call(tag_slice_proc.call(tag), tag_prefix_match), tag_suffix_match)}#{tag_suffix}" }
|
334
368
|
elsif tag_prefix_match
|
335
|
-
Proc.new {|tag| "#{tag_prefix}#{lstrip.call(tag, tag_prefix_match)}#{tag_suffix}" }
|
369
|
+
Proc.new {|tag| "#{tag_prefix}#{lstrip.call(tag_slice_proc.call(tag), tag_prefix_match)}#{tag_suffix}" }
|
336
370
|
elsif tag_suffix_match
|
337
|
-
Proc.new {|tag| "#{tag_prefix}#{rstrip.call(tag, tag_suffix_match)}#{tag_suffix}" }
|
371
|
+
Proc.new {|tag| "#{tag_prefix}#{rstrip.call(tag_slice_proc.call(tag), tag_suffix_match)}#{tag_suffix}" }
|
372
|
+
elsif tag_prefix || @remove_tag_slice || tag_suffix
|
373
|
+
Proc.new {|tag| "#{tag_prefix}#{tag_slice_proc.call(tag)}#{tag_suffix}" }
|
338
374
|
else
|
339
|
-
Proc.new {|tag|
|
375
|
+
Proc.new {|tag| tag_fixed }
|
340
376
|
end
|
341
377
|
end
|
342
378
|
|
data/spec/out_stats_spec.rb
CHANGED
@@ -59,7 +59,7 @@ describe Fluent::StatsOutput do
|
|
59
59
|
its(:interval) { should == 5 }
|
60
60
|
its(:tag) { should be_nil }
|
61
61
|
its(:add_tag_prefix) { should == 'stats' }
|
62
|
-
its(:aggregate) { should == '
|
62
|
+
its(:aggregate) { should == 'in_tag' }
|
63
63
|
end
|
64
64
|
end
|
65
65
|
end
|
@@ -91,8 +91,8 @@ describe Fluent::StatsOutput do
|
|
91
91
|
]
|
92
92
|
end
|
93
93
|
before do
|
94
|
-
Fluent::Engine.
|
95
|
-
Fluent::Engine.
|
94
|
+
allow(Fluent::Engine).to receive(:now).and_return(time)
|
95
|
+
expect(Fluent::Engine).to receive(:emit).with("stats.#{tag}", time, {
|
96
96
|
"4xx_count"=>6,"5xx_count"=>6,"reqtime_max"=>6,"reqtime_min"=>1,"reqtime_avg"=>3.0
|
97
97
|
})
|
98
98
|
end
|
@@ -110,11 +110,11 @@ describe Fluent::StatsOutput do
|
|
110
110
|
]
|
111
111
|
end
|
112
112
|
before do
|
113
|
-
Fluent::Engine.
|
114
|
-
Fluent::Engine.
|
113
|
+
allow(Fluent::Engine).to receive(:now).and_return(time)
|
114
|
+
expect(Fluent::Engine).to receive(:emit).with("stats.#{tag}", time, {
|
115
115
|
"4xx_count"=>6,"5xx_count"=>6,"reqtime_max"=>6,"reqtime_min"=>1,"reqtime_avg"=>3.0
|
116
116
|
})
|
117
|
-
Fluent::Engine.
|
117
|
+
expect(Fluent::Engine).to receive(:emit).with("stats.#{tag}", time, {
|
118
118
|
"4xx_count"=>0,"5xx_count"=>0,"reqtime_max"=>0,"reqtime_min"=>0,"reqtime_avg"=>0.0
|
119
119
|
})
|
120
120
|
end
|
@@ -131,8 +131,8 @@ describe Fluent::StatsOutput do
|
|
131
131
|
]
|
132
132
|
end
|
133
133
|
before do
|
134
|
-
Fluent::Engine.
|
135
|
-
Fluent::Engine.
|
134
|
+
allow(Fluent::Engine).to receive(:now).and_return(time)
|
135
|
+
expect(Fluent::Engine).to receive(:emit).with("stats.#{tag}", time, {
|
136
136
|
"4xx_count"=>6,"5xx_count"=>6,"reqtime_max"=>6,"reqtime_min"=>1,"reqtime_avg"=>3.0
|
137
137
|
})
|
138
138
|
end
|
@@ -159,8 +159,8 @@ describe Fluent::StatsOutput do
|
|
159
159
|
]
|
160
160
|
end
|
161
161
|
before do
|
162
|
-
Fluent::Engine.
|
163
|
-
Fluent::Engine.
|
162
|
+
allow(Fluent::Engine).to receive(:now).and_return(time)
|
163
|
+
expect(Fluent::Engine).to receive(:emit).with("stats.#{tag}", time, {
|
164
164
|
"reqtime_sum"=>3.000,"reqtime_max"=>2.000,"reqtime_min"=>1.000,"reqtime_avg"=>1.500,"reqsize_sum"=>30
|
165
165
|
})
|
166
166
|
end
|
@@ -175,8 +175,8 @@ describe Fluent::StatsOutput do
|
|
175
175
|
]
|
176
176
|
end
|
177
177
|
before do
|
178
|
-
Fluent::Engine.
|
179
|
-
Fluent::Engine.
|
178
|
+
allow(Fluent::Engine).to receive(:now).and_return(time)
|
179
|
+
expect(Fluent::Engine).to receive(:emit).with("foo", time, {
|
180
180
|
"4xx_count"=>6,"5xx_count"=>6
|
181
181
|
})
|
182
182
|
end
|
@@ -192,8 +192,8 @@ describe Fluent::StatsOutput do
|
|
192
192
|
end
|
193
193
|
let(:tag) { 'foo.bar' }
|
194
194
|
before do
|
195
|
-
Fluent::Engine.
|
196
|
-
Fluent::Engine.
|
195
|
+
allow(Fluent::Engine).to receive(:now).and_return(time)
|
196
|
+
expect(Fluent::Engine).to receive(:emit).with("foo.#{tag}", time, {
|
197
197
|
"4xx_count"=>6,"5xx_count"=>6
|
198
198
|
})
|
199
199
|
end
|
@@ -209,8 +209,8 @@ describe Fluent::StatsOutput do
|
|
209
209
|
end
|
210
210
|
let(:tag) { 'foo.bar' }
|
211
211
|
before do
|
212
|
-
Fluent::Engine.
|
213
|
-
Fluent::Engine.
|
212
|
+
allow(Fluent::Engine).to receive(:now).and_return(time)
|
213
|
+
expect(Fluent::Engine).to receive(:emit).with("bar", time, {
|
214
214
|
"4xx_count"=>6,"5xx_count"=>6
|
215
215
|
})
|
216
216
|
end
|
@@ -226,8 +226,8 @@ describe Fluent::StatsOutput do
|
|
226
226
|
end
|
227
227
|
let(:tag) { 'foo.bar' }
|
228
228
|
before do
|
229
|
-
Fluent::Engine.
|
230
|
-
Fluent::Engine.
|
229
|
+
allow(Fluent::Engine).to receive(:now).and_return(time)
|
230
|
+
expect(Fluent::Engine).to receive(:emit).with("#{tag}.foo", time, {
|
231
231
|
"4xx_count"=>6,"5xx_count"=>6
|
232
232
|
})
|
233
233
|
end
|
@@ -243,8 +243,25 @@ describe Fluent::StatsOutput do
|
|
243
243
|
end
|
244
244
|
let(:tag) { 'foo.bar' }
|
245
245
|
before do
|
246
|
-
Fluent::Engine.
|
247
|
-
Fluent::Engine.
|
246
|
+
allow(Fluent::Engine).to receive(:now).and_return(time)
|
247
|
+
expect(Fluent::Engine).to receive(:emit).with("foo", time, {
|
248
|
+
"4xx_count"=>6,"5xx_count"=>6
|
249
|
+
})
|
250
|
+
end
|
251
|
+
it { emit }
|
252
|
+
end
|
253
|
+
|
254
|
+
context 'remove_tag_slice' do
|
255
|
+
let(:config) do
|
256
|
+
CONFIG + %[
|
257
|
+
remove_tag_slice 0..-2
|
258
|
+
sum _count$
|
259
|
+
]
|
260
|
+
end
|
261
|
+
let(:tag) { 'foo.bar' }
|
262
|
+
before do
|
263
|
+
allow(Fluent::Engine).to receive(:now).and_return(time)
|
264
|
+
expect(Fluent::Engine).to receive(:emit).with("foo", time, {
|
248
265
|
"4xx_count"=>6,"5xx_count"=>6
|
249
266
|
})
|
250
267
|
end
|
@@ -270,15 +287,15 @@ describe Fluent::StatsOutput do
|
|
270
287
|
]
|
271
288
|
end
|
272
289
|
before do
|
273
|
-
Fluent::Engine.
|
274
|
-
Fluent::Engine.
|
290
|
+
allow(Fluent::Engine).to receive(:now).and_return(time)
|
291
|
+
expect(Fluent::Engine).to receive(:emit).with("foo", time, {
|
275
292
|
"4xx_count"=>12,"5xx_count"=>12,"reqtime_max"=>6,"reqtime_min"=>1,"reqtime_avg"=>3.0
|
276
293
|
})
|
277
294
|
end
|
278
295
|
it { emit }
|
279
296
|
end
|
280
297
|
|
281
|
-
context 'aggregate
|
298
|
+
context 'aggregate in_tag' do
|
282
299
|
let(:config) do
|
283
300
|
CONFIG + %[
|
284
301
|
aggregate tag
|
@@ -290,16 +307,37 @@ describe Fluent::StatsOutput do
|
|
290
307
|
]
|
291
308
|
end
|
292
309
|
before do
|
293
|
-
Fluent::Engine.
|
294
|
-
Fluent::Engine.
|
310
|
+
allow(Fluent::Engine).to receive(:now).and_return(time)
|
311
|
+
expect(Fluent::Engine).to receive(:emit).with("stats.foo.bar", time, {
|
295
312
|
"4xx_count"=>6,"5xx_count"=>6,"reqtime_max"=>6,"reqtime_min"=>1,"reqtime_avg"=>3.0
|
296
313
|
})
|
297
|
-
Fluent::Engine.
|
314
|
+
expect(Fluent::Engine).to receive(:emit).with("stats.foo.bar2", time, {
|
298
315
|
"4xx_count"=>6,"5xx_count"=>6,"reqtime_max"=>6,"reqtime_min"=>1,"reqtime_avg"=>3.0
|
299
316
|
})
|
300
317
|
end
|
301
318
|
it { emit }
|
302
319
|
end
|
320
|
+
|
321
|
+
context 'aggregate out_tag' do
|
322
|
+
let(:config) do
|
323
|
+
CONFIG + %[
|
324
|
+
aggregate out_tag
|
325
|
+
remove_tag_slice 0..-2
|
326
|
+
add_tag_prefix stats
|
327
|
+
sum _count$
|
328
|
+
max _max$
|
329
|
+
min _min$
|
330
|
+
avg _avg$
|
331
|
+
]
|
332
|
+
end
|
333
|
+
before do
|
334
|
+
allow(Fluent::Engine).to receive(:now).and_return(time)
|
335
|
+
expect(Fluent::Engine).to receive(:emit).with("stats.foo", time, {
|
336
|
+
"4xx_count"=>12,"5xx_count"=>12,"reqtime_max"=>6,"reqtime_min"=>1,"reqtime_avg"=>3.0
|
337
|
+
})
|
338
|
+
end
|
339
|
+
it { emit }
|
340
|
+
end
|
303
341
|
end
|
304
342
|
|
305
343
|
describe "store_file" do
|
@@ -333,9 +371,9 @@ describe Fluent::StatsOutput do
|
|
333
371
|
loaded_saved_at = driver.instance.saved_at
|
334
372
|
loaded_saved_duration = driver.instance.saved_duration
|
335
373
|
|
336
|
-
loaded_matches.
|
337
|
-
loaded_saved_at.
|
338
|
-
loaded_saved_duration.
|
374
|
+
expect(loaded_matches).to eql(stored_matches)
|
375
|
+
expect(loaded_saved_at).to eql(stored_saved_at)
|
376
|
+
expect(loaded_saved_duration).to eql(stored_saved_duration)
|
339
377
|
end
|
340
378
|
end
|
341
379
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,83 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-stats
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
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
|
+
date: 2014-08-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- -
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec-its
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
53
67
|
- !ruby/object:Gem::Version
|
54
68
|
version: '0'
|
55
69
|
- !ruby/object:Gem::Dependency
|
56
70
|
name: pry
|
57
71
|
requirement: !ruby/object:Gem::Requirement
|
58
72
|
requirements:
|
59
|
-
- -
|
73
|
+
- - ">="
|
60
74
|
- !ruby/object:Gem::Version
|
61
75
|
version: '0'
|
62
76
|
type: :development
|
63
77
|
prerelease: false
|
64
78
|
version_requirements: !ruby/object:Gem::Requirement
|
65
79
|
requirements:
|
66
|
-
- -
|
80
|
+
- - ">="
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: '0'
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: pry-nav
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
72
86
|
requirements:
|
73
|
-
- -
|
87
|
+
- - ">="
|
74
88
|
- !ruby/object:Gem::Version
|
75
89
|
version: '0'
|
76
90
|
type: :development
|
77
91
|
prerelease: false
|
78
92
|
version_requirements: !ruby/object:Gem::Requirement
|
79
93
|
requirements:
|
80
|
-
- -
|
94
|
+
- - ">="
|
81
95
|
- !ruby/object:Gem::Version
|
82
96
|
version: '0'
|
83
97
|
description: Fluentd plugin to calculate statistics such as sum, max, min, avg
|
@@ -87,11 +101,11 @@ executables: []
|
|
87
101
|
extensions: []
|
88
102
|
extra_rdoc_files: []
|
89
103
|
files:
|
90
|
-
- .coveralls.yml
|
91
|
-
- .gitignore
|
92
|
-
- .rdebugrc
|
93
|
-
- .rspec
|
94
|
-
- .travis.yml
|
104
|
+
- ".coveralls.yml"
|
105
|
+
- ".gitignore"
|
106
|
+
- ".rdebugrc"
|
107
|
+
- ".rspec"
|
108
|
+
- ".travis.yml"
|
95
109
|
- CHANGELOG.md
|
96
110
|
- Gemfile
|
97
111
|
- LICENSE
|
@@ -111,17 +125,17 @@ require_paths:
|
|
111
125
|
- lib
|
112
126
|
required_ruby_version: !ruby/object:Gem::Requirement
|
113
127
|
requirements:
|
114
|
-
- -
|
128
|
+
- - ">="
|
115
129
|
- !ruby/object:Gem::Version
|
116
130
|
version: '0'
|
117
131
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
118
132
|
requirements:
|
119
|
-
- -
|
133
|
+
- - ">="
|
120
134
|
- !ruby/object:Gem::Version
|
121
135
|
version: '0'
|
122
136
|
requirements: []
|
123
137
|
rubyforge_project: fluent-plugin-stats
|
124
|
-
rubygems_version: 2.0
|
138
|
+
rubygems_version: 2.2.0
|
125
139
|
signing_key:
|
126
140
|
specification_version: 4
|
127
141
|
summary: Fluentd plugin to calculate statistics such as sum, max, min, avg
|