fluent-plugin-td 0.10.23 → 0.10.24

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: bea1cedfa710605a41e6621d3c1a5e735d30d41b
4
- data.tar.gz: e674f3cc8a8f4ea2901b8232266bfe7cbbada432
3
+ metadata.gz: 46404732e76417f2f5110a8f97a219935c3c653c
4
+ data.tar.gz: ae4a4ba457f7c7bd5097fa37a9cc955bd02914bd
5
5
  SHA512:
6
- metadata.gz: 256e1e8db03e0e8271a55e4d138d40d0c2af9f94cd9712d357625fd62bc87becbad890ec01ec649a90cd0390e103275a426a1b853e1d40c1fd5637ae88ab9f58
7
- data.tar.gz: 02fb8daa4050de87b6ca2f2e7d87d5c732e9c75040c3588e893bd93255ae509dfa2fb48ed9850479c549b4ef55e85c8aa139d228a8237c7d06003145c69204c7
6
+ metadata.gz: e9812f2997140c7470641d82666ec59ec4bae779fb435f24fca1a821e0bdcb67184a0151b93e92cd130045b1223a352e96fe4d553e2017a3ea787e963f91c1b6
7
+ data.tar.gz: e332f546b28efe2446b7d820fe1f1fd9e74dd32bf2661c80640677b963fa194acba041e3597b22ef38fd91c4b14e2e0811f0d280c498fd64c0dd860cd512dc60
data/ChangeLog CHANGED
@@ -1,3 +1,10 @@
1
+ Release 0.10.24 - 2015/02/05
2
+
3
+ * Change log level and message when a broken record is skipped to make it clear that it is skipped
4
+ * Skip non-hash record because plugin can't recover such situation
5
+ * Use MessagePack::Buffer to improve the performance with msgpack v0.5
6
+
7
+
1
8
  Release 0.10.23 - 2014/12/08
2
9
 
3
10
  * Relax fluentd version restriction
@@ -183,9 +183,12 @@ module Fluent
183
183
  end
184
184
 
185
185
  def format_stream(tag, es)
186
- out = ''
187
- off = out.bytesize
186
+ out = $use_msgpack_5 ? MessagePack::Buffer.new : ''.force_encoding('ASCII-8BIT') # this condition will be removed after removed msgpack v0.4 support
187
+ off = out.size # size is same as bytesize in ASCII-8BIT string
188
188
  es.each { |time, record|
189
+ # Applications may send non-hash record or broken chunk may generate non-hash record so such records should be skipped
190
+ next unless record.is_a?(Hash)
191
+
189
192
  begin
190
193
  if @anonymizes
191
194
  @anonymizes.each_pair { |key, scr|
@@ -205,8 +208,8 @@ module Fluent
205
208
  # TODO (a) Remove the transaction mechanism of fluentd
206
209
  # or (b) keep transaction boundaries in in/out_forward.
207
210
  # This code disables the transaction mechanism (a).
208
- log.error "#{e}: #{summarize_record(record)}"
209
- log.error_backtrace e.backtrace
211
+ log.warn "Skipped a broken record (#{e}): #{summarize_record(record)}"
212
+ log.warn_backtrace e.backtrace
210
213
  next
211
214
  end
212
215
 
@@ -216,7 +219,7 @@ module Fluent
216
219
  TreasureData::API.normalized_msgpack(record, out)
217
220
  end
218
221
 
219
- noff = out.bytesize
222
+ noff = out.size
220
223
  sz = noff - off
221
224
  if sz > @record_size_limit
222
225
  # TODO don't raise error
@@ -225,7 +228,7 @@ module Fluent
225
228
  end
226
229
  off = noff
227
230
  }
228
- out
231
+ out.to_s
229
232
  end
230
233
 
231
234
  def summarize_record(record)
@@ -1,5 +1,5 @@
1
1
  module Fluent
2
2
  module TreasureDataPlugin
3
- VERSION = '0.10.23'
3
+ VERSION = '0.10.24'
4
4
  end
5
5
  end
@@ -56,6 +56,25 @@ class TreasureDataLogOutputTest < Test::Unit::TestCase
56
56
  assert_equal('TD1 testkey', @auth_header)
57
57
  end
58
58
 
59
+ def test_emit_with_broken_record
60
+ d = create_driver
61
+ time, records = stub_seed_values
62
+ records[1] = nil
63
+ records << 'string' # non-hash case
64
+ database, table = d.instance.instance_variable_get(:@key).split(".", 2)
65
+ stub_td_table_create_request(database, table)
66
+ stub_td_import_request(stub_request_body(records, time), database, table)
67
+
68
+ records.each { |record|
69
+ d.emit(record, time)
70
+ }
71
+ d.run
72
+
73
+ assert !d.instance.log.logs.any? { |line|
74
+ line =~ /undefined method/
75
+ }, 'nil record should be skipped'
76
+ end
77
+
59
78
  def test_emit_with_time_symbole
60
79
  d = create_driver
61
80
  time, records = stub_seed_values
@@ -99,7 +118,7 @@ class TreasureDataLogOutputTest < Test::Unit::TestCase
99
118
 
100
119
  assert_equal 0, d.emits.size
101
120
  assert d.instance.log.logs.select{ |line|
102
- line =~ / \[error\]: Too many number of keys/
121
+ line =~ /Too many number of keys/
103
122
  }.size == 1, "too many keys error is not logged"
104
123
  end
105
124
 
data/test/test_helper.rb CHANGED
@@ -27,6 +27,8 @@ class Test::Unit::TestCase
27
27
  def stub_request_body(records, time = nil)
28
28
  out = ''
29
29
  records.each { |record|
30
+ next unless record.is_a?(Hash)
31
+
30
32
  r = record.dup
31
33
  if time
32
34
  r['time'] = time
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-td
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.23
4
+ version: 0.10.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Treasure Data, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-08 00:00:00.000000000 Z
11
+ date: 2015-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd