fluent-plugin-kinesis 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.3.5
4
+
5
+ - **1MB record size limit**: Increased record size limit from 50KB to 1MB due to [Amazon Kinesis improvement.](http://aws.amazon.com/jp/about-aws/whats-new/2015/06/amazon-kinesis-announces-put-pricing-change-1mb-record-support-and-the-kinesis-producer-library/)
6
+ - **Switching IAM user support**: Added support for [shared credential file](http://docs.aws.amazon.com/ja_jp/AWSSdkDocsRuby/latest/DeveloperGuide/prog-basics-creds.html#creds-specify-provider).
7
+
3
8
  ## 0.3.4
4
9
 
5
10
  - **Multi-byte UTF-8 support**: We now support multi-byte UTF-8 by using *use_yajl* option.
@@ -28,7 +28,7 @@ module FluentPluginKinesis
28
28
  USER_AGENT_NAME = 'fluent-plugin-kinesis-output-filter'
29
29
  PROC_BASE_STR = 'proc {|record| %s }'
30
30
  PUT_RECORDS_MAX_COUNT = 500
31
- PUT_RECORD_MAX_DATA_SIZE = 1024 * 50
31
+ PUT_RECORD_MAX_DATA_SIZE = 1024 * 1024
32
32
  PUT_RECORDS_MAX_DATA_SIZE = 1024 * 1024 * 5
33
33
 
34
34
  Fluent::Plugin.register_output('kinesis',self)
@@ -42,6 +42,9 @@ module FluentPluginKinesis
42
42
  # it may be set as an environment variable.
43
43
  config_param :region, :string, default: nil
44
44
 
45
+ config_param :profile, :string, :default => nil
46
+ config_param :credentials_path, :string, :default => nil
47
+
45
48
  config_param :stream_name, :string
46
49
  config_param :random_partition_key, :bool, default: false
47
50
  config_param :partition_key, :string, default: nil
@@ -119,7 +122,7 @@ module FluentPluginKinesis
119
122
  unless record_exceeds_max_size?(record['data'])
120
123
  true
121
124
  else
122
- log.error sprintf('Record exceeds the 50KB per-record size limit and will not be delivered: %s', record['data'])
125
+ log.error sprintf('Record exceeds the %.3f KB(s) per-record size limit and will not be delivered: %s', PUT_RECORD_MAX_DATA_SIZE / 1024.0, record['data'])
123
126
  false
124
127
  end
125
128
  }.map{|record|
@@ -160,6 +163,11 @@ module FluentPluginKinesis
160
163
  access_key_id: @aws_key_id,
161
164
  secret_access_key: @aws_sec_key,
162
165
  )
166
+ elsif @profile
167
+ credentials_opts = {:profile_name => @profile}
168
+ credentials_opts[:path] = @credentials_path if @credentials_path
169
+ credentials = Aws::SharedCredentials.new(credentials_opts)
170
+ options[:credentials] = credentials
163
171
  end
164
172
 
165
173
  if @debug
@@ -226,15 +234,16 @@ module FluentPluginKinesis
226
234
  records_payload_length = 0
227
235
  data_list.each{|data_to_put|
228
236
  payload = data_to_put[:data]
229
- if records.length >= PUT_RECORDS_MAX_COUNT or (records_payload_length + payload.length) >= PUT_RECORDS_MAX_DATA_SIZE
237
+ partition_key = data_to_put[:partition_key]
238
+ if records.length >= PUT_RECORDS_MAX_COUNT or (records_payload_length + payload.length + partition_key.length) >= PUT_RECORDS_MAX_DATA_SIZE
230
239
  records_array.push(records)
231
240
  records = []
232
241
  records_payload_length = 0
233
242
  end
234
243
  records.push(data_to_put)
235
- records_payload_length += payload.length
244
+ records_payload_length += (payload.length + partition_key.length)
236
245
  }
237
- records_array.push(records)
246
+ records_array.push(records) unless records.empty?
238
247
  records_array
239
248
  end
240
249
 
@@ -12,5 +12,5 @@
12
12
  # language governing permissions and limitations under the License.
13
13
 
14
14
  module FluentPluginKinesis
15
- VERSION = '0.3.4'
15
+ VERSION = '0.3.5'
16
16
  end
@@ -50,6 +50,66 @@ class KinesisOutputTest < Test::Unit::TestCase
50
50
  assert_equal 'test_partition_key', d.instance.partition_key
51
51
  end
52
52
 
53
+ def test_configure_with_credentials
54
+ d = create_driver(<<-EOS)
55
+ profile default
56
+ credentials_path /home/scott/.aws/credentials
57
+ stream_name test_stream
58
+ region us-east-1
59
+ partition_key test_partition_key
60
+ EOS
61
+
62
+ assert_equal 'default', d.instance.profile
63
+ assert_equal '/home/scott/.aws/credentials', d.instance.credentials_path
64
+ assert_equal 'test_stream', d.instance.stream_name
65
+ assert_equal 'us-east-1', d.instance.region
66
+ assert_equal 'test_partition_key', d.instance.partition_key
67
+ end
68
+
69
+ def test_load_client
70
+ client = stub(Object.new)
71
+ client.describe_stream
72
+ client.put_records { {} }
73
+
74
+ stub(Aws::Kinesis::Client).new do |options|
75
+ assert_equal("test_key_id", options[:access_key_id])
76
+ assert_equal("test_sec_key", options[:secret_access_key])
77
+ assert_equal("us-east-1", options[:region])
78
+ client
79
+ end
80
+
81
+ d = create_driver
82
+ d.run
83
+ end
84
+
85
+ def test_load_client_with_credentials
86
+ client = stub(Object.new)
87
+ client.describe_stream
88
+ client.put_records { {} }
89
+
90
+ stub(Aws::Kinesis::Client).new do |options|
91
+ assert_equal(nil, options[:access_key_id])
92
+ assert_equal(nil, options[:secret_access_key])
93
+ assert_equal("us-east-1", options[:region])
94
+
95
+ credentials = options[:credentials]
96
+ assert_equal("default", credentials.profile_name)
97
+ assert_equal("/home/scott/.aws/credentials", credentials.path)
98
+
99
+ client
100
+ end
101
+
102
+ d = create_driver(<<-EOS)
103
+ profile default
104
+ credentials_path /home/scott/.aws/credentials
105
+ stream_name test_stream
106
+ region us-east-1
107
+ partition_key test_partition_key
108
+ EOS
109
+
110
+ d.run
111
+ end
112
+
53
113
  def test_configure_with_more_options
54
114
 
55
115
  conf = %[
@@ -351,75 +411,99 @@ class KinesisOutputTest < Test::Unit::TestCase
351
411
 
352
412
  def test_record_exceeds_max_size
353
413
  d = create_driver
414
+
415
+ # PUT_RECORD_MAX_DATA_SIZE = 1024*1024 is way too big, try something smaller (10), just to verify the logic not the actual value
416
+ original_put_record_max_data_size = d.instance.class.send(:remove_const, :PUT_RECORD_MAX_DATA_SIZE) if d.instance.class.const_defined?(:PUT_RECORD_MAX_DATA_SIZE)
417
+ d.instance.class.const_set(:PUT_RECORD_MAX_DATA_SIZE, 10)
418
+
354
419
  string = ''
355
- (1..1024).each{ string = string + '1' }
420
+ (1..5).each{ string = string + '1' }
356
421
  assert_equal(
357
422
  false,
358
423
  d.instance.send(:record_exceeds_max_size?,string)
359
424
  )
360
425
 
361
426
  string = ''
362
- (1..(1024*50)).each{ string = string + '1' }
427
+ (1..10).each{ string = string + '1' }
363
428
  assert_equal(
364
429
  false,
365
430
  d.instance.send(:record_exceeds_max_size?,string)
366
431
  )
367
432
 
368
433
  string = ''
369
- (1..(1024*51)).each{ string = string + '1' }
434
+ (1..11).each{ string = string + '1' }
370
435
  assert_equal(
371
436
  true,
372
437
  d.instance.send(:record_exceeds_max_size?,string)
373
438
  )
439
+
440
+ # reset the constant
441
+ d.instance.class.const_set(:PUT_RECORD_MAX_DATA_SIZE, original_put_record_max_data_size)
374
442
  end
375
443
 
376
444
  def test_build_records_array_to_put
377
445
  d = create_driver
378
446
 
447
+ # PUT_RECORDS_MAX_DATA_SIZE = 1024*1024*5 is way too big, try something smaller (100), just to verify the logic not the actual value
448
+ original_put_records_max_data_size = d.instance.class.send(:remove_const, :PUT_RECORDS_MAX_DATA_SIZE) if d.instance.class.const_defined?(:PUT_RECORDS_MAX_DATA_SIZE)
449
+ d.instance.class.const_set(:PUT_RECORDS_MAX_DATA_SIZE, 100)
450
+
451
+ # PUT_RECORDS_MAX_COUNT = 500 is way too big, try something smaller (10), just to verify the logic not the actual value
452
+ original_put_records_max_count = d.instance.class.send(:remove_const, :PUT_RECORDS_MAX_COUNT) if d.instance.class.const_defined?(:PUT_RECORDS_MAX_COUNT)
453
+ d.instance.class.const_set(:PUT_RECORDS_MAX_COUNT, 10)
454
+
379
455
  data_list = []
380
- (0..500).each do |n|
381
- data_list.push({data: n.to_s})
456
+ (0..10).each do |n|
457
+ data_list.push({data: '1', partition_key: '0'})
382
458
  end
383
459
  result = d.instance.send(:build_records_array_to_put,data_list)
384
460
  assert_equal(2,result.length)
385
- assert_equal(500,result[0].length)
461
+ assert_equal(10,result[0].length)
386
462
  assert_equal(1,result[1].length)
387
463
 
388
464
  data_list = []
389
- (0..1400).each do
390
- data_list.push({data: '1'})
465
+ (0..24).each do
466
+ data_list.push({data: '1', partition_key: '0'})
391
467
  end
392
468
  result = d.instance.send(:build_records_array_to_put,data_list)
393
469
  assert_equal(3,result.length)
394
- assert_equal(500,result[0].length)
395
- assert_equal(500,result[1].length)
396
- assert_equal(401,result[2].length)
470
+ assert_equal(10,result[0].length)
471
+ assert_equal(10,result[1].length)
472
+ assert_equal(5,result[2].length)
397
473
 
398
474
  data_list = []
399
- data_string = ''
400
- (0..(1024*30)).each do
401
- data_string = data_string + '1'
402
- end
403
- (0..500).each do
404
- data_list.push({data: data_string})
475
+ (0..20).each do
476
+ data_list.push({data: '0123456789', partition_key: '1'})
405
477
  end
478
+ # Should return 3 lists: 9*11 + 9*11 + 3*11
406
479
  result = d.instance.send(:build_records_array_to_put,data_list)
407
480
  assert_equal(3,result.length)
408
- assert_equal(170,result[0].length)
481
+ assert_equal(9,result[0].length)
409
482
  assert_operator(
410
- 1024 * 1024 *5, :>,
411
- result[0].reduce(0){|sum,i| sum + i[:data].length}
483
+ 100, :>,
484
+ result[0].reduce(0){|sum,i| sum + i[:data].length + i[:partition_key].length}
412
485
  )
413
- assert_equal(170,result[1].length)
486
+ assert_equal(9,result[1].length)
414
487
  assert_operator(
415
- 1024 * 1024 *5, :>,
416
- result[1].reduce(0){|sum,i| sum + i[:data].length}
488
+ 100, :>,
489
+ result[1].reduce(0){|sum,i| sum + i[:data].length + i[:partition_key].length}
417
490
  )
418
- assert_equal(161,result[2].length)
491
+ assert_equal(3,result[2].length)
419
492
  assert_operator(
420
- 1024 * 1024 *5, :>,
421
- result[2].reduce(0){|sum,i| sum + i[:data].length}
493
+ 100, :>,
494
+ result[2].reduce(0){|sum,i| sum + i[:data].length + i[:partition_key].length}
422
495
  )
496
+
497
+ # reset the constants
498
+ d.instance.class.const_set(:PUT_RECORDS_MAX_DATA_SIZE, original_put_records_max_data_size)
499
+ d.instance.class.const_set(:PUT_RECORDS_MAX_COUNT, original_put_records_max_count)
500
+ end
501
+
502
+ def test_build_empty_array_to_put
503
+ d = create_driver
504
+ data_list = []
505
+ result = d.instance.send(:build_records_array_to_put,data_list)
506
+ assert_equal(0, result.length, 'Should return empty array if there is no record')
423
507
  end
424
508
 
425
509
  def test_build_data_to_put
metadata CHANGED
@@ -1,18 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-kinesis
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Amazon Web Services
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2015-07-06 00:00:00.000000000 Z
12
+ date: 2015-08-03 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: bundler
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
19
  - - ~>
18
20
  - !ruby/object:Gem::Version
@@ -20,6 +22,7 @@ dependencies:
20
22
  type: :development
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
27
  - - ~>
25
28
  - !ruby/object:Gem::Version
@@ -27,6 +30,7 @@ dependencies:
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: rake
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
35
  - - ~>
32
36
  - !ruby/object:Gem::Version
@@ -34,6 +38,7 @@ dependencies:
34
38
  type: :development
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
43
  - - ~>
39
44
  - !ruby/object:Gem::Version
@@ -41,6 +46,7 @@ dependencies:
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: test-unit-rr
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
51
  - - ~>
46
52
  - !ruby/object:Gem::Version
@@ -48,6 +54,7 @@ dependencies:
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
59
  - - ~>
53
60
  - !ruby/object:Gem::Version
@@ -55,8 +62,9 @@ dependencies:
55
62
  - !ruby/object:Gem::Dependency
56
63
  name: fluentd
57
64
  requirement: !ruby/object:Gem::Requirement
65
+ none: false
58
66
  requirements:
59
- - - '>='
67
+ - - ! '>='
60
68
  - !ruby/object:Gem::Version
61
69
  version: 0.10.53
62
70
  - - <
@@ -65,8 +73,9 @@ dependencies:
65
73
  type: :runtime
66
74
  prerelease: false
67
75
  version_requirements: !ruby/object:Gem::Requirement
76
+ none: false
68
77
  requirements:
69
- - - '>='
78
+ - - ! '>='
70
79
  - !ruby/object:Gem::Version
71
80
  version: 0.10.53
72
81
  - - <
@@ -75,8 +84,9 @@ dependencies:
75
84
  - !ruby/object:Gem::Dependency
76
85
  name: aws-sdk-core
77
86
  requirement: !ruby/object:Gem::Requirement
87
+ none: false
78
88
  requirements:
79
- - - '>='
89
+ - - ! '>='
80
90
  - !ruby/object:Gem::Version
81
91
  version: 2.0.12
82
92
  - - <
@@ -85,8 +95,9 @@ dependencies:
85
95
  type: :runtime
86
96
  prerelease: false
87
97
  version_requirements: !ruby/object:Gem::Requirement
98
+ none: false
88
99
  requirements:
89
- - - '>='
100
+ - - ! '>='
90
101
  - !ruby/object:Gem::Version
91
102
  version: 2.0.12
92
103
  - - <
@@ -95,6 +106,7 @@ dependencies:
95
106
  - !ruby/object:Gem::Dependency
96
107
  name: multi_json
97
108
  requirement: !ruby/object:Gem::Requirement
109
+ none: false
98
110
  requirements:
99
111
  - - ~>
100
112
  - !ruby/object:Gem::Version
@@ -102,6 +114,7 @@ dependencies:
102
114
  type: :runtime
103
115
  prerelease: false
104
116
  version_requirements: !ruby/object:Gem::Requirement
117
+ none: false
105
118
  requirements:
106
119
  - - ~>
107
120
  - !ruby/object:Gem::Version
@@ -109,15 +122,17 @@ dependencies:
109
122
  - !ruby/object:Gem::Dependency
110
123
  name: msgpack
111
124
  requirement: !ruby/object:Gem::Requirement
125
+ none: false
112
126
  requirements:
113
- - - '>='
127
+ - - ! '>='
114
128
  - !ruby/object:Gem::Version
115
129
  version: 0.5.8
116
130
  type: :runtime
117
131
  prerelease: false
118
132
  version_requirements: !ruby/object:Gem::Requirement
133
+ none: false
119
134
  requirements:
120
- - - '>='
135
+ - - ! '>='
121
136
  - !ruby/object:Gem::Version
122
137
  version: 0.5.8
123
138
  description:
@@ -143,26 +158,27 @@ files:
143
158
  homepage: https://github.com/awslabs/aws-fluent-plugin-kinesis
144
159
  licenses:
145
160
  - Apache License, Version 2.0
146
- metadata: {}
147
161
  post_install_message:
148
162
  rdoc_options: []
149
163
  require_paths:
150
164
  - lib
151
165
  required_ruby_version: !ruby/object:Gem::Requirement
166
+ none: false
152
167
  requirements:
153
- - - '>='
168
+ - - ! '>='
154
169
  - !ruby/object:Gem::Version
155
170
  version: 1.9.3
156
171
  required_rubygems_version: !ruby/object:Gem::Requirement
172
+ none: false
157
173
  requirements:
158
- - - '>='
174
+ - - ! '>='
159
175
  - !ruby/object:Gem::Version
160
176
  version: '0'
161
177
  requirements: []
162
178
  rubyforge_project:
163
- rubygems_version: 2.0.14
179
+ rubygems_version: 1.8.23
164
180
  signing_key:
165
- specification_version: 4
181
+ specification_version: 3
166
182
  summary: Fluentd output plugin that sends events to Amazon Kinesis.
167
183
  test_files:
168
184
  - test/helper.rb
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 1afe44290b2075c66e362e31b6ad9239b8b8a4f1
4
- data.tar.gz: 8317862b2882294c24efd9d1e1d3434e37a82ba6
5
- SHA512:
6
- metadata.gz: d3ed7132f9ab1022c75de1eef2732858adf4cacfeb607b4a7543e3989ce6541d14b601521062eedd966bd49f52a3f8d5812505e1fedcae6fd098c29ec863f35e
7
- data.tar.gz: 890a373bdb0c9752026fc52120b444b7eb84dbf3abc116ea4d8d78816cb0dcf8f5f35c83ca888ab295dc251a4599e1d2f9681f7ee892c0ccf93be761409a893c