fluent-plugin-flowcounter-simple 0.0.3 → 0.0.4

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: 6068639d44bb2bd1f48f368276c79218b37df9d0
4
- data.tar.gz: 676f07aef67aaa0a1be88317bf4f7db75768ce48
3
+ metadata.gz: ea1531a6eca03db802d05acb32f7ac39cfd29576
4
+ data.tar.gz: 6db938ffaa1c09dc074816b6491fc8dfa752b9f1
5
5
  SHA512:
6
- metadata.gz: a276cb04edb29041e5c1b361176c8e12c3c37c8d3f06ee6d5666eb7c8ce7249028481e90777573197a22d5323f68869232bf7fa55ad585806f4611f9cc2ee862
7
- data.tar.gz: 05ee368bb3ee9e36a1fe5cd696d51ef1df983f5ba5b26234bb941a49f21ee3a4aa285ede7ae8866e9dead52b14d2926321397b1863887941f8630bf0eadc59d2
6
+ metadata.gz: 3564af10781be5858eed85223f0657581a7140e729d994fba324bbb0222532d524408a1821182352316657f73f01182254daa62cad3e5de94257ace2b96e7939
7
+ data.tar.gz: 7b327631a4d0cb1a082d26e0bebb3674549cf4b37184de7057993d942181d1e26d44c6481934d4272235758869383e192d71237cc582e860595535e5e8a0a8ce
@@ -1,6 +1,8 @@
1
1
  rvm:
2
- - 1.9.2
3
2
  - 1.9.3
4
3
  - 2.0.0
4
+ - 2.1
5
+ - 2.2
5
6
  gemfile:
6
7
  - Gemfile
8
+ - Gemfile.v0.10
@@ -1,6 +1,12 @@
1
+ ## 0.0.4 (2015/04/24)
2
+
3
+ Enhancements:
4
+
5
+ * Add filter plugin
6
+
1
7
  ## 0.0.3 (2014/02/04)
2
8
 
3
- Enhancement:
9
+ Enhancements:
4
10
 
5
11
  * Support `log_level` option of Fleuntd v0.10.43
6
12
 
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ gemspec
4
+ gem 'fluentd', '~> 0.10.0'
data/README.md CHANGED
@@ -2,14 +2,29 @@
2
2
 
3
3
  Simple Fluentd Plugin to count number of messages and outputs to log
4
4
 
5
- ## Configuration
5
+ ## Output Plugin Configuration
6
6
 
7
7
  <match foo.bar.**>
8
8
  type flowcounter_simple
9
9
  unit second
10
- </source>
10
+ </match>
11
11
 
12
- This plugin does not emit, just writes into the log file as
12
+ This plugin does not emit, just writes counts into the log file as
13
+
14
+ plugin:out_flowcounter_simple count:30 indicator:num unit:second
15
+
16
+ ## Filter Plugin Configuration
17
+
18
+ Fluentd >= v0.12
19
+
20
+ ```apache
21
+ <filter foo.bar.**>
22
+ type flowcounter_simple
23
+ unit second
24
+ </filter>
25
+ ```
26
+
27
+ This filter plugin pass through records, and writes counts into the log file as
13
28
 
14
29
  plugin:out_flowcounter_simple count:30 indicator:num unit:second
15
30
 
data/Rakefile CHANGED
@@ -9,3 +9,9 @@ Rake::TestTask.new(:test) do |test|
9
9
  end
10
10
 
11
11
  task :default => :test
12
+
13
+ desc 'Open an irb session preloaded with the gem library'
14
+ task :console do
15
+ sh 'irb -rubygems -I lib -r"fluent/load"'
16
+ end
17
+ task :c => :console
@@ -0,0 +1,13 @@
1
+ <source>
2
+ type dummy
3
+ tag dummy
4
+ </source>
5
+
6
+ <filter dummy>
7
+ type flowcounter_simple
8
+ unit second
9
+ </filter>
10
+
11
+ <match dummy>
12
+ type null
13
+ </match>
@@ -0,0 +1,9 @@
1
+ <source>
2
+ type dummy
3
+ tag dummy
4
+ </source>
5
+
6
+ <match dummy>
7
+ type flowcounter_simple
8
+ unit second
9
+ </match>
@@ -1,7 +1,7 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
  Gem::Specification.new do |gem|
3
3
  gem.name = "fluent-plugin-flowcounter-simple"
4
- gem.version = "0.0.3"
4
+ gem.version = "0.0.4"
5
5
  gem.authors = ["Naotoshi Seo"]
6
6
  gem.email = ["sonots@gmail.com"]
7
7
  gem.summary = %q{Simple Fluentd Plugin to count number of messages and outputs to log}
@@ -18,4 +18,6 @@ Gem::Specification.new do |gem|
18
18
  gem.add_development_dependency "rake"
19
19
  gem.add_development_dependency "pry"
20
20
  gem.add_development_dependency "pry-nav"
21
+ gem.add_development_dependency "test-unit"
22
+ gem.add_development_dependency "test-unit-rr"
21
23
  end
@@ -0,0 +1,21 @@
1
+ # I'm lazy to to implement filter plugin. Use output plugin instance
2
+ require_relative 'out_flowcounter_simple'
3
+ require 'forwardable'
4
+
5
+ class Fluent::FlowCounterSimpleFilter < Fluent::Filter
6
+ Fluent::Plugin.register_filter('flowcounter_simple', self)
7
+
8
+ extend Forwardable
9
+ attr_reader :output
10
+ def_delegators :@output, :configure, :start, :shutdown, :flush_emit
11
+
12
+ def initialize
13
+ super
14
+ @output = Fluent::FlowCounterSimpleOutput.new
15
+ end
16
+
17
+ def filter_stream(tag, es)
18
+ @output.emit(tag, es, Fluent::NullOutputChain.instance)
19
+ es
20
+ end
21
+ end if defined?(Fluent::Filter)
@@ -13,6 +13,15 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
13
13
  $LOAD_PATH.unshift(File.dirname(__FILE__))
14
14
  require 'fluent/test'
15
15
  require 'fluent/plugin/out_flowcounter_simple'
16
+ require 'fluent/plugin/filter_flowcounter_simple'
16
17
 
17
18
  class Test::Unit::TestCase
19
+ def capture_log(log)
20
+ tmp = log.out
21
+ log.out = StringIO.new
22
+ yield
23
+ return log.out.string
24
+ ensure
25
+ log.out = tmp
26
+ end
18
27
  end
@@ -0,0 +1,49 @@
1
+ require_relative '../helper'
2
+ require "test/unit/rr"
3
+
4
+ class FlowCounterSimpleFilterTest < Test::Unit::TestCase
5
+ include Fluent
6
+
7
+ def setup
8
+ Fluent::Test.setup
9
+ @time = Fluent::Engine.now
10
+ end
11
+
12
+ CONFIG = %[
13
+ unit second
14
+ ]
15
+
16
+ def create_driver(conf = CONFIG)
17
+ Fluent::Test::FilterTestDriver.new(Fluent::FlowCounterSimpleFilter).configure(conf, true)
18
+ end
19
+
20
+ def test_filter
21
+ msgs = []
22
+ 10.times do
23
+ msgs << {'message'=> 'a' * 100}
24
+ msgs << {'message'=> 'b' * 100}
25
+ end
26
+ d = create_driver
27
+ filtered, out = filter(d, msgs)
28
+ assert_equal msgs, filtered
29
+ assert( out.include?("count:20"), out )
30
+ end
31
+
32
+ private
33
+
34
+ def filter(d, msgs)
35
+ stub(d.instance.output).start
36
+ stub(d.instance.output).shutdown
37
+ d.run {
38
+ msgs.each {|msg|
39
+ d.filter(msg, @time)
40
+ }
41
+ }
42
+ out = capture_log(d.instance.output.log) do
43
+ d.instance.flush_emit(0)
44
+ end
45
+ filtered = d.filtered_as_array
46
+ filtered_msgs = filtered.map {|m| m[2] }
47
+ [filtered_msgs, out]
48
+ end
49
+ end if defined?(Fluent::Filter)
@@ -1,4 +1,4 @@
1
- require 'helper'
1
+ require_relative '../helper'
2
2
 
3
3
  class FlowCounterSimpleOutputTest < Test::Unit::TestCase
4
4
  def setup
@@ -37,8 +37,8 @@ class FlowCounterSimpleOutputTest < Test::Unit::TestCase
37
37
  d1.emit({'message'=> 'c' * 100})
38
38
  end
39
39
  end
40
- log = capture_log { d1.instance.flush_emit(60) }
41
- assert( log.include?("count:30"), log )
40
+ out = capture_log(d1.instance.log) { d1.instance.flush_emit(60) }
41
+ assert( out.include?("count:30"), out )
42
42
  end
43
43
 
44
44
  def test_byte
@@ -50,8 +50,8 @@ class FlowCounterSimpleOutputTest < Test::Unit::TestCase
50
50
  d1.emit({'message'=> 'c' * 100})
51
51
  end
52
52
  end
53
- log = capture_log { d1.instance.flush_emit(60) }
54
- assert( log.include?("count:3360"), log )
53
+ out = capture_log(d1.instance.log) { d1.instance.flush_emit(60) }
54
+ assert( out.include?("count:3360"), out )
55
55
  end
56
56
 
57
57
  def test_comment
@@ -63,18 +63,7 @@ class FlowCounterSimpleOutputTest < Test::Unit::TestCase
63
63
  d1.emit({'message'=> 'c' * 100})
64
64
  end
65
65
  end
66
- log = capture_log { d1.instance.flush_emit(60) }
67
- assert( log.include?("comment:foobar"), log )
68
- end
69
-
70
- private
71
-
72
- def capture_log
73
- tmp = $log.out
74
- $log.out = StringIO.new
75
- yield
76
- return $log.out.string
77
- ensure
78
- $log.out = tmp
66
+ out = capture_log(d1.instance.log) { d1.instance.flush_emit(60) }
67
+ assert( out.include?("comment:foobar"), out )
79
68
  end
80
69
  end
metadata CHANGED
@@ -1,69 +1,97 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-flowcounter-simple
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
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-02-04 00:00:00.000000000 Z
11
+ date: 2015-04-23 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: pry
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
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: pry-nav
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ">="
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: test-unit
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: test-unit-rr
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
67
95
  - !ruby/object:Gem::Version
68
96
  version: '0'
69
97
  description: Simple Fluentd Plugin to count number of messages and outputs to log
@@ -73,16 +101,21 @@ executables: []
73
101
  extensions: []
74
102
  extra_rdoc_files: []
75
103
  files:
76
- - .gitignore
77
- - .travis.yml
104
+ - ".gitignore"
105
+ - ".travis.yml"
78
106
  - CHANGELOG.md
79
107
  - Gemfile
108
+ - Gemfile.v0.10
80
109
  - LICENSE.txt
81
110
  - README.md
82
111
  - Rakefile
112
+ - examples/filter.conf
113
+ - examples/output.conf
83
114
  - fluent-plugin-flowcounter-simple.gemspec
115
+ - lib/fluent/plugin/filter_flowcounter_simple.rb
84
116
  - lib/fluent/plugin/out_flowcounter_simple.rb
85
117
  - test/helper.rb
118
+ - test/plugin/test_filter_flowcounter_simple.rb
86
119
  - test/plugin/test_out_flowcounter_simple.rb
87
120
  homepage: https://github.com/sonots/fluent-plugin-flowcounter-simple
88
121
  licenses:
@@ -94,20 +127,21 @@ require_paths:
94
127
  - lib
95
128
  required_ruby_version: !ruby/object:Gem::Requirement
96
129
  requirements:
97
- - - '>='
130
+ - - ">="
98
131
  - !ruby/object:Gem::Version
99
132
  version: '0'
100
133
  required_rubygems_version: !ruby/object:Gem::Requirement
101
134
  requirements:
102
- - - '>='
135
+ - - ">="
103
136
  - !ruby/object:Gem::Version
104
137
  version: '0'
105
138
  requirements: []
106
139
  rubyforge_project:
107
- rubygems_version: 2.0.3
140
+ rubygems_version: 2.2.2
108
141
  signing_key:
109
142
  specification_version: 4
110
143
  summary: Simple Fluentd Plugin to count number of messages and outputs to log
111
144
  test_files:
112
145
  - test/helper.rb
146
+ - test/plugin/test_filter_flowcounter_simple.rb
113
147
  - test/plugin/test_out_flowcounter_simple.rb