fluent-plugin-tag-ignore 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: cddac7d9d0e3bd923217e531a2cada6a6d7d437b
4
+ data.tar.gz: aeb4142e8dd7fe22efbbbbe6f1e6a735cf0aedc2
5
+ SHA512:
6
+ metadata.gz: f9e931a6e04ad3ec6d1f628ab6357ef286804e8dce51f74c9dcddd8ea52a2c97a629bece2adc5fc5affe156fcc3ed48e8e4c811ad409530fd6da509cbafe6021
7
+ data.tar.gz: 1e4165142887d6bdc97af204730279771cbdeb2f106084566b5a4078466ccf7f8153d0b9bdb00afa4701c811c62adf294d72d1238bd28fb6ce917e29eedf559a
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fluent-plugin-tag-ignore.gemspec
4
+ gemspec
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Shota Fukumori (sora_h)
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ # Fluent::Plugin::Tag::Ignore
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'fluent-plugin-tag-ignore'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install fluent-plugin-tag-ignore
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,15 @@
1
+ <source>
2
+ type forward
3
+ </source>
4
+
5
+ <match **>
6
+ type tag_ignore
7
+
8
+ <ignore>
9
+ glob ignore.**
10
+ </ignore>
11
+
12
+ <store>
13
+ type stdout
14
+ </store>
15
+ </match>
@@ -0,0 +1,26 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'fluent-plugin-tag-ignore/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "fluent-plugin-tag-ignore"
8
+ spec.version = Fluent::TagIgnoreOutput::VERSION
9
+ spec.authors = ["Shota Fukumori (sora_h)"]
10
+ spec.email = ["her@sorah.jp"]
11
+ spec.description = %q{Plugin for fluentd, this allows you to specify ignore patterns for match.}
12
+ spec.summary = %q{this fluentd-plugin allows you to specify ignore patterns for match directive.}
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files`.split($/)
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "fluentd", "~> 0.10"
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.3"
24
+ spec.add_development_dependency "rake"
25
+ spec.add_development_dependency "rspec", '~> 2.14.1'
26
+ end
@@ -0,0 +1,5 @@
1
+ module Fluent
2
+ class TagIgnoreOutput
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
@@ -0,0 +1,57 @@
1
+ require 'fluent/output'
2
+ require 'fluent/match'
3
+ require 'fluent-plugin-tag-ignore/version'
4
+
5
+ v = Fluent::TagIgnoreOutput::VERSION
6
+ module Fluent
7
+ remove_const :TagIgnoreOutput
8
+ end
9
+
10
+ class Fluent::TagIgnoreOutput < Fluent::MultiOutput
11
+ Fluent::Plugin.register_output('tag_ignore', self)
12
+
13
+ def initialize(*)
14
+ super
15
+ @propagatee = nil
16
+ @patterns = []
17
+ end
18
+
19
+ def configure(conf)
20
+ super
21
+
22
+ store = conf.elements.find { |e| e.name == 'store' }
23
+ raise Fluent::ConfigError, 'Missing `store` for tag_ignore' unless store
24
+
25
+ type = store['type']
26
+ raise Fluent::ConfigError, 'Missing `type` for tag_ignore store configuration' unless type
27
+
28
+ @propagatee = Fluent::Plugin.new_output(type)
29
+ @propagatee.configure(store)
30
+
31
+ @patterns = conf.elements.select { |e| e.name == 'ignore' }.map do |e|
32
+ raise Fluent::ConfigError, 'Missing `glob` for tag_ignore ignore configuration' unless e['glob']
33
+ Fluent::GlobMatchPattern.new(e['glob'])
34
+ end
35
+ end
36
+
37
+ def start
38
+ super
39
+ @propagatee.start
40
+ end
41
+
42
+ def shutdown
43
+ super
44
+ @propagatee.shutdown
45
+ end
46
+
47
+ def emit(tag, es, chain)
48
+ if @patterns.any? { |pat| pat.match(tag) }
49
+ chain.next
50
+ return
51
+ end
52
+
53
+ @propagatee.emit(tag, es, chain)
54
+ end
55
+ end
56
+
57
+ Fluent::TagIgnoreOutput.send(:const_set, :VERSION, v)
@@ -0,0 +1,109 @@
1
+ require 'spec_helper'
2
+ require 'fluent/test'
3
+ require 'fluent/plugin/out_tag_ignore'
4
+ require_relative 'support/out_tag_ignore_tester'
5
+
6
+ describe Fluent::TagIgnoreOutput do
7
+ before(:each) do
8
+ Fluent::TagIgnoreTesterOutput.records.clear
9
+ Fluent::Test.setup
10
+ end
11
+
12
+
13
+ let(:tag) { 'test' }
14
+
15
+ let(:conf) do
16
+ <<-EOC
17
+ <store>
18
+ type tag_ignore_tester
19
+ </store>
20
+ EOC
21
+ end
22
+
23
+ let(:driver) do
24
+ Fluent::Test::OutputTestDriver.new(described_class, tag).configure(conf)
25
+ end
26
+
27
+ let(:time) { Time.now }
28
+
29
+ it "propagates to <store>" do
30
+ expect {
31
+ driver.run { driver.emit({'msg' => 'message'}, time) }
32
+ }.to change { Fluent::TagIgnoreTesterOutput.records.last } \
33
+ .from(nil).to(['test', 'msg' => 'message'])
34
+ end
35
+
36
+ context "with ignore pattern" do
37
+ let(:conf) do
38
+ <<-EOC
39
+ <ignore>
40
+ glob rej.**
41
+ </ignore>
42
+
43
+ <store>
44
+ type tag_ignore_tester
45
+ </store>
46
+ EOC
47
+ end
48
+
49
+ it "doesn't propagate logs with matched tag" do
50
+ expect {
51
+ driver.tag = 'test'; driver.run { driver.emit({'m' => 'msg'}, time) }
52
+ driver.tag = 'rej.test'; driver.run { driver.emit({'m' => 'rej'}, time) }
53
+ }.to change { Fluent::TagIgnoreTesterOutput.records.size } \
54
+ .from(0).to(1)
55
+
56
+ expect(Fluent::TagIgnoreTesterOutput.records.last).to \
57
+ eq(['test', 'm' => 'msg'])
58
+ end
59
+ end
60
+
61
+ context "with many ignore patterns" do
62
+ let(:conf) do
63
+ <<-EOC
64
+ <ignore>
65
+ glob rej.**
66
+ </ignore>
67
+
68
+ <ignore>
69
+ glob deny.**
70
+ </ignore>
71
+
72
+ <store>
73
+ type tag_ignore_tester
74
+ </store>
75
+ EOC
76
+ end
77
+
78
+ it "doesn't propagate logs with matched tag" do
79
+ expect {
80
+ driver.tag = 'deny.test'; driver.run { driver.emit({'m' => 'deny'}, time) }
81
+ driver.tag = 'test'; driver.run { driver.emit({'m' => 'msg'}, time) }
82
+ driver.tag = 'rej.test'; driver.run { driver.emit({'m' => 'rej'}, time) }
83
+ }.to change { Fluent::TagIgnoreTesterOutput.records.size } \
84
+ .from(0).to(1)
85
+
86
+ expect(Fluent::TagIgnoreTesterOutput.records.last).to \
87
+ eq(['test', 'm' => 'msg'])
88
+ end
89
+ end
90
+
91
+ context "with store configuration" do
92
+ let(:conf) do
93
+ <<-EOC
94
+ <store>
95
+ type tag_ignore_tester
96
+ foo baz
97
+ </store>
98
+ EOC
99
+ end
100
+ let(:tag) { 'foo' }
101
+
102
+ it "uses substore configuration" do
103
+ expect {
104
+ driver.run { driver.emit({'msg' => 'message'}, time) }
105
+ }.to change { Fluent::TagIgnoreTesterOutput.records.last } \
106
+ .from(nil).to(['foo', 'baz'])
107
+ end
108
+ end
109
+ end
@@ -0,0 +1,11 @@
1
+ # This file was generated by the `rspec --init` command. Conventionally, all
2
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
3
+ # Require this file using `require "spec_helper"` to ensure that it is only
4
+ # loaded once.
5
+ #
6
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
7
+ RSpec.configure do |config|
8
+ config.treat_symbols_as_metadata_keys_with_true_values = true
9
+ config.run_all_when_everything_filtered = true
10
+ config.filter_run :focus
11
+ end
@@ -0,0 +1,25 @@
1
+ require 'fluent/test'
2
+
3
+ class Fluent::TagIgnoreTesterOutput < Fluent::Output
4
+ Fluent::Plugin.register_output('tag_ignore_tester', self)
5
+
6
+ config_param :foo, :string, :default => 'bar'
7
+
8
+ class << self
9
+ def records
10
+ @records ||= []
11
+ end
12
+ end
13
+
14
+ def emit(tag, es, chain)
15
+ es.each do |t, record|
16
+ if tag == 'foo'
17
+ self.class.records << ['foo', @foo]
18
+ else
19
+ self.class.records << [tag, record]
20
+ end
21
+ end
22
+
23
+ chain.next
24
+ end
25
+ end
metadata ADDED
@@ -0,0 +1,116 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-tag-ignore
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Shota Fukumori (sora_h)
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2013-09-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: fluentd
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '0.10'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '0.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '1.3'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '1.3'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 2.14.1
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 2.14.1
69
+ description: Plugin for fluentd, this allows you to specify ignore patterns for match.
70
+ email:
71
+ - her@sorah.jp
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - .gitignore
77
+ - .rspec
78
+ - Gemfile
79
+ - LICENSE.txt
80
+ - README.md
81
+ - Rakefile
82
+ - example.conf
83
+ - fluent-plugin-tag-ignore.gemspec
84
+ - lib/fluent-plugin-tag-ignore/version.rb
85
+ - lib/fluent/plugin/out_tag_ignore.rb
86
+ - spec/out_tag_ignore_spec.rb
87
+ - spec/spec_helper.rb
88
+ - spec/support/out_tag_ignore_tester.rb
89
+ homepage: ''
90
+ licenses:
91
+ - MIT
92
+ metadata: {}
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ requirements:
99
+ - - '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ required_rubygems_version: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - '>='
105
+ - !ruby/object:Gem::Version
106
+ version: '0'
107
+ requirements: []
108
+ rubyforge_project:
109
+ rubygems_version: 2.0.3
110
+ signing_key:
111
+ specification_version: 4
112
+ summary: this fluentd-plugin allows you to specify ignore patterns for match directive.
113
+ test_files:
114
+ - spec/out_tag_ignore_spec.rb
115
+ - spec/spec_helper.rb
116
+ - spec/support/out_tag_ignore_tester.rb