fluent-plugin-retag 0.0.2 → 0.1.0

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: c1a56b2c7c9ff8c152f581ebef1909dc4ba0749f
4
- data.tar.gz: 109309b4d2773227e2d5e79ba5513228ebab9612
3
+ metadata.gz: 274ade0964d0e63df8227fe94598a609106a53fd
4
+ data.tar.gz: 774a744bdbde01aa4f643e25d588c8178246585c
5
5
  SHA512:
6
- metadata.gz: bb325a2f3a08c6590f9cff36f812d6e70c46f02c673272c83f63350b1e8db4034850aff91adb1c9019ef576d751e6e9108fc2d620f3fc8b7c3f0316fc522dc51
7
- data.tar.gz: 666943f651598f0429ea4fcfeecc48d15907d6bfe3563783230cca5d0e954f28c43013164bc2f49a2f82c92b88665bd60ab90ef0f244e5447294dbe8c93d1557
6
+ metadata.gz: ab34927fba8fc079b7a2a22e2bd1e3e0e7669ecedc8a353ab2e91ba791762e6706fd6184f05a5588c3966802a59940ed0b552fae64fa09dc38b703ebb7bd8fb1
7
+ data.tar.gz: c02f15e992779ac29e630bf88a496b54000f66f40c8f51f2fbba02ceae583a6527ba002a062613b24094b11d389240a92aea61d348540889cff4cd537b60194a
data/Gemfile CHANGED
@@ -2,5 +2,3 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in fluent-plugin-retag.gemspec
4
4
  gemspec
5
- gem "rake"
6
- gem "test-unit"
data/README.md CHANGED
@@ -15,14 +15,14 @@ Output plugin only retagging.
15
15
  To retag foo.bar to hoge.fuga:
16
16
 
17
17
  <match foo.bar>
18
- type retag
18
+ @type retag
19
19
  tag hoge.fuga
20
20
  </match>
21
21
 
22
22
  To retag foo.bar.** to xyz.bar.**:
23
23
 
24
24
  <match foo.bar>
25
- type retag
25
+ @type retag
26
26
  remove_prefix foo
27
27
  add_prefix xyz
28
28
  </match>
@@ -32,9 +32,9 @@ To retag foo.bar.** to xyz.bar.**:
32
32
  If you want to use branch condition, it is useful to use out_copy with fluent-plugin-retag.
33
33
 
34
34
  <match foo.bar.**>
35
- type copy
35
+ @type copy
36
36
  <store>
37
- type retag
37
+ @type retag
38
38
  add_prefix copied
39
39
  </store>
40
40
  <store>
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |gem|
6
6
  gem.name = "fluent-plugin-retag"
7
- gem.version = "0.0.2"
7
+ gem.version = "0.1.0"
8
8
  gem.authors = ["Masahiro Yamauchi"]
9
9
  gem.email = ["sgt.yamauchi@gmail.com"]
10
10
  gem.description = %q{Output filter plugin to retag}
@@ -16,6 +16,7 @@ Gem::Specification.new do |gem|
16
16
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
- gem.add_development_dependency "fluentd"
20
- gem.add_runtime_dependency "fluentd"
19
+ gem.add_development_dependency "rake", "~> 12.0"
20
+ gem.add_development_dependency "test-unit", "~> 3.2"
21
+ gem.add_runtime_dependency "fluentd", [">= 0.14.8", "< 2"]
21
22
  end
@@ -1,6 +1,10 @@
1
- class Fluent::RetagOutput < Fluent::Output
1
+ require 'fluent/plugin/output'
2
+
3
+ class Fluent::Plugin::RetagOutput < Fluent::Plugin::Output
2
4
  Fluent::Plugin.register_output('retag', self)
3
5
 
6
+ helpers :event_emitter
7
+
4
8
  config_param :tag, :string, :default => nil
5
9
  config_param :remove_prefix, :string, :default => nil
6
10
  config_param :add_prefix, :string, :default => nil
@@ -29,11 +33,11 @@ class Fluent::RetagOutput < Fluent::Output
29
33
  @removed_suffix_pos = 0 - @removed_suffix_length
30
34
  end
31
35
  if @add_suffix
32
- @added_suffix_string = '.' + @add_suffix
36
+ @added_suffix_string = '.' + @add_suffix
33
37
  end
34
38
  end
35
39
 
36
- def emit(tag, es, chain)
40
+ def process(tag, es)
37
41
  tag = if @tag
38
42
  @tag
39
43
  else
@@ -44,15 +48,15 @@ class Fluent::RetagOutput < Fluent::Output
44
48
  if @remove_prefix and
45
49
  ( (tag.start_with?(@removed_prefix_string) and tag.length > @removed_length) or tag == @remove_prefix)
46
50
  tag = tag[@removed_length..-1]
47
- end
48
- if @add_prefix
51
+ end
52
+ if @add_prefix
49
53
  tag = if tag and tag.length > 0
50
54
  @added_prefix_string + tag
51
55
  else
52
56
  @add_prefix
53
57
  end
54
58
  end
55
- if @add_suffix
59
+ if @add_suffix
56
60
  tag = if tag and tag.length > 0
57
61
  tag + @added_suffix_string
58
62
  else
@@ -64,7 +68,5 @@ class Fluent::RetagOutput < Fluent::Output
64
68
  es.each do |time,record|
65
69
  router.emit(tag, time, record)
66
70
  end
67
- chain.next
68
71
  end
69
72
  end
70
-
data/test/helper.rb CHANGED
@@ -12,6 +12,8 @@ require 'test/unit'
12
12
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
13
13
  $LOAD_PATH.unshift(File.dirname(__FILE__))
14
14
  require 'fluent/test'
15
+ require 'fluent/test/helpers'
16
+ require 'fluent/test/driver/output'
15
17
  unless ENV.has_key?('VERBOSE')
16
18
  nulllogger = Object.new
17
19
  nulllogger.instance_eval {|obj|
@@ -25,5 +27,5 @@ end
25
27
  require 'fluent/plugin/out_retag'
26
28
 
27
29
  class Test::Unit::TestCase
30
+ include Fluent::Test::Helpers
28
31
  end
29
-
@@ -16,8 +16,8 @@ class RetagOutputTest < Test::Unit::TestCase
16
16
  add_prefix head
17
17
  ]
18
18
 
19
- def create_driver(conf = CONFIG, tag='test')
20
- Fluent::Test::OutputTestDriver.new(Fluent::RetagOutput, tag).configure(conf)
19
+ def create_driver(conf = CONFIG)
20
+ Fluent::Test::Driver::Output.new(Fluent::Plugin::RetagOutput).configure(conf)
21
21
  end
22
22
 
23
23
  def test_configure
@@ -51,46 +51,42 @@ class RetagOutputTest < Test::Unit::TestCase
51
51
  end
52
52
 
53
53
  def test_emit
54
- d = create_driver(CONFIG, 'foo.bar')
55
- time = Time.parse('2011-03-11 14:46:01').to_i
56
- d.run do
57
- d.emit({'a' => 'b'})
58
- d.emit({'c' => 'd'})
54
+ d = create_driver(CONFIG)
55
+ time = event_time('2011-03-11 14:46:01')
56
+ d.run(default_tag: 'foo.bar') do
57
+ d.feed(time, {'a' => 'b'})
58
+ d.feed(time, {'c' => 'd'})
59
59
  end
60
- emits = d.emits
60
+ emits = d.events
61
61
  assert_equal 2, emits.length
62
- p emits[0]
63
62
  assert_equal 'hoge', emits[0][0]
64
63
  assert_equal 'b', emits[0][2]['a']
65
64
  end
66
65
 
67
66
  def test_emit2
68
- d = create_driver(CONFIG2, 'foo.bar')
69
- time = Time.parse('2011-03-11 14:46:01').to_i
70
- d.run do
71
- d.emit({'a' => 'b'})
72
- d.emit({'c' => 'd'})
67
+ d = create_driver(CONFIG2)
68
+ time = event_time('2011-03-11 14:46:01')
69
+ d.run(default_tag: 'foo.bar') do
70
+ d.feed(time, {'a' => 'b'})
71
+ d.feed(time, {'c' => 'd'})
73
72
  end
74
- emits = d.emits
73
+ emits = d.events
75
74
  assert_equal 2, emits.length
76
- p emits[0]
77
75
  assert_equal 'bar', emits[0][0]
78
76
  assert_equal 'b', emits[0][2]['a']
79
77
  end
80
78
 
81
79
  def test_emit3
82
- d = create_driver(CONFIG3, 'foo.bar')
83
- time = Time.parse('2011-03-11 14:46:01').to_i
84
- d.run do
85
- d.emit({'a' => 'b'})
86
- d.emit({'c' => 'd'})
80
+ d = create_driver(CONFIG3)
81
+ time = event_time('2011-03-11 14:46:01')
82
+ d.run(default_tag: 'foo.bar') do
83
+ d.feed(time, {'a' => 'b'})
84
+ d.feed(time, {'c' => 'd'})
87
85
  end
88
- emits = d.emits
86
+ emits = d.events
89
87
  assert_equal 2, emits.length
90
- p emits[0]
91
88
  assert_equal 'head.bar', emits[0][0]
92
89
  assert_equal 'b', emits[0][2]['a']
93
90
  end
94
91
 
95
92
  end
96
-
metadata CHANGED
@@ -1,43 +1,63 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-retag
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masahiro Yamauchi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-08 00:00:00.000000000 Z
11
+ date: 2017-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: fluentd
14
+ name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '12.0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '12.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: test-unit
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
25
32
  - !ruby/object:Gem::Version
26
- version: '0'
33
+ version: '3.2'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '3.2'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: fluentd
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
45
  - - ">="
32
46
  - !ruby/object:Gem::Version
33
- version: '0'
47
+ version: 0.14.8
48
+ - - "<"
49
+ - !ruby/object:Gem::Version
50
+ version: '2'
34
51
  type: :runtime
35
52
  prerelease: false
36
53
  version_requirements: !ruby/object:Gem::Requirement
37
54
  requirements:
38
55
  - - ">="
39
56
  - !ruby/object:Gem::Version
40
- version: '0'
57
+ version: 0.14.8
58
+ - - "<"
59
+ - !ruby/object:Gem::Version
60
+ version: '2'
41
61
  description: Output filter plugin to retag
42
62
  email:
43
63
  - sgt.yamauchi@gmail.com