fluent-logger 0.6.2 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ChangeLog +4 -0
- data/VERSION +1 -1
- data/lib/fluent/logger/fluent_logger.rb +10 -2
- data/lib/fluent/logger/version.rb +1 -1
- data/spec/fluent_logger_spec.rb +8 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cb70f375d56167d4fa69310f24457f9697947fa9
|
4
|
+
data.tar.gz: 25ceec5e3dd80f84368cb28bc0f092d7dbd0766f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 571ef4468e47a4917e6525719594baa7f478f1a2d4b676b5d669a04f9b344bf86cc3edee7d4da1b21d9e2cdd357c4bd829ce03616761efa62ab322e2e52ef054
|
7
|
+
data.tar.gz: 803ed86c13a44b1b823b2d70ed0d2e60eae9c2e388a9d414751b8301ac6603a218254cad5ebc1c49d4febe410b5c6378d5a18797ca6a8f74bfdd0db502b5870b
|
data/ChangeLog
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.6.
|
1
|
+
0.6.3
|
@@ -135,6 +135,14 @@ module Fluent
|
|
135
135
|
@socket_path ? "#{@socket_path}" : "#{@host}:#{@port}"
|
136
136
|
end
|
137
137
|
|
138
|
+
def pending_bytesize
|
139
|
+
if @pending
|
140
|
+
@pending.bytesize
|
141
|
+
else
|
142
|
+
0
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
138
146
|
private
|
139
147
|
|
140
148
|
def to_msgpack(msg)
|
@@ -170,7 +178,7 @@ module Fluent
|
|
170
178
|
end
|
171
179
|
|
172
180
|
# suppress reconnection burst
|
173
|
-
if !@connect_error_history.empty? &&
|
181
|
+
if !@connect_error_history.empty? && pending_bytesize <= @limit
|
174
182
|
if Time.now.to_i - @connect_error_history.last < suppress_sec
|
175
183
|
return false
|
176
184
|
end
|
@@ -182,7 +190,7 @@ module Fluent
|
|
182
190
|
true
|
183
191
|
rescue => e
|
184
192
|
set_last_error(e)
|
185
|
-
if
|
193
|
+
if pending_bytesize > @limit
|
186
194
|
@logger.error("FluentLogger: Can't send logs to #{connection_string}: #{$!}")
|
187
195
|
call_buffer_overflow_handler(@pending)
|
188
196
|
@pending = nil
|
data/spec/fluent_logger_spec.rb
CHANGED
@@ -58,9 +58,11 @@ describe Fluent::Logger::FluentLogger do
|
|
58
58
|
|
59
59
|
context('post') do
|
60
60
|
it ('success') {
|
61
|
+
expect(logger.pending_bytesize).to eq 0
|
61
62
|
expect(logger.post('tag', {'a' => 'b'})).to be true
|
62
63
|
fluentd.wait_transfer
|
63
64
|
expect(fluentd.queue.last).to eq ['logger-test.tag', {'a' => 'b'}]
|
65
|
+
expect(logger.pending_bytesize).to eq 0
|
64
66
|
}
|
65
67
|
|
66
68
|
it ('close after post') {
|
@@ -72,6 +74,7 @@ describe Fluent::Logger::FluentLogger do
|
|
72
74
|
expect(logger).to be_connect
|
73
75
|
fluentd.wait_transfer
|
74
76
|
expect(fluentd.queue.last).to eq ['logger-test.tag', {'b' => 'c'}]
|
77
|
+
expect(logger.pending_bytesize).to eq 0
|
75
78
|
}
|
76
79
|
|
77
80
|
it ('large data') {
|
@@ -150,9 +153,11 @@ describe Fluent::Logger::FluentLogger do
|
|
150
153
|
context "not running fluentd" do
|
151
154
|
context('fluent logger interface') do
|
152
155
|
it ('post & close') {
|
156
|
+
expect(logger.pending_bytesize).to eq 0
|
153
157
|
expect(logger.post('tag', {'a' => 'b'})).to be false
|
154
158
|
fluentd.wait_transfer # even if wait
|
155
159
|
expect(fluentd.queue.last).to be_nil
|
160
|
+
expect(logger.pending_bytesize).to be > 0
|
156
161
|
logger.close
|
157
162
|
logger_io.rewind
|
158
163
|
log = logger_io.read
|
@@ -204,11 +209,13 @@ describe Fluent::Logger::FluentLogger do
|
|
204
209
|
let(:buffer_overflow_handler) { Proc.new { |messages| handler.flush(messages) } }
|
205
210
|
|
206
211
|
it ('post limit over') do
|
212
|
+
expect(logger.pending_bytesize).to eq 0
|
207
213
|
logger.limit = 100
|
208
214
|
event_1 = {'a' => 'b'}
|
209
215
|
logger.post('tag', event_1)
|
210
216
|
fluentd.wait_transfer # even if wait
|
211
217
|
expect(fluentd.queue.last).to be(nil)
|
218
|
+
expect(logger.pending_bytesize).to be > 0
|
212
219
|
|
213
220
|
logger_io.rewind
|
214
221
|
expect(logger_io.read).not_to match(/Can't send logs to/)
|
@@ -216,6 +223,7 @@ describe Fluent::Logger::FluentLogger do
|
|
216
223
|
event_2 = {'a' => ('c' * 1000)}
|
217
224
|
logger.post('tag', event_2)
|
218
225
|
logger_io.rewind
|
226
|
+
expect(logger.pending_bytesize).to eq 0
|
219
227
|
expect(logger_io.read).to match(/Can't send logs to/)
|
220
228
|
|
221
229
|
buffer = handler.buffer
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sadayuki Furuhashi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: msgpack
|