fluent-plugin-record-reformer 0.8.2 → 0.8.3

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: abcb8c05a4359b363c8a1a0f0cf75a16df123c03
4
- data.tar.gz: 55d88baf42ee056e4de0f181fae316fcefc451ac
3
+ metadata.gz: dc59bc6bee21df0c85068cc0e3eef1ccfbb9c9a0
4
+ data.tar.gz: 88548f35221803b464118e7920893ce59f633139
5
5
  SHA512:
6
- metadata.gz: de246d926ea5785af76414cc7d8d60acde19cc552d8a81e988ca91a290f0ce41c77482a29d18ef99f9953097b958a6ec695ad7db7d8276e8721063bc6716fd72
7
- data.tar.gz: d905845078c70d674b33098b4269fd62ba76d32a3fb3ef9e1bcc9758138b359e7d08c15313f1a4b7d12abbf09bcdb9ce4eec516837f6ff977fd4b372052f339f
6
+ metadata.gz: 165159b501d607dde4a932fa8e1e39248b21b4d01f50c87581bd4857a7af529484158140a28088a5717e4358cfd9e1064674c083b5080b56d8f188591889a2fe
7
+ data.tar.gz: a5b0ad5603625ba7350f336e9a7fe8bbc63f91081bcf834f59fcb99dc7cc6de8bb04d38bfc24f581a86c3a18b0e0c22450b70f4d944709ed0fc4fd334797dcdd
@@ -1,3 +1,9 @@
1
+ ## 0.8.3 (2017/01/26)
2
+
3
+ Fixes
4
+
5
+ * Apply `remove_keys` last, otherwise, `renew_time_key` could be removed before generating new time
6
+
1
7
  ## 0.8.2 (2016/08/21)
2
8
 
3
9
  Fixes
@@ -3,7 +3,7 @@ $:.push File.expand_path('../lib', __FILE__)
3
3
 
4
4
  Gem::Specification.new do |gem|
5
5
  gem.name = "fluent-plugin-record-reformer"
6
- gem.version = "0.8.2"
6
+ gem.version = "0.8.3"
7
7
  gem.authors = ["Naotoshi Seo"]
8
8
  gem.email = "sonots@gmail.com"
9
9
  gem.homepage = "https://github.com/sonots/fluent-plugin-record-reformer"
@@ -116,6 +116,7 @@ module Fluent
116
116
  if @renew_time_key && new_record.has_key?(@renew_time_key)
117
117
  time = new_record[@renew_time_key].to_i
118
118
  end
119
+ @remove_keys.each {|k| new_record.delete(k) } if @remove_keys
119
120
  router.emit(new_tag, time, new_record)
120
121
  end
121
122
  }
@@ -146,7 +147,6 @@ module Fluent
146
147
  new_record = @renew_record ? {} : record.dup
147
148
  @keep_keys.each {|k| new_record[k] = record[k]} if @keep_keys and @renew_record
148
149
  new_record.merge!(expand_placeholders(@map, placeholders))
149
- @remove_keys.each {|k| new_record.delete(k) } if @remove_keys
150
150
 
151
151
  [new_tag, new_record]
152
152
  end
@@ -209,7 +209,6 @@ module Fluent
209
209
 
210
210
  def prepare_placeholders(placeholder_values)
211
211
  placeholders = {}
212
- reserved_keys = Set.new(placeholder_values.keys)
213
212
 
214
213
  placeholder_values.each do |key, value|
215
214
  if value.kind_of?(Array) # tag_parts, etc
@@ -220,7 +219,7 @@ module Fluent
220
219
  end
221
220
  elsif value.kind_of?(Hash) # record, etc
222
221
  value.each do |k, v|
223
- unless reserved_keys.include?(k) # prevent overwriting the reserved keys such as tag
222
+ unless placeholder_values.has_key?(k) # prevent overwriting the reserved keys such as tag
224
223
  placeholders.store("${#{k}}", v)
225
224
  end
226
225
  placeholders.store(%Q[${#{key}["#{k}"]}], v) # record["foo"]
@@ -146,14 +146,37 @@ class RecordReformerOutputTest < Test::Unit::TestCase
146
146
  config = <<EOC
147
147
  tag reformed.${tag}
148
148
  enable_ruby true
149
- message ${Time.parse(message).to_i}
150
- renew_time_key message
149
+ renew_time_key event_time_key
150
+ <record>
151
+ event_time_key ${Time.parse(record["message"]).to_i}
152
+ </record>
151
153
  EOC
152
154
  msgs = times.map{|t| t.to_s }
153
155
  emits = emit(config, use_v1, msgs)
154
156
  emits.each_with_index do |(tag, time, record), i|
155
157
  assert_equal("reformed.#{@tag}", tag)
156
158
  assert_equal(times[i].to_i, time)
159
+ assert_true(record.has_key?('event_time_key'))
160
+ end
161
+ end
162
+
163
+ test 'renew_time_key and remove_keys' do
164
+ config = <<EOC
165
+ tag reformed.${tag}
166
+ renew_time_key event_time_key
167
+ remove_keys event_time_key
168
+ auto_typecast true
169
+ <record>
170
+ event_time_key ${Time.parse(record["message"]).to_i}
171
+ </record>
172
+ EOC
173
+ times = [ Time.local(2,2,3,4,5,2010,nil,nil,nil,nil), Time.local(3,2,3,4,5,2010,nil,nil,nil,nil) ]
174
+ msgs = times.map{|t| t.to_s }
175
+ emits = emit(config, use_v1, msgs)
176
+ emits.each_with_index do |(tag, time, record), i|
177
+ assert_equal("reformed.#{@tag}", tag)
178
+ assert_equal(times[i].to_i, time)
179
+ assert_false(record.has_key?('event_time_key'))
157
180
  end
158
181
  end
159
182
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-record-reformer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 0.8.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naotoshi Seo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-21 00:00:00.000000000 Z
11
+ date: 2017-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd