fluent-plugin-calc 0.1.2 → 0.2.0
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 +6 -0
- data/README.md +5 -1
- data/fluent-plugin-calc.gemspec +3 -3
- data/lib/fluent/plugin/out_calc.rb +29 -3
- data/spec/out_calc_spec.rb +16 -0
- metadata +6 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30c8943cbad7b43b318067d0708773cce1e1adff
|
4
|
+
data.tar.gz: 74e0cdf6eaf70a24efae255962333c499bc72fcb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 82ed5239999ff5306267c125bbbfb2e46ac5bcefd9ace0e55dede3145dc809f6c747590a48e49b5d1e794f2bd64835a545ddec273e0597d3dde02bee71b03e65
|
7
|
+
data.tar.gz: f0ea97358cc2b5695a96a101a3851fca6a6cb5758f7953b3d9668f14bfdbc938a5129801412e79b80b913e18270e6058bb9f9c46f2f9c4495fa2c9976a9ce9c7
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
data/fluent-plugin-calc.gemspec
CHANGED
@@ -3,11 +3,11 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "fluent-plugin-calc"
|
6
|
-
s.version = "0.
|
7
|
-
s.authors = ["Naotoshi
|
6
|
+
s.version = "0.2.0"
|
7
|
+
s.authors = ["Naotoshi Seo"]
|
8
8
|
s.email = ["sonots@gmail.com"]
|
9
9
|
s.homepage = "https://github.com/sonots/fluent-plugin-calc"
|
10
|
-
s.summary = "
|
10
|
+
s.summary = "Fluentd plugin to calcucate statistics in messages"
|
11
11
|
s.description = s.summary
|
12
12
|
|
13
13
|
s.rubyforge_project = "fluent-plugin-calc"
|
@@ -21,7 +21,8 @@ class Fluent::CalcOutput < Fluent::Output
|
|
21
21
|
config_param :avg_suffix, :string, :default => ""
|
22
22
|
config_param :interval, :time, :default => 5
|
23
23
|
config_param :tag, :string, :default => nil
|
24
|
-
config_param :add_tag_prefix, :string, :default =>
|
24
|
+
config_param :add_tag_prefix, :string, :default => nil
|
25
|
+
config_param :remove_tag_prefix, :string, :default => nil
|
25
26
|
config_param :aggregate, :string, :default => 'tag'
|
26
27
|
config_param :store_file, :string, :default => nil
|
27
28
|
config_param :zero_emit, :bool, :default => false
|
@@ -53,6 +54,25 @@ class Fluent::CalcOutput < Fluent::Output
|
|
53
54
|
raise Fluent::ConfigError, "tag must be specified for aggregate all" if @tag.nil?
|
54
55
|
end
|
55
56
|
|
57
|
+
if @tag.nil? and @add_tag_prefix.nil? and @remove_tag_prefix.nil?
|
58
|
+
@add_tag_prefix = 'calc' # not ConfigError for lower version compatibility
|
59
|
+
end
|
60
|
+
|
61
|
+
@tag_prefix = "#{@add_tag_prefix}." if @add_tag_prefix
|
62
|
+
@tag_prefix_match = "#{@remove_tag_prefix}." if @remove_tag_prefix
|
63
|
+
@tag_proc =
|
64
|
+
if @tag
|
65
|
+
Proc.new {|tag| @tag }
|
66
|
+
elsif @tag_prefix and @tag_prefix_match
|
67
|
+
Proc.new {|tag| "#{@tag_prefix}#{lstrip(tag, @tag_prefix_match)}" }
|
68
|
+
elsif @tag_prefix_match
|
69
|
+
Proc.new {|tag| lstrip(tag, @tag_prefix_match) }
|
70
|
+
elsif @tag_prefix
|
71
|
+
Proc.new {|tag| "#{@tag_prefix}#{tag}" }
|
72
|
+
else
|
73
|
+
Proc.new {|tag| tag }
|
74
|
+
end
|
75
|
+
|
56
76
|
@matches = {}
|
57
77
|
@mutex = Mutex.new
|
58
78
|
end
|
@@ -177,8 +197,8 @@ class Fluent::CalcOutput < Fluent::Output
|
|
177
197
|
flushed_matches.keys.each do |tag|
|
178
198
|
matches = flushed_matches[tag]
|
179
199
|
output = generate_output(matches)
|
180
|
-
|
181
|
-
Fluent::Engine.emit(
|
200
|
+
emit_tag = @tag_proc.call(tag)
|
201
|
+
Fluent::Engine.emit(emit_tag, time, output) if output
|
182
202
|
end
|
183
203
|
end
|
184
204
|
|
@@ -283,4 +303,10 @@ class Fluent::CalcOutput < Fluent::Output
|
|
283
303
|
end
|
284
304
|
end
|
285
305
|
|
306
|
+
private
|
307
|
+
|
308
|
+
def lstrip(string, substring)
|
309
|
+
string.index(substring) == 0 ? string[substring.size..-1] : string
|
310
|
+
end
|
311
|
+
|
286
312
|
end
|
data/spec/out_calc_spec.rb
CHANGED
@@ -199,6 +199,22 @@ describe Fluent::CalcOutput do
|
|
199
199
|
it { emit }
|
200
200
|
end
|
201
201
|
|
202
|
+
context 'remove_tag_prefix' do
|
203
|
+
let(:config) do
|
204
|
+
CONFIG + %[
|
205
|
+
remove_tag_prefix foo
|
206
|
+
sum _count$
|
207
|
+
]
|
208
|
+
end
|
209
|
+
before do
|
210
|
+
Fluent::Engine.stub(:now).and_return(time)
|
211
|
+
Fluent::Engine.should_receive(:emit).with("bar", time, {
|
212
|
+
"4xx_count"=>6,"5xx_count"=>6
|
213
|
+
})
|
214
|
+
end
|
215
|
+
it { emit }
|
216
|
+
end
|
217
|
+
|
202
218
|
context 'aggregate' do
|
203
219
|
let(:emit) do
|
204
220
|
driver.run { messages.each {|message| driver.emit_with_tag(message, time, 'foo.bar') } }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-calc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- Naotoshi
|
7
|
+
- Naotoshi Seo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-12-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -80,7 +80,7 @@ dependencies:
|
|
80
80
|
- - '>='
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '0'
|
83
|
-
description:
|
83
|
+
description: Fluentd plugin to calcucate statistics in messages
|
84
84
|
email:
|
85
85
|
- sonots@gmail.com
|
86
86
|
executables: []
|
@@ -120,11 +120,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
120
|
version: '0'
|
121
121
|
requirements: []
|
122
122
|
rubyforge_project: fluent-plugin-calc
|
123
|
-
rubygems_version: 2.0.
|
123
|
+
rubygems_version: 2.0.3
|
124
124
|
signing_key:
|
125
125
|
specification_version: 4
|
126
|
-
summary:
|
126
|
+
summary: Fluentd plugin to calcucate statistics in messages
|
127
127
|
test_files:
|
128
128
|
- spec/out_calc_spec.rb
|
129
129
|
- spec/spec_helper.rb
|
130
|
-
has_rdoc:
|