fluent-plugin-groupcounter 0.2.2 → 0.2.3

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: 0eae1a0bcfc8a083aae95ca82cf3870d3ec1055c
4
- data.tar.gz: 14201fa360defd334687a6ee18aa3722fdba9791
3
+ metadata.gz: 26090aad310f08ef321e34aa1a70d163b22c5836
4
+ data.tar.gz: 6646e5b26176862e2690a075cb6efe3aef2eaac1
5
5
  SHA512:
6
- metadata.gz: 089d7eec6dc0e3206e105610b9e28b8f6813c927d79d006c5ec04abcdb1870adc7a4d18808fc821a3050af86ce352557cfc48da51e50d9572fdc1ee465558e3c
7
- data.tar.gz: ccc024bf4414587322556d0a9725ad475786b8ac7e71c9c6cd5d07c24bf73b307a5d0169542a0e4cfd7333a566fc898b5d7653991ece26a53449cedfb0ace0d9
6
+ metadata.gz: 80d21ba0055a19bce8c1b8ec268b6b44bff868a1951e7bfebb62eed72f49d3b82a678861a8f23770bc7727b15fdf6a60ee7281142b1913feb7ac419990fa4411
7
+ data.tar.gz: 7298c6d5fc76383e69c9f538b0f05e335351c3986929fc0c7eb069703c492b77aee4950d81ecaee903cad6d625df51e8bfb4a70ce1cb3dce745d4eff363750e6
@@ -0,0 +1,5 @@
1
+ ## 0.2.3 (2013/12/28)
2
+
3
+ Changes
4
+
5
+ * Add `add_tag_prefix` and `remove_tag_prefix` options. `tag_prefix` and `input_tag_remove_prefix` are obsolete.
data/README.md CHANGED
@@ -16,7 +16,7 @@ Think of quering `SELECT COUNT(\*) GROUP BY code,method,path`. Configuration bec
16
16
  type groupcounter
17
17
  aggregate tag
18
18
  output_per_tag true
19
- tag_prefix groupcounter
19
+ add_tag_prefix groupcounter
20
20
  group_by_keys code,method,path
21
21
  </match>
22
22
 
@@ -68,11 +68,11 @@ Output becomes like
68
68
 
69
69
  The output tag. Default is `groupcount`.
70
70
 
71
- * tag\_prefix
71
+ * add\_tag\_prefix
72
72
 
73
73
  The prefix string which will be added to the input tag. `output_per_tag yes` must be specified together.
74
74
 
75
- * input\_tag\_remove\_prefix
75
+ * remove\_tag\__prefix
76
76
 
77
77
  The prefix string which will be removed from the input tag.
78
78
 
@@ -125,6 +125,18 @@ Output becomes like
125
125
 
126
126
  Default is `_avg`. Should be used with `avg_key` option.
127
127
 
128
+ ## ChangeLog
129
+
130
+ See [CHANGELOG.md](CHANGELOG.md) for details.
131
+
132
+ ## Contributing
133
+
134
+ 1. Fork it
135
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
136
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
137
+ 4. Push to the branch (`git push origin my-new-feature`)
138
+ 5. Create new [Pull Request](../../pull/new/master)
139
+
128
140
  ## Copyright
129
141
 
130
142
  * Copyright
@@ -3,12 +3,13 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "fluent-plugin-groupcounter"
6
- s.version = "0.2.2"
7
- s.authors = ["Ryosuke IWANAGA", "Naotoshi SEO"]
8
- s.email = ["@riywo", "sonots@gmail.com"]
6
+ s.version = "0.2.3"
7
+ s.authors = ["Ryosuke IWANAGA", "Naotoshi Seo"]
8
+ s.email = ["riywo.jp@gmail.com", "sonots@gmail.com"]
9
9
  s.homepage = "https://github.com/riywo/fluent-plugin-groupcounter"
10
10
  s.summary = %q{Fluentd plugin to count like SELECT COUNT(\*) GROUP BY}
11
11
  s.description = %q{Fluentd plugin to count like SELECT COUNT(\*) GROUP BY}
12
+ s.licenses = ["Apache"]
12
13
 
13
14
  s.rubyforge_project = "fluent-plugin-groupcounter"
14
15
 
@@ -13,8 +13,10 @@ class Fluent::GroupCounterOutput < Fluent::Output
13
13
  config_param :output_per_tag, :bool, :default => false
14
14
  config_param :aggregate, :string, :default => 'tag'
15
15
  config_param :tag, :string, :default => 'groupcount'
16
- config_param :tag_prefix, :string, :default => nil
17
- config_param :input_tag_remove_prefix, :string, :default => nil
16
+ config_param :tag_prefix, :string, :default => nil # obsolete
17
+ config_param :add_tag_prefix, :string, :default => nil
18
+ config_param :input_tag_remove_prefix, :string, :default => nil # obsolete
19
+ config_param :remove_tag_prefix, :string, :default => nil
18
20
  config_param :group_by_keys, :string, :default => nil
19
21
  config_param :group_by_expression, :string, :default => nil
20
22
  config_param :max_key, :string, :default => nil
@@ -56,13 +58,18 @@ class Fluent::GroupCounterOutput < Fluent::Output
56
58
  raise Fluent::ConfigError, "groupcounter aggregate allows tag/all"
57
59
  end
58
60
 
61
+ @add_tag_prefix ||= @tag_prefix
62
+ @remove_tag_prefix ||= @input_tag_remove_prefix
59
63
  if @output_per_tag
60
- raise Fluent::ConfigError, "tag_prefix must be specified with output_per_tag" unless @tag_prefix
61
- @tag_prefix_string = @tag_prefix + '.'
64
+ raise Fluent::ConfigError, "add_tag_prefix must be specified with output_per_tag" unless @add_tag_prefix
62
65
  end
63
-
64
- if @input_tag_remove_prefix
65
- @removed_prefix_string = @input_tag_remove_prefix + '.'
66
+ if @add_tag_prefix
67
+ @tag_prefix_string = @add_tag_prefix + '.'
68
+ else
69
+ @tag_prefix_string = ''
70
+ end
71
+ if @remove_tag_prefix
72
+ @removed_prefix_string = @remove_tag_prefix + '.'
66
73
  @removed_length = @removed_prefix_string.length
67
74
  end
68
75
 
@@ -152,7 +159,7 @@ class Fluent::GroupCounterOutput < Fluent::Output
152
159
  time = Fluent::Engine.now
153
160
  if @output_per_tag
154
161
  flush.each do |tag, message|
155
- Fluent::Engine.emit(@tag_prefix_string + tag, time, message)
162
+ Fluent::Engine.emit("#{@tag_prefix_string}#{tag}", time, message)
156
163
  end
157
164
  else
158
165
  message = flush
@@ -265,9 +272,8 @@ class Fluent::GroupCounterOutput < Fluent::Output
265
272
  end
266
273
 
267
274
  def stripped_tag(tag)
268
- return tag unless @input_tag_remove_prefix
275
+ return tag unless @remove_tag_prefix
269
276
  return tag[@removed_length..-1] if tag.start_with?(@removed_prefix_string) and tag.length > @removed_length
270
- return tag[@removed_length..-1] if tag == @input_tag_remove_prefix
271
277
  tag
272
278
  end
273
279
 
@@ -14,11 +14,11 @@ describe Fluent::GroupCounterOutput do
14
14
  count_interval 5s
15
15
  aggragate tag
16
16
  output_per_tag true
17
- tag_prefix count
17
+ add_tag_prefix count
18
18
  group_by_keys code,method,path
19
19
  ]
20
20
 
21
- let(:tag) { 'test' }
21
+ let(:tag) { 'test.hoge' }
22
22
  let(:driver) { Fluent::Test::OutputTestDriver.new(Fluent::GroupCounterOutput, tag).configure(config) }
23
23
 
24
24
  describe 'test configure' do
@@ -32,8 +32,8 @@ describe Fluent::GroupCounterOutput do
32
32
  its(:output_per_tag) { should == false }
33
33
  its(:aggregate) { should == :tag }
34
34
  its(:tag) { should == 'groupcount' }
35
- its(:tag_prefix) { should be_nil }
36
- its(:input_tag_remove_prefix) { should be_nil }
35
+ its(:add_tag_prefix) { should be_nil }
36
+ its(:remove_tag_prefix) { should be_nil }
37
37
  its(:group_by_keys) { should == %w[foo] }
38
38
  end
39
39
 
@@ -44,8 +44,8 @@ describe Fluent::GroupCounterOutput do
44
44
  its(:output_per_tag) { should == true }
45
45
  its(:aggregate) { should == :tag }
46
46
  its(:tag) { should == 'groupcount' }
47
- its(:tag_prefix) { should == 'count' }
48
- its(:input_tag_remove_prefix) { should be_nil }
47
+ its(:add_tag_prefix) { should == 'count' }
48
+ its(:remove_tag_prefix) { should be_nil }
49
49
  its(:group_by_keys) { should == %w[code method path] }
50
50
  end
51
51
  end
@@ -74,7 +74,7 @@ describe Fluent::GroupCounterOutput do
74
74
  }
75
75
  end
76
76
  let(:expected_with_tag) do
77
- Hash[*(expected.map {|key, val| next ["test_#{key}", val] }.flatten)]
77
+ Hash[*(expected.map {|key, val| next ["test.hoge_#{key}", val] }.flatten)]
78
78
  end
79
79
 
80
80
  context 'typical' do
@@ -217,7 +217,7 @@ describe Fluent::GroupCounterOutput do
217
217
  context 'no group_by' do
218
218
  let(:config) do
219
219
  %[
220
- tag_prefix count
220
+ add_tag_prefix count
221
221
  output_per_tag true
222
222
 
223
223
  count_suffix count
@@ -271,10 +271,14 @@ describe Fluent::GroupCounterOutput do
271
271
  end
272
272
  end
273
273
 
274
- context 'tag_prefix' do
274
+ context 'tag_prefix (obsolete)' do
275
275
  let(:config) do
276
- CONFIG + %[
276
+ %[
277
+ count_interval 5s
278
+ aggragate tag
279
+ output_per_tag true
277
280
  tag_prefix foo
281
+ group_by_keys code,method,path
278
282
  ]
279
283
  end
280
284
  before do
@@ -284,6 +288,47 @@ describe Fluent::GroupCounterOutput do
284
288
  it { emit }
285
289
  end
286
290
 
291
+ context 'add_tag_prefix' do
292
+ let(:config) do
293
+ CONFIG + %[
294
+ add_tag_prefix foo
295
+ ]
296
+ end
297
+ before do
298
+ Fluent::Engine.stub(:now).and_return(time)
299
+ Fluent::Engine.should_receive(:emit).with("foo.#{tag}", time, expected)
300
+ end
301
+ it { emit }
302
+ end
303
+
304
+ context 'input_tag_remove_prefix (obsolete)' do
305
+ let(:config) do
306
+ CONFIG + %[
307
+ add_tag_prefix foo
308
+ input_tag_remove_prefix test
309
+ ]
310
+ end
311
+ before do
312
+ Fluent::Engine.stub(:now).and_return(time)
313
+ Fluent::Engine.should_receive(:emit).with("foo.hoge", time, expected)
314
+ end
315
+ it { emit }
316
+ end
317
+
318
+ context 'remove_tag_prefix' do
319
+ let(:config) do
320
+ CONFIG + %[
321
+ add_tag_prefix foo
322
+ remove_tag_prefix test
323
+ ]
324
+ end
325
+ before do
326
+ Fluent::Engine.stub(:now).and_return(time)
327
+ Fluent::Engine.should_receive(:emit).with("foo.hoge", time, expected)
328
+ end
329
+ it { emit }
330
+ end
331
+
287
332
  context 'aggregate all' do
288
333
  let(:emit) do
289
334
  driver.run { messages.each {|message| driver.emit_with_tag(message, time, 'foo.bar') } }
@@ -294,7 +339,7 @@ describe Fluent::GroupCounterOutput do
294
339
  let(:config) do
295
340
  CONFIG + %[
296
341
  aggregate all
297
- tag_prefix count
342
+ add_tag_prefix count
298
343
  ]
299
344
  end
300
345
 
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-groupcounter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryosuke IWANAGA
8
- - Naotoshi SEO
8
+ - Naotoshi Seo
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-29 00:00:00.000000000 Z
12
+ date: 2013-12-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fluentd
@@ -83,7 +83,7 @@ dependencies:
83
83
  version: '0'
84
84
  description: Fluentd plugin to count like SELECT COUNT(\*) GROUP BY
85
85
  email:
86
- - '@riywo'
86
+ - riywo.jp@gmail.com
87
87
  - sonots@gmail.com
88
88
  executables: []
89
89
  extensions: []
@@ -92,6 +92,7 @@ files:
92
92
  - .gitignore
93
93
  - .pryrc
94
94
  - .travis.yml
95
+ - CHANGELOG.md
95
96
  - Gemfile
96
97
  - README.md
97
98
  - Rakefile
@@ -100,7 +101,8 @@ files:
100
101
  - spec/out_groupcounter_spec.rb
101
102
  - spec/spec_helper.rb
102
103
  homepage: https://github.com/riywo/fluent-plugin-groupcounter
103
- licenses: []
104
+ licenses:
105
+ - Apache
104
106
  metadata: {}
105
107
  post_install_message:
106
108
  rdoc_options: []
@@ -118,11 +120,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
120
  version: '0'
119
121
  requirements: []
120
122
  rubyforge_project: fluent-plugin-groupcounter
121
- rubygems_version: 2.0.2
123
+ rubygems_version: 2.0.3
122
124
  signing_key:
123
125
  specification_version: 4
124
126
  summary: Fluentd plugin to count like SELECT COUNT(\*) GROUP BY
125
127
  test_files:
126
128
  - spec/out_groupcounter_spec.rb
127
129
  - spec/spec_helper.rb
128
- has_rdoc: