fluent-plugin-input-gelf 0.2.0 → 0.3.1

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
- SHA1:
3
- metadata.gz: eee1b338888b0ca1ec6f85012c47afbf14266fd4
4
- data.tar.gz: 7d0557b52f33d68de6e1469f9e184a96e43de44d
2
+ SHA256:
3
+ metadata.gz: 8f097e210aed3af36c1e2d4e69863ae9e7def76a8dc146b1d62142e7a468021d
4
+ data.tar.gz: 12fc71512e8cfd1a77bf061caf6857e2b8da1489a0050054dac7071a507ffb10
5
5
  SHA512:
6
- metadata.gz: bb91d66ad6039147e5f795a9037e61f41541e7f1b0309ff0d0ebcc8ef15f0dbbdc6e2437f24254bbad67cec5c61da7fcf8f7c67cbf3535ff8d7fc5ee19b0f967
7
- data.tar.gz: b69d7aa70c1b58b28604c8c3f566197e4ded4928975c6a07d2be38c90a837a908a4c0f9e3b9cbfd55b74b326b1c20df011957a4faeb16f9495ad05e6be003f4f
6
+ metadata.gz: 8811bb2fb2d6d81120d7007d7ca939fd065f22ae0d6ba41f6bd6279c74e8e3cc6926f7b82c441f73f33a784de3c965d59fc5f940721b344b0a36a5b80ef668fd
7
+ data.tar.gz: 04f05ae7694cadf96b89d6ed249e03d10228be6282cfff4652a0347414bd634b49222f62d472594594e1c77b4bc43be10b2894343ef406fe5a8831482be1ef81
@@ -1,16 +1,33 @@
1
1
  language: ruby
2
2
 
3
3
  rvm:
4
- - 2.1
5
- - 2.2.2
6
- - 2.3.0
7
- - 2.4.0
4
+ - 2.1
5
+ - 2.2
6
+ - 2.3
7
+ - 2.4
8
+ - 2.5
8
9
 
9
10
  gemfile:
10
- - Gemfile
11
+ - Gemfile
11
12
 
12
13
  branches:
13
14
  only:
14
- - master
15
+ - master
16
+ # Tagged commits
17
+ - /^v\d+\.\d+(\.\d+)?(-\S*)?$/
15
18
 
16
19
  script: bundle exec rake test
20
+
21
+ jobs:
22
+ include:
23
+ - stage: gem release
24
+ rvm: 2.3
25
+ script: echo "Deploying to rubygems.org ..."
26
+ deploy:
27
+ provider: rubygems
28
+ api_key:
29
+ secure: R06ICCYHjZ+bk+CocD+eZROiTsfDnmUlugdSIqND0f9Z+Vi8ALOZmIEhlpBvloRaOLU0pz3d9juj74vHMJ1boJN6Qgn+CtAGSDzesxm6vcd/AP87mEzAaJvvHRme7bNLy7gt1RvrmVzDjyOe2fF8kcVAz19bEArJ1rqBXeLiLY+fOPenCsWRNrOt2+yOH5qRgdFs+n2NQ6oQrDEq18uZJVQ74WnSyKGylIhPfXj+TcgMrDGJtxqWYmL+DeuzOVk73REMHiw+9ljvhjVIdMxiU/oXge9y7Ua7q6OlkJgmChaWrs06bHiwhJHz6yh+OXebVFbxHTsPdsw4w+Uv9/MB961zgR58yLVi6AJr5xosM8l92S/OJeG9paO43xuQGeX+mch7m/827VbeM8aLtRGXjNILC3BW+l9O++Yg0eF6YC4c6NobNOX4ZpfGNopDsoyYI19Yj9SoKvoqw3WtAZsX2T5CrAdG1PHLKNDwyCbuiYjlNKAAHy5ZCB7X63JrDAKgwUQSnYEPEGNVzisnNfyqVxQnvTDZLwgzWcYxTBCjXoO09+qsbB9lpgecT45UI80VgW70nokEzilmyXARG+eBGKhz2iJli+mrdZbpfzws/PD/Hr5dubgn8mNX5/e6DRMoTr9xQOGrvdXhET+ygiTEWg1VMzfcZ2WpeJTveV9h2BQ=
30
+ gem: fluent-plugin-input-gelf
31
+ on:
32
+ tags: true
33
+ repo: MerlinDMC/fluent-plugin-input-gelf
@@ -7,7 +7,7 @@ Gem::Specification.new do |gem|
7
7
  gem.license = "MIT"
8
8
  gem.homepage = "https://github.com/MerlinDMC/fluent-plugin-input-gelf"
9
9
  gem.summary = gem.description
10
- gem.version = "0.2.0"
10
+ gem.version = "0.3.1"
11
11
  gem.authors = ["Daniel Malon"]
12
12
  gem.email = "daniel.malon@me.com"
13
13
  gem.has_rdoc = false
@@ -16,7 +16,7 @@ Gem::Specification.new do |gem|
16
16
  gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
17
17
  gem.require_paths = ['lib']
18
18
 
19
- gem.add_runtime_dependency "fluentd"
19
+ gem.add_runtime_dependency "fluentd", [">= 0.14.10", "< 2"]
20
20
  gem.add_runtime_dependency "gelfd2", ">= 0.3.0"
21
21
 
22
22
  gem.add_development_dependency "bundler"
@@ -4,68 +4,52 @@ require 'time'
4
4
  require 'cool.io'
5
5
  require 'yajl'
6
6
 
7
- require 'fluent/input'
7
+ require 'gelfd2'
8
8
 
9
- module Fluent
10
- class GelfInput < Fluent::Input
9
+ require 'fluent/plugin/input'
10
+
11
+ module Fluent::Plugin
12
+ class GelfInput < Fluent::Plugin::Input
11
13
  Fluent::Plugin.register_input('gelf', self)
12
14
 
15
+ helpers :server, :parser, :compat_parameters
16
+
17
+ DEFAULT_PARSER = 'json'.freeze
18
+
13
19
  def initialize
14
20
  super
15
- require 'fluent/plugin/socket_util'
16
- require 'gelfd2'
17
21
  end
18
22
 
19
23
  desc "The value is the tag assigned to the generated events."
20
24
  config_param :tag, :string
21
- desc 'The format of the payload.'
22
- config_param :format, :string, default: 'json'
23
25
  desc 'The port to listen to.'
24
26
  config_param :port, :integer, default: 12201
25
27
  desc 'The bind address to listen to.'
26
28
  config_param :bind, :string, default: '0.0.0.0'
27
29
  desc 'The transport protocol used to receive logs.(udp, tcp)'
28
- config_param :protocol_type, default: :udp do |val|
29
- case val.downcase
30
- when 'tcp'
31
- :tcp
32
- when 'udp'
33
- :udp
34
- else
35
- raise ConfigError, "gelf input protocol type should be 'tcp' or 'udp'"
36
- end
37
- end
38
- config_param :blocking_timeout, :time, default: 0.5
30
+ config_param :protocol_type, :enum, list: [:udp, :tcp], default: :udp
39
31
  desc 'Strip leading underscore'
40
32
  config_param :strip_leading_underscore, :bool, default: true
41
33
 
34
+ config_section :parse do
35
+ config_set_default :@type, DEFAULT_PARSER
36
+ end
37
+
42
38
  def configure(conf)
39
+ compat_parameters_convert(conf, :parser)
43
40
  super
44
41
 
45
- @parser = Plugin.new_parser(@format)
46
- @parser.configure(conf)
42
+ @parser = parser_create
47
43
  end
48
44
 
49
45
  def start
50
- @loop = Coolio::Loop.new
51
- @handler = listen(method(:receive_data))
52
- @loop.attach(@handler)
46
+ super
53
47
 
54
- @thread = Thread.new(&method(:run))
48
+ listen
55
49
  end
56
50
 
57
51
  def shutdown
58
- @loop.watchers.each { |w| w.detach }
59
- @loop.stop
60
- @handler.close
61
- @thread.join
62
- end
63
-
64
- def run
65
- @loop.run(@blocking_timeout)
66
- rescue
67
- log.error 'unexpected error', error: $!.to_s
68
- log.error_backtrace
52
+ super
69
53
  end
70
54
 
71
55
  def receive_data(data, addr)
@@ -86,7 +70,7 @@ module Fluent
86
70
  end
87
71
 
88
72
  # Use the recorded event time if available
89
- time = record.delete('timestamp').to_i if record.key?('timestamp')
73
+ time = record.delete('timestamp').to_f if record.key?('timestamp')
90
74
 
91
75
  # Postprocess recorded event
92
76
  strip_leading_underscore_(record) if @strip_leading_underscore
@@ -98,14 +82,16 @@ module Fluent
98
82
  log.error_backtrace
99
83
  end
100
84
 
101
- def listen(callback)
85
+ def listen
102
86
  log.info "listening gelf socket on #{@bind}:#{@port} with #{@protocol_type}"
103
87
  if @protocol_type == :tcp
104
- Coolio::TCPServer.new(@bind, @port, SocketUtil::TcpHandler, log, "\n", callback)
88
+ server_create(:in_tcp_server, @port, bind: @bind) do |data, conn|
89
+ receive_data(data, conn)
90
+ end
105
91
  else
106
- @usock = SocketUtil.create_udp_socket(@bind)
107
- @usock.bind(@bind, @port)
108
- SocketUtil::UdpHandler.new(@usock, log, 8192, callback)
92
+ server_create(:in_udp_server, @port, proto: :udp, bind: @bind, max_bytes: 8192) do |data, sock|
93
+ receive_data(data, sock)
94
+ end
109
95
  end
110
96
  end
111
97
 
@@ -20,7 +20,7 @@ class GelfInputTest < Test::Unit::TestCase
20
20
  !
21
21
 
22
22
  def create_driver(conf)
23
- Fluent::Test::InputTestDriver.new(Fluent::GelfInput).configure(conf)
23
+ Fluent::Test::Driver::Input.new(Fluent::Plugin::GelfInput).configure(conf)
24
24
  end
25
25
 
26
26
  def test_configure
@@ -31,7 +31,7 @@ class GelfInputTest < Test::Unit::TestCase
31
31
  d = create_driver(v)
32
32
  assert_equal PORT, d.instance.port
33
33
  assert_equal k, d.instance.bind
34
- assert_equal 'json', d.instance.format
34
+ assert_equal 'json', d.instance.parser_configs.first["@type"]
35
35
  }
36
36
  end
37
37
 
@@ -48,22 +48,19 @@ class GelfInputTest < Test::Unit::TestCase
48
48
  {:short_message => 'short message', :full_message => 'full message', :timestamp => 12345678.12345}
49
49
  ]
50
50
 
51
- d.run do
51
+ d.run(expect_emits: 2) do
52
52
  n = GELF::Notifier.new(k, PORT)
53
53
 
54
54
  tests.each { |test|
55
55
  n.notify!(test)
56
56
  }
57
-
58
- sleep 1
59
57
  end
60
58
 
61
- emits = d.emits
59
+ emits = d.events
62
60
  assert_equal tests.length, emits.length, 'missing emitted events'
63
61
  emits.each_index { |i|
64
- puts emits[i].to_s
65
62
  assert_equal 'gelf', emits[i][0]
66
- assert_equal tests[i][:timestamp].to_i, emits[i][1] unless tests[i][:timestamp].nil?
63
+ assert_equal tests[i][:timestamp].to_f, emits[i][1] unless tests[i][:timestamp].nil?
67
64
  assert_equal tests[i][:short_message], emits[i][2]['short_message']
68
65
  assert_equal tests[i][:full_message], emits[i][2]['full_message']
69
66
  }
@@ -95,22 +92,19 @@ class GelfInputTest < Test::Unit::TestCase
95
92
  }
96
93
  ]
97
94
 
98
- d.run do
95
+ d.run(expect_emits: 1) do
99
96
  n = GELF::Notifier.new(k, PORT)
100
97
 
101
98
  tests.each { |test|
102
99
  n.notify!(test[:given])
103
100
  }
104
-
105
- sleep 1
106
101
  end
107
102
 
108
- emits = d.emits
103
+ emits = d.events
109
104
  assert_equal tests.length, emits.length, 'missing emitted events'
110
105
  emits.each_index { |i|
111
- puts emits[i].to_s
112
106
  assert_equal 'gelf', emits[i][0]
113
- assert_equal tests[i][:timestamp].to_i, emits[i][1] unless tests[i][:timestamp].nil?
107
+ assert_equal tests[i][:timestamp].to_f, emits[i][1] unless tests[i][:timestamp].nil?
114
108
  assert_block "expectation not met: #{tests[i][:expected]}" do
115
109
  emits[i][2].merge(tests[i][:expected]) == emits[i][2]
116
110
  end
@@ -13,16 +13,7 @@ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
13
13
  $LOAD_PATH.unshift(File.dirname(__FILE__))
14
14
 
15
15
  require 'fluent/test'
16
- unless ENV.has_key?('VERBOSE')
17
- nulllogger = Object.new
18
- nulllogger.instance_eval {|obj|
19
- def method_missing(method, *args)
20
- # pass
21
- end
22
- }
23
- $log = nulllogger
24
- end
25
-
16
+ require 'fluent/test/driver/input'
26
17
  require 'fluent/plugin/in_gelf'
27
18
 
28
19
  def unused_port
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-input-gelf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Malon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-02-11 00:00:00.000000000 Z
11
+ date: 2019-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -16,14 +16,20 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: 0.14.10
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '2'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - ">="
25
28
  - !ruby/object:Gem::Version
26
- version: '0'
29
+ version: 0.14.10
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '2'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: gelfd2
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -129,11 +135,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
129
135
  - !ruby/object:Gem::Version
130
136
  version: '0'
131
137
  requirements: []
132
- rubyforge_project:
133
- rubygems_version: 2.6.8
138
+ rubygems_version: 3.0.3
134
139
  signing_key:
135
140
  specification_version: 4
136
141
  summary: A GELF input plugin for fluentd
137
- test_files:
138
- - test/plugin/test_in_gelf.rb
139
- - test/test_helper.rb
142
+ test_files: []