fluent-plugin-concat 0.4.1 → 0.5.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: ae4aa01995d47f27e2c79b6e117872d72995e061
4
- data.tar.gz: f846be7e55d2bd0029bc2b369fc0a546be8fca6e
3
+ metadata.gz: 6e0e8f69b86fd07cc91f4045b25ac65cb7355130
4
+ data.tar.gz: 3927ef6dd92afbe5807ce1dbf34c77a190e723b4
5
5
  SHA512:
6
- metadata.gz: da41f352fb2d1201c3ae2bc97593590abe11823dcb7c3b561f5d48126510f0c676d772f524ce44fd76d3075082968e7a6793bb2dc94714a83994a717c7466c0f
7
- data.tar.gz: 5cf5f9dc762eb74068836f83031dae8a29bbe923e023507830cacaab702cf0fd04a5033a9d97d9664d54b0de7b79cfc29595e701a19a0cc0f03595fab84f2d97
6
+ metadata.gz: 3f2e2eeaa5321ab37aaa86cc2974e1239121e84dd9c8fd4a80aa809ac0f9483307cacb50ff003b6ab749c21fc56ff6d00c0913367fd4294b2ff82f493609c4ee
7
+ data.tar.gz: c27abd17cef7c40df3cd09d63e8ca61a5d2d87a6d465cd5f4df50e5246b9c933a593a987fba967ecf51132098f5857fc8128bc7e026a03b96496d5fbb7463acb
data/README.md CHANGED
@@ -49,6 +49,10 @@ The regexp to match ending of multiline.
49
49
 
50
50
  The key to determine which stream an event belongs to.
51
51
 
52
+ **flush\_interval**
53
+
54
+ The number of seconds after which the last received event log will be flushed.
55
+
52
56
  ## Usage
53
57
 
54
58
  Every 10 events will be concatenated into one event.
@@ -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-concat"
7
- spec.version = "0.4.1"
7
+ spec.version = "0.5.0"
8
8
  spec.authors = ["Kenji Okimoto"]
9
9
  spec.email = ["okimoto@clear-code.com"]
10
10
 
@@ -16,6 +16,8 @@ module Fluent
16
16
  config_param :stream_identity_key, :string, default: nil
17
17
  desc "The interval between data flushes"
18
18
  config_param :flush_interval, :time, default: 60
19
+ desc "The label name to handle timeout"
20
+ config_param :timeout_label, :string, default: nil
19
21
 
20
22
  class TimeoutError < StandardError
21
23
  end
@@ -134,12 +136,13 @@ module Fluent
134
136
 
135
137
  def flush_buffer(stream_identity, new_element = nil)
136
138
  lines = @buffer[stream_identity].map {|_tag, _time, record| record[@key] }
139
+ _tag, _time, last_record = @buffer[stream_identity].last
137
140
  new_record = {
138
141
  @key => lines.join(@separator)
139
142
  }
140
143
  @buffer[stream_identity] = []
141
144
  @buffer[stream_identity] << new_element if new_element
142
- new_record
145
+ last_record.merge(new_record)
143
146
  end
144
147
 
145
148
  def flush_timeout_buffer
@@ -151,8 +154,8 @@ module Fluent
151
154
  timeout_stream_identities << stream_identity
152
155
  tag = stream_identity.split(":").first
153
156
  message = "Timeout flush: #{stream_identity}"
154
- router.emit_error_event(tag, now, flushed_record, TimeoutError.new(message))
155
- log.info message
157
+ handle_timeout_error(tag, now, flushed_record, message)
158
+ log.info(message)
156
159
  end
157
160
  @timeout_map.reject! do |stream_identity, _|
158
161
  timeout_stream_identities.include?(stream_identity)
@@ -169,11 +172,21 @@ module Fluent
169
172
  }
170
173
  tag, time, record = elements.last
171
174
  message = "Flush remaining buffer: #{stream_identity}"
172
- router.emit_error_event(tag, time, record.merge(new_record), TimeoutError.new(message))
175
+ handle_timeout_error(tag, time, record.merge(new_record), message)
176
+ log.info(message)
173
177
  end
174
178
  @buffer.clear
175
179
  end
176
180
 
181
+ def handle_timeout_error(tag, time, record, message)
182
+ if @timeout_label
183
+ label = Engine.root_agent.find_label(@timeout_label)
184
+ label.event_router.emit(tag, time, record)
185
+ else
186
+ router.emit_error_event(tag, time, record, TimeoutError.new(message))
187
+ end
188
+ end
189
+
177
190
  class TimeoutTimer < Coolio::TimerWatcher
178
191
  def initialize(interval, callback)
179
192
  super(interval, true)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-concat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenji Okimoto
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-06-06 00:00:00.000000000 Z
11
+ date: 2016-06-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd
@@ -139,7 +139,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
139
  version: '0'
140
140
  requirements: []
141
141
  rubyforge_project:
142
- rubygems_version: 2.6.4
142
+ rubygems_version: 2.5.1
143
143
  signing_key:
144
144
  specification_version: 4
145
145
  summary: Fluentd Filter plugin to concat multiple event messages