fluent-plugin-scalyr 0.8.14 → 0.8.15
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 +4 -4
- data/VERSION +1 -1
- data/lib/fluent/plugin/out_scalyr.rb +34 -6
- data/test/test_events.rb +44 -0
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b707a6d76dc806731c45f6a96915936e559c49c79e873c3c5ea5dce4ffbaf288
|
|
4
|
+
data.tar.gz: a328a42722469673e69d9e7a77e84c65cb1f7235a566076a1316216937a54405
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fad3abf458ae0f215f7a29ca3aa4cc167d05811e270c3eace46057ce291307f3b76ef8c13c269b8c43b4564909001e2421dd6ef591188e52c6ed44c22a5ef946
|
|
7
|
+
data.tar.gz: b8a3268ce7d4d71178ea3356ba47ffd9247cbe3c55d49d436916868076710c4f66719266235d926e314b936bed5544a92de6afdad93a0b33be5d4d0fe0d473cb
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.8.
|
|
1
|
+
0.8.15
|
|
@@ -358,13 +358,37 @@ module Scalyr
|
|
|
358
358
|
# generate new request if json size of events in the array exceed maximum request buffer size
|
|
359
359
|
append_event = true
|
|
360
360
|
if total_bytes + event_json.bytesize > @max_request_buffer
|
|
361
|
-
#
|
|
361
|
+
# the case where a single event causes us to exceed the @max_request_buffer
|
|
362
362
|
if events.empty?
|
|
363
|
-
|
|
363
|
+
# if we are able to truncate the content (and append an ellipsis)
|
|
364
|
+
# inside the @message_field we do so here
|
|
365
|
+
if record.key?(@message_field) &&
|
|
366
|
+
record[@message_field].is_a?(String) &&
|
|
367
|
+
record[@message_field].bytesize > event_json.bytesize - @max_request_buffer &&
|
|
368
|
+
record[@message_field].bytesize >= 3
|
|
369
|
+
|
|
370
|
+
@log.warn "Received a record that cannot fit within max_request_buffer "\
|
|
371
|
+
"(#{@max_request_buffer}) from #{record['logfile']}, serialized event size "\
|
|
372
|
+
"is #{event_json.bytesize}. The #{@message_field} field will be truncated to fit."
|
|
373
|
+
max_msg_size = @max_request_buffer - event_json.bytesize - 3
|
|
374
|
+
truncated_msg = event[:attrs][@message_field][0...max_msg_size] + "..."
|
|
375
|
+
event[:attrs][@message_field] = truncated_msg
|
|
376
|
+
events << event
|
|
377
|
+
|
|
378
|
+
# otherwise we drop the event and save ourselves hitting a 4XX response from the server
|
|
379
|
+
else
|
|
380
|
+
@log.warn "Received a record that cannot fit within max_request_buffer "\
|
|
381
|
+
"(#{@max_request_buffer}) from #{record['logfile']}, serialized event size "\
|
|
382
|
+
"is #{event_json.bytesize}. The #{@message_field} field too short to truncate, "\
|
|
383
|
+
"dropping event."
|
|
384
|
+
end
|
|
364
385
|
append_event = false
|
|
365
386
|
end
|
|
366
|
-
|
|
367
|
-
|
|
387
|
+
|
|
388
|
+
unless events.empty?
|
|
389
|
+
request = create_request(events, current_threads)
|
|
390
|
+
requests << request
|
|
391
|
+
end
|
|
368
392
|
|
|
369
393
|
total_bytes = 0
|
|
370
394
|
current_threads = {}
|
|
@@ -380,8 +404,12 @@ module Scalyr
|
|
|
380
404
|
}
|
|
381
405
|
|
|
382
406
|
# create a final request with any left over events
|
|
383
|
-
|
|
384
|
-
|
|
407
|
+
unless events.empty?
|
|
408
|
+
request = create_request(events, current_threads)
|
|
409
|
+
requests << request
|
|
410
|
+
end
|
|
411
|
+
|
|
412
|
+
requests
|
|
385
413
|
end
|
|
386
414
|
|
|
387
415
|
def create_request(events, current_threads)
|
data/test/test_events.rb
CHANGED
|
@@ -357,4 +357,48 @@ class EventsTest < Scalyr::ScalyrOutTest
|
|
|
357
357
|
d.feed(time, attrs)
|
|
358
358
|
end
|
|
359
359
|
end
|
|
360
|
+
|
|
361
|
+
def test_truncated_large_event
|
|
362
|
+
d = create_driver CONFIG + "max_request_buffer 4000"
|
|
363
|
+
|
|
364
|
+
time = event_time("2015-04-01 10:00:00 UTC")
|
|
365
|
+
attrs = {"log" => "this is a test", "message" => "0123456789" * 500}
|
|
366
|
+
|
|
367
|
+
response = flexmock(Net::HTTPResponse, code: "200", body: '{ "status":"success" }')
|
|
368
|
+
mock = flexmock(d.instance)
|
|
369
|
+
|
|
370
|
+
mock.should_receive(:post_request).with(
|
|
371
|
+
URI,
|
|
372
|
+
on {|request_body|
|
|
373
|
+
body = JSON.parse(request_body)
|
|
374
|
+
events = body["events"]
|
|
375
|
+
assert(events[0]["attrs"].key?("message"), "'message' field not found in event")
|
|
376
|
+
assert_equal(
|
|
377
|
+
"0123456789" * 388 + "012...",
|
|
378
|
+
events[0]["attrs"]["message"],
|
|
379
|
+
"'message' field incorrect"
|
|
380
|
+
)
|
|
381
|
+
true
|
|
382
|
+
}
|
|
383
|
+
).once.and_return(response)
|
|
384
|
+
|
|
385
|
+
d.run(default_tag: "test") do
|
|
386
|
+
d.feed(time, attrs)
|
|
387
|
+
end
|
|
388
|
+
end
|
|
389
|
+
|
|
390
|
+
def test_dropped_large_event
|
|
391
|
+
d = create_driver CONFIG + "max_request_buffer 4000"
|
|
392
|
+
|
|
393
|
+
time = event_time("2015-04-01 10:00:00 UTC")
|
|
394
|
+
attrs = {"message" => "this is a test", "not_message" => "0123456789" * 500}
|
|
395
|
+
|
|
396
|
+
mock = flexmock(d.instance)
|
|
397
|
+
|
|
398
|
+
mock.should_receive(:post_request).never
|
|
399
|
+
|
|
400
|
+
d.run(default_tag: "test") do
|
|
401
|
+
d.feed(time, attrs)
|
|
402
|
+
end
|
|
403
|
+
end
|
|
360
404
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fluent-plugin-scalyr
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.8.
|
|
4
|
+
version: 0.8.15
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Imron Alston
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2022-02-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: ffi
|