fluent-plugin-json_expander 0.0.1.pre → 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dd0e91d385a1c563f4eeda19098692538e510d20
4
- data.tar.gz: 1c35f48f84214ab5e9e1c3b872c7852b19631f80
3
+ metadata.gz: d583201256a49ab2c2ca48747f882c55aa3397fe
4
+ data.tar.gz: b91660f95dedaf77e44ba9b2490c0d245bc828f6
5
5
  SHA512:
6
- metadata.gz: 3b6fdbddb5dd1aaed2317c129fd1f1fa66c6cc66cfac2f8cf407fdd49e8ef04ceba667270f261026a7d8bc3dae574e7113a63a7dfc20bf7f2f7de7244f12b634
7
- data.tar.gz: dc05731acc6313db0faad2074543cd1036be1c56343dabfa60a14ec5c61ca484cd49a1d33deb7614eb5b8735f05d29cfea9e27504dccfaf564f445082f4018e4
6
+ metadata.gz: 69e2106ffe9668eadcc54f011cbfec61d250c6d4d1bccc280f9743ccf4b3e7eb20918616a87f24b35e806938bfc09b08e834c8208ea4bd2d25e2ecf4f3013546
7
+ data.tar.gz: 4137b0ec45ec23e2a9c39ca6e81c6808c1a91065091621c13de31145009539e5e9ee5ffd6bab85763449301f01a2cf02c6334404b2fd26b59b395e50827c22ff
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "fluent-plugin-json_expander"
7
- spec.version = "0.0.1.pre"
7
+ spec.version = "0.0.1"
8
8
  spec.authors = ["Uchio KONDO"]
9
9
  spec.email = ["udzura@udzura.jp"]
10
10
 
@@ -43,13 +43,13 @@ class Fluent::JsonExpanderOutput < Fluent::MultiOutput
43
43
  tag = tag[@removed_length..-1]
44
44
  end
45
45
  if @add_prefix
46
- tag = tag.empty? ? (@added_prefix_string + tag) : @add_prefix
46
+ tag = tag.empty? ? @add_prefix : (@added_prefix_string + tag)
47
47
  end
48
48
 
49
49
  es.each {|time, record|
50
- output = new_output(record)
50
+ output, new_record = *new_output(record)
51
51
  if output
52
- dup_es = Fluent::ArrayEventStream.new([[time, record]])
52
+ dup_es = Fluent::ArrayEventStream.new([[time, new_record]])
53
53
  null_chain = Fluent::NullOutputChain.instance
54
54
  output.emit(tag, dup_es, null_chain)
55
55
  end
@@ -64,7 +64,8 @@ class Fluent::JsonExpanderOutput < Fluent::MultiOutput
64
64
  t = @template
65
65
  begin
66
66
  @mutex.synchronize do
67
- if e = expand_elm(t, data)
67
+ e, data = expand_elm(t, data)
68
+ if e
68
69
  o = Fluent::Plugin.new_output(@subtype)
69
70
  o.configure(e)
70
71
  o.start
@@ -86,7 +87,7 @@ class Fluent::JsonExpanderOutput < Fluent::MultiOutput
86
87
  o = nil
87
88
  end
88
89
 
89
- return o
90
+ return o, data
90
91
  end
91
92
 
92
93
  SCAN_DATA_RE = /\$\{data\[(?:[_a-zA-Z][_a-zA-Z0-9]*)\]\}/
@@ -100,11 +101,11 @@ class Fluent::JsonExpanderOutput < Fluent::MultiOutput
100
101
  if !key_matched or !key_matched[0]
101
102
  raise(Fluent::ConfigError, "[BUG] data matched in template, but could not find key name")
102
103
  end
103
- if @handle_empty_as_error
104
- k = key_matched[0]
105
- data[k] || mark_errored(k, data)
104
+ target = key_matched[0]
105
+ if @delete_used_key
106
+ data.delete(target) || on_empty_data(target, data)
106
107
  else
107
- data[key_matched[0]] || ""
108
+ data[target] || on_empty_data(target, data)
108
109
  end
109
110
  end
110
111
  attr[k] = v
@@ -113,14 +114,17 @@ class Fluent::JsonExpanderOutput < Fluent::MultiOutput
113
114
  sub_elms = template.elements.map {|e| expand_elm(data) }
114
115
 
115
116
  if @mark_errored
116
- nil
117
+ return nil, nil
117
118
  else
118
- Fluent::Config::Element.new('instance', '', attr, sub_elms)
119
+ return Fluent::Config::Element.new('instance', '', attr, sub_elms), data
119
120
  end
120
121
  end
121
122
 
122
- def mark_errored(k, data)
123
- log.error "Could not find value for `#{k}' in data #{data.inspect}, Fluentd skips this"
124
- @mark_errored = true
123
+ def on_empty_data(k, data)
124
+ if @handle_empty_as_error
125
+ log.error "Could not find value for `#{k}' in data #{data.inspect}, Fluentd skips this"
126
+ @mark_errored = true
127
+ end
128
+ ""
125
129
  end
126
130
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-json_expander
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.pre
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Uchio KONDO
@@ -128,9 +128,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
128
128
  version: '0'
129
129
  required_rubygems_version: !ruby/object:Gem::Requirement
130
130
  requirements:
131
- - - ">"
131
+ - - ">="
132
132
  - !ruby/object:Gem::Version
133
- version: 1.3.1
133
+ version: '0'
134
134
  requirements: []
135
135
  rubyforge_project:
136
136
  rubygems_version: 2.2.3