fluent-plugin-kinesis-aggregation 0.2.3 → 0.3.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: 9c7aa063d31e8a8d8b373a723b31cb6c284e4bdd
4
- data.tar.gz: c4ca64341656418dd2e197c6d76d1ee40508c77f
3
+ metadata.gz: b75bac816dfcbedd2d634402e10f2e4c00bb9b0c
4
+ data.tar.gz: d4b59d91022744f5e9a4dcfe7d8f0e4d6ee89878
5
5
  SHA512:
6
- metadata.gz: 52f71d9072671d888c774163a0216651987f248c67f2a0c11dd7709bd3326619355b6a2dc7807e545616d3aa4512eebb8161bcc0c3019c1add4b39e0e0228962
7
- data.tar.gz: ad1ac4922c2f9e0ef39f9f4e0314b034e6a0c7f925511cab377f28574559018e33b7d0dbafe8acd40728ab884879b705eee274c1033b0f07137b757fde5c6182
6
+ metadata.gz: 0d06cdd97c38fdfa5a6f6ae66547718a4fd7d5d93453a9d2f3c7d749fd0fc93e6ab2d148c791815ab3e289bce4f8f1c00a4f944af938b4149a9fe6653b44685b
7
+ data.tar.gz: 8bb20bed570042d2619ec72a808b3a046d50b6a14065618b88294d55ed94d951fd5540646f6ac2321c483cd68ab19dd389e9cc701ec8b0732bd37985d7e358d5
@@ -1,6 +1,8 @@
1
1
  language: ruby
2
2
 
3
3
  rvm:
4
+ - 2.4
5
+ - 2.3
4
6
  - 2.2
5
7
  - 2.1
6
8
 
@@ -1,9 +1,19 @@
1
1
  # CHANGELOG
2
2
 
3
- ## Next
3
+ ## 0.3.0
4
+
5
+ - Update to use fluentd 0.14 API (stick to 0.2.3 if you need support for earlier versions of fluentd)
6
+ Much thanks to cosmo0920 for doing this.
7
+
8
+ ## 0.2.3
9
+
10
+ - emit stream name in error
11
+
12
+ ## 0.2.1 - 0.2.2
4
13
 
5
14
  - update documentation to refer to published gem
6
15
  - turn on testing for Ruby 2.1
16
+ - allow running on Ruby 2.1
7
17
 
8
18
  ## 0.2.0
9
19
 
data/README.md CHANGED
@@ -145,24 +145,28 @@ forces all writes to a specific shard, and if you're using
145
145
  a single thread/process will probably keep event ordering
146
146
  (not recommended - watch out for hot shards!).
147
147
 
148
- ### detach_process
149
-
150
- Integer. Optional. This defines the number of parallel processes to start.
151
- This can be used to increase throughput by allowing multiple processes to
152
- execute the plugin at once. Setting this option to > 0 will cause the plugin
153
- to run in a separate process. The default is 0.
154
-
155
148
  ### num_threads
156
149
 
157
150
  Integer. The number of threads to flush the buffer. This plugin is based on
158
- Fluentd::BufferedOutput, so we buffer incoming records before emitting them to
151
+ Fluentd::Plugin::Output, so we buffer incoming records before emitting them to
159
152
  Amazon Kinesis. You can find the detail about buffering mechanism [here](http://docs.fluentd.org/articles/buffer-plugin-overview).
160
153
  Emitting records to Amazon Kinesis via network causes I/O Wait, so parallelizing
161
154
  emitting with threads will improve throughput.
162
155
 
163
156
  This option can be used to parallelize writes into the output(s)
164
157
  designated by the output plugin. The default is 1.
165
- Also you can use this option with *detach_process*.
158
+ Also you can use this option with *multi workers*.
159
+
160
+ ### multi workers
161
+
162
+ This feature is introduced in Fluentd v0.14.
163
+ Instead of using *detach_process*, this feature can use as the following system directive.
164
+ Note that *detach_process* parameter is removed after using v0.14 Output Plugin API.
165
+ The default is 1.
166
+
167
+ <system>
168
+ workers 5
169
+ </system>
166
170
 
167
171
  ### debug
168
172
 
@@ -17,11 +17,12 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
17
17
 
18
18
  Gem::Specification.new do |spec|
19
19
  spec.name = "fluent-plugin-kinesis-aggregation"
20
- spec.version = '0.2.3'
20
+ spec.version = '0.3.0'
21
21
  spec.author = 'Atlassian'
22
+ spec.email = 'jhaggerty@atlassian.com'
22
23
  spec.summary = %q{Fluentd output plugin that sends KPL style aggregated events to Amazon Kinesis.}
23
24
  spec.homepage = "https://github.com/atlassian/fluent-plugin-kinesis-aggregation"
24
- spec.license = "Apache License, Version 2.0"
25
+ spec.license = "Apache-2.0"
25
26
 
26
27
  spec.files = `git ls-files`.split($/)
27
28
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
@@ -33,8 +34,8 @@ Gem::Specification.new do |spec|
33
34
  spec.add_development_dependency "rake", "~> 10.0"
34
35
  spec.add_development_dependency "test-unit-rr", "~> 1.0"
35
36
 
36
- spec.add_dependency "fluentd", ">= 0.10.53", "< 0.13"
37
+ spec.add_dependency "fluentd", [">= 0.14.15", "< 2"]
37
38
  spec.add_dependency "aws-sdk-core", ">= 2.0.12", "< 3.0"
38
- spec.add_dependency "msgpack", ">= 0.5.8"
39
- spec.add_dependency "google-protobuf", ">= 3.0.0.alpha.4.0"
39
+ spec.add_dependency "msgpack", "~> 1.0"
40
+ spec.add_dependency "google-protobuf", "~> 3.0"
40
41
  end
@@ -18,6 +18,7 @@ require 'securerandom'
18
18
  require 'digest'
19
19
 
20
20
  require 'google/protobuf'
21
+ require 'fluent/plugin/output'
21
22
 
22
23
  Google::Protobuf::DescriptorPool.generated_pool.build do
23
24
  add_message "AggregatedRecord" do
@@ -43,12 +44,11 @@ Record = Google::Protobuf::DescriptorPool.generated_pool.lookup("Record").msgcla
43
44
 
44
45
 
45
46
  module FluentPluginKinesisAggregation
46
- class OutputFilter < Fluent::BufferedOutput
47
+ class OutputFilter < Fluent::Plugin::Output
47
48
 
48
- include Fluent::DetachMultiProcessMixin
49
- include Fluent::SetTimeKeyMixin
50
- include Fluent::SetTagKeyMixin
49
+ helpers :compat_parameters, :inject
51
50
 
51
+ DEFAULT_BUFFER_TYPE = "memory"
52
52
  NAME = 'kinesis-aggregation'
53
53
  PUT_RECORD_MAX_DATA_SIZE = 1024 * 1024
54
54
  # 200 is an arbitrary number more than the envelope overhead
@@ -81,26 +81,31 @@ module FluentPluginKinesisAggregation
81
81
 
82
82
  config_param :http_proxy, :string, default: nil
83
83
 
84
+ config_section :buffer do
85
+ config_set_default :@type, DEFAULT_BUFFER_TYPE
86
+ end
87
+
84
88
  def configure(conf)
89
+ compat_parameters_convert(conf, :buffer, :inject)
85
90
  super
86
91
 
87
- if @buffer.chunk_limit > FLUENTD_MAX_BUFFER_SIZE
92
+ if @buffer.chunk_limit_size > FLUENTD_MAX_BUFFER_SIZE
88
93
  raise Fluent::ConfigError, "Kinesis buffer_chunk_limit is set to more than the 1mb shard limit (i.e. you won't be able to write your chunks!"
89
94
  end
90
95
 
91
- if @buffer.chunk_limit > FLUENTD_MAX_BUFFER_SIZE / 3
96
+ if @buffer.chunk_limit_size > FLUENTD_MAX_BUFFER_SIZE / 3
92
97
  log.warn 'Kinesis buffer_chunk_limit is set at more than 1/3 of the per second shard limit (1mb). This is not good if you have many producers.'
93
98
  end
94
99
  end
95
100
 
96
101
  def start
97
- detach_multi_process do
98
- super
99
- load_client
100
- end
102
+ super
103
+ load_client
101
104
  end
102
105
 
103
106
  def format(tag, time, record)
107
+ record = inject_values_to_record(tag, time, record)
108
+
104
109
  return AggregatedRecord.encode(AggregatedRecord.new(
105
110
  records: [Record.new(
106
111
  partition_key_index: 1,
@@ -28,5 +28,7 @@ require 'test/unit/rr'
28
28
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
29
29
  $LOAD_PATH.unshift(File.dirname(__FILE__))
30
30
  require 'fluent/test'
31
+ require 'fluent/test/helpers'
32
+ require 'fluent/test/driver/output'
31
33
  require 'fluent/process'
32
34
  require 'fluent/plugin/out_kinesis-aggregation'
@@ -14,6 +14,8 @@
14
14
  require 'helper'
15
15
 
16
16
  class KinesisOutputTest < Test::Unit::TestCase
17
+ include Fluent::Test::Helpers
18
+
17
19
  def setup
18
20
  Fluent::Test.setup
19
21
  end
@@ -27,14 +29,14 @@ class KinesisOutputTest < Test::Unit::TestCase
27
29
  buffer_chunk_limit 100k
28
30
  ]
29
31
 
30
- def create_driver(conf = CONFIG, tag='test')
31
- Fluent::Test::BufferedOutputTestDriver
32
- .new(FluentPluginKinesisAggregation::OutputFilter, tag).configure(conf)
32
+ def create_driver(conf = CONFIG)
33
+ Fluent::Test::Driver::Output
34
+ .new(FluentPluginKinesisAggregation::OutputFilter).configure(conf)
33
35
  end
34
36
 
35
37
  def create_mock_client
36
38
  client = mock(Object.new)
37
- mock(Aws::Kinesis::Client).new(anything) { client }
39
+ stub(Aws::Kinesis::Client).new(anything) { client }
38
40
  return client
39
41
  end
40
42
 
@@ -104,7 +106,7 @@ class KinesisOutputTest < Test::Unit::TestCase
104
106
  end
105
107
 
106
108
  d = create_driver
107
- d.run
109
+ d.run(default_tag: "test")
108
110
  end
109
111
 
110
112
  def test_load_client_with_credentials
@@ -132,7 +134,7 @@ class KinesisOutputTest < Test::Unit::TestCase
132
134
  buffer_chunk_limit 100k
133
135
  EOS
134
136
 
135
- d.run
137
+ d.run(default_tag: "test")
136
138
  end
137
139
 
138
140
  def test_load_client_with_role_arn
@@ -160,7 +162,7 @@ class KinesisOutputTest < Test::Unit::TestCase
160
162
  fixed_partition_key test_partition_key
161
163
  buffer_chunk_limit 100k
162
164
  EOS
163
- d.run
165
+ d.run(default_tag: "test")
164
166
  end
165
167
 
166
168
  def test_emitting
@@ -169,18 +171,19 @@ class KinesisOutputTest < Test::Unit::TestCase
169
171
  data1 = {"a"=>1,"time"=>"2011-01-02T13:14:15Z","tag"=>"test"}
170
172
  data2 = {"a"=>2,"time"=>"2011-01-02T13:14:15Z","tag"=>"test"}
171
173
 
172
- time = Time.parse("2011-01-02 13:14:15 UTC").to_i
173
- d.emit(data1, time)
174
- d.emit(data2, time)
174
+ time = event_time("2011-01-02 13:14:15 UTC")
175
175
 
176
- client = create_mock_client
177
- client.put_record(
178
- stream_name: 'test_stream',
179
- data: "\xF3\x89\x9A\xC2\n\x01a\n\x12test_partition_key\x1A6\b\x01\x1A2{\"a\":1,\"time\":\"2011-01-02T13:14:15Z\",\"tag\":\"test\"}\x1A6\b\x01\x1A2{\"a\":2,\"time\":\"2011-01-02T13:14:15Z\",\"tag\":\"test\"}\xA2\x0E y\x8B\x02\xDF\xAE\xAB\x93\x1C;\xCB\xAD\x1Fx".b,
180
- partition_key: 'test_partition_key'
181
- ) { {} }
176
+ d.run(default_tag: "test") do
177
+ client = create_mock_client
178
+ stub.instance_of(Aws::Kinesis::Client).put_record(
179
+ stream_name: 'test_stream',
180
+ data: "\xF3\x89\x9A\xC2\n\x01a\n\x12test_partition_key\x1A6\b\x01\x1A2{\"a\":1,\"time\":\"2011-01-02T13:14:15Z\",\"tag\":\"test\"}\x1A6\b\x01\x1A2{\"a\":2,\"time\":\"2011-01-02T13:14:15Z\",\"tag\":\"test\"}\xA2\x0E y\x8B\x02\xDF\xAE\xAB\x93\x1C;\xCB\xAD\x1Fx".b,
181
+ partition_key: 'test_partition_key'
182
+ ) { {} }
182
183
 
183
- d.run
184
+ d.feed(time, data1)
185
+ d.feed(time, data2)
186
+ end
184
187
  end
185
188
 
186
189
  def test_multibyte
@@ -188,29 +191,32 @@ class KinesisOutputTest < Test::Unit::TestCase
188
191
 
189
192
  data1 = {"a"=>"\xE3\x82\xA4\xE3\x83\xB3\xE3\x82\xB9\xE3\x83\x88\xE3\x83\xBC\xE3\x83\xAB","time"=>"2011-01-02T13:14:15Z".b,"tag"=>"test"}
190
193
 
191
- time = Time.parse("2011-01-02 13:14:15 UTC").to_i
192
- d.emit(data1, time)
193
194
 
194
- client = create_mock_client
195
- client.put_record(
196
- stream_name: 'test_stream',
197
- data: "\xF3\x89\x9A\xC2\n\x01a\n\x12test_partition_key\x1AI\b\x01\x1AE{\"a\":\"\xE3\x82\xA4\xE3\x83\xB3\xE3\x82\xB9\xE3\x83\x88\xE3\x83\xBC\xE3\x83\xAB\",\"time\":\"2011-01-02T13:14:15Z\",\"tag\":\"test\"}_$\x9C\xF9v+pV:g7c\xE3\xF2$\xBA".b,
198
- partition_key: 'test_partition_key'
199
- ) { {} }
195
+ time = event_time("2011-01-02 13:14:15 UTC")
196
+ d.run(default_tag: "test") do
197
+ client = create_mock_client
198
+ stub.instance_of(Aws::Kinesis::Client).put_record(
199
+ stream_name: 'test_stream',
200
+ data: "\xF3\x89\x9A\xC2\n\x01a\n\x12test_partition_key\x1AI\b\x01\x1AE{\"a\":\"\xE3\x82\xA4\xE3\x83\xB3\xE3\x82\xB9\xE3\x83\x88\xE3\x83\xBC\xE3\x83\xAB\",\"time\":\"2011-01-02T13:14:15Z\",\"tag\":\"test\"}_$\x9C\xF9v+pV:g7c\xE3\xF2$\xBA".b,
201
+ partition_key: 'test_partition_key'
202
+ ) { {} }
200
203
 
201
- d.run
204
+ d.feed(time, data1)
205
+ end
202
206
  end
203
207
 
204
208
  def test_fail_on_bigchunk
205
209
  d = create_driver
206
210
 
207
- d.emit(
208
- {"msg" => "z" * 1024 * 1024},
209
- Time.parse("2011-01-02 13:14:15 UTC").to_i)
210
- client = dont_allow(Object.new)
211
- client.put_record
212
- mock(Aws::Kinesis::Client).new(anything) { client }
213
-
214
- d.run
211
+ assert_raise(Fluent::Plugin::Buffer::BufferChunkOverflowError) do
212
+ d.run(default_tag: "test") do
213
+ d.feed(
214
+ event_time("2011-01-02 13:14:15 UTC"),
215
+ {"msg" => "z" * 1024 * 1024})
216
+ client = dont_allow(Object.new)
217
+ client.put_record
218
+ mock(Aws::Kinesis::Client).new(anything) { client }
219
+ end
220
+ end
215
221
  end
216
222
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-kinesis-aggregation
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.3
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Atlassian
@@ -58,20 +58,20 @@ dependencies:
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: 0.10.53
61
+ version: 0.14.15
62
62
  - - "<"
63
63
  - !ruby/object:Gem::Version
64
- version: '0.13'
64
+ version: '2'
65
65
  type: :runtime
66
66
  prerelease: false
67
67
  version_requirements: !ruby/object:Gem::Requirement
68
68
  requirements:
69
69
  - - ">="
70
70
  - !ruby/object:Gem::Version
71
- version: 0.10.53
71
+ version: 0.14.15
72
72
  - - "<"
73
73
  - !ruby/object:Gem::Version
74
- version: '0.13'
74
+ version: '2'
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: aws-sdk-core
77
77
  requirement: !ruby/object:Gem::Requirement
@@ -96,32 +96,32 @@ dependencies:
96
96
  name: msgpack
97
97
  requirement: !ruby/object:Gem::Requirement
98
98
  requirements:
99
- - - ">="
99
+ - - "~>"
100
100
  - !ruby/object:Gem::Version
101
- version: 0.5.8
101
+ version: '1.0'
102
102
  type: :runtime
103
103
  prerelease: false
104
104
  version_requirements: !ruby/object:Gem::Requirement
105
105
  requirements:
106
- - - ">="
106
+ - - "~>"
107
107
  - !ruby/object:Gem::Version
108
- version: 0.5.8
108
+ version: '1.0'
109
109
  - !ruby/object:Gem::Dependency
110
110
  name: google-protobuf
111
111
  requirement: !ruby/object:Gem::Requirement
112
112
  requirements:
113
- - - ">="
113
+ - - "~>"
114
114
  - !ruby/object:Gem::Version
115
- version: 3.0.0.alpha.4.0
115
+ version: '3.0'
116
116
  type: :runtime
117
117
  prerelease: false
118
118
  version_requirements: !ruby/object:Gem::Requirement
119
119
  requirements:
120
- - - ">="
120
+ - - "~>"
121
121
  - !ruby/object:Gem::Version
122
- version: 3.0.0.alpha.4.0
122
+ version: '3.0'
123
123
  description:
124
- email:
124
+ email: jhaggerty@atlassian.com
125
125
  executables: []
126
126
  extensions: []
127
127
  extra_rdoc_files: []
@@ -142,7 +142,7 @@ files:
142
142
  - test/plugin/test_out_kinesis-aggregation.rb
143
143
  homepage: https://github.com/atlassian/fluent-plugin-kinesis-aggregation
144
144
  licenses:
145
- - Apache License, Version 2.0
145
+ - Apache-2.0
146
146
  metadata: {}
147
147
  post_install_message:
148
148
  rdoc_options: []