fluent-plugin-cloudwatch-logs 0.2.2 → 0.2.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5082b725cf548ffea0fb7e779c6c24a4d7bb7909
|
4
|
+
data.tar.gz: 6a8dbc8986550ec45e9fb3518316f19d7267ac8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f8321eeaa7a481dae684a5908446782a5ba570b1bcc9bbeec86a63d4a365340923a4478536a471a4480aa32b6017a537c5023ee87dd5d0144d62cab252f0c6fd
|
7
|
+
data.tar.gz: c57ab7ca6be0756ad4377b3b7cf12cc69b6f4e141b82c5c5cc664fe493fe22f705758c5e3c4be2d00fcec55d98c892c8c325c3f17b453acd899b7ccf266b01cb
|
@@ -25,6 +25,7 @@ module Fluent
|
|
25
25
|
config_param :http_proxy, :string, default: nil
|
26
26
|
|
27
27
|
MAX_EVENTS_SIZE = 1_048_576
|
28
|
+
EVENT_HEADER_SIZE = 26
|
28
29
|
|
29
30
|
unless method_defined?(:log)
|
30
31
|
define_method(:log) { $log }
|
@@ -158,25 +159,30 @@ module Fluent
|
|
158
159
|
|
159
160
|
# The maximum batch size is 1,048,576 bytes, and this size is calculated as the sum of all event messages in UTF-8, plus 26 bytes for each log event.
|
160
161
|
# http://docs.aws.amazon.com/AmazonCloudWatchLogs/latest/APIReference/API_PutLogEvents.html
|
162
|
+
total_bytesize = 0
|
161
163
|
while event = events.shift
|
162
164
|
new_chunk = chunk + [event]
|
165
|
+
event_bytesize = event[:message].bytesize + EVENT_HEADER_SIZE
|
166
|
+
|
163
167
|
chunk_span_too_big = new_chunk.size > 1 && new_chunk[-1][:timestamp] - new_chunk[0][:timestamp] >= 1000 * 60 * 60 * 24
|
164
|
-
chunk_too_big =
|
168
|
+
chunk_too_big = total_bytesize + event_bytesize > MAX_EVENTS_SIZE
|
165
169
|
chunk_too_long = @max_events_per_batch && chunk.size >= @max_events_per_batch
|
166
170
|
if chunk_too_big or chunk_span_too_big or chunk_too_long
|
167
|
-
put_events(group_name, stream_name, chunk)
|
171
|
+
put_events(group_name, stream_name, chunk, total_bytesize)
|
168
172
|
chunk = [event]
|
173
|
+
total_bytesize = event_bytesize
|
169
174
|
else
|
170
175
|
chunk << event
|
176
|
+
total_bytesize += event_bytesize
|
171
177
|
end
|
172
178
|
end
|
173
179
|
|
174
180
|
unless chunk.empty?
|
175
|
-
put_events(group_name, stream_name, chunk)
|
181
|
+
put_events(group_name, stream_name, chunk, total_bytesize)
|
176
182
|
end
|
177
183
|
end
|
178
184
|
|
179
|
-
def put_events(group_name, stream_name, events)
|
185
|
+
def put_events(group_name, stream_name, events, events_bytesize)
|
180
186
|
args = {
|
181
187
|
log_events: events,
|
182
188
|
log_group_name: group_name,
|
@@ -185,6 +191,13 @@ module Fluent
|
|
185
191
|
token = next_sequence_token(group_name, stream_name)
|
186
192
|
args[:sequence_token] = token if token
|
187
193
|
|
194
|
+
log.debug "Calling PutLogEvents API", {
|
195
|
+
"group" => group_name,
|
196
|
+
"stream" => stream_name,
|
197
|
+
"events_count" => events.size,
|
198
|
+
"events_bytesize" => events_bytesize,
|
199
|
+
}
|
200
|
+
|
188
201
|
response = @logs.put_log_events(args)
|
189
202
|
store_next_sequence_token(group_name, stream_name, response.next_sequence_token)
|
190
203
|
end
|
@@ -51,6 +51,8 @@ class CloudwatchLogsOutputTest < Test::Unit::TestCase
|
|
51
51
|
assert_equal('{"cloudwatch":"logs1"}', events[0].message)
|
52
52
|
assert_equal((time.to_i + 1) * 1000, events[1].timestamp)
|
53
53
|
assert_equal('{"cloudwatch":"logs2"}', events[1].message)
|
54
|
+
|
55
|
+
assert_match(/Calling PutLogEvents API/, d.instance.log.logs[0])
|
54
56
|
end
|
55
57
|
|
56
58
|
def test_write_utf8
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-cloudwatch-logs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryota Arai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|