logstash-codec-avro 3.0.0-java → 3.1.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/logstash/codecs/avro.rb +10 -0
- data/logstash-codec-avro.gemspec +1 -1
- data/spec/codecs/avro_spec.rb +15 -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: 800d769a22f692329606bfe7b30fef7b22894038
|
4
|
+
data.tar.gz: 62f39efb3bcaf5074dd81d1b657f08a6ec857664
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a17a7e2514b3f8b97f019ff6bf0f5a8b6b68b19c41e6c5f95b324a79eb3ff72374276d37fde76f2a3f5c58384cf5466de73bd4c0d570f228a00c3d6d96ebbaa
|
7
|
+
data.tar.gz: 07cef39e0789d1638f9f55f5edf1e290358f445ce878642cd00bea65d54638baadf54c743f9e7721028d9dfbb0b03baf8e7180b1ac07f4c452255e6edca38607
|
data/CHANGELOG.md
CHANGED
data/lib/logstash/codecs/avro.rb
CHANGED
@@ -56,6 +56,9 @@ class LogStash::Codecs::Avro < LogStash::Codecs::Base
|
|
56
56
|
# * file - `/path/to/schema.avsc`
|
57
57
|
config :schema_uri, :validate => :string, :required => true
|
58
58
|
|
59
|
+
# tag events with `_avroparsefailure` when decode fails
|
60
|
+
config :tag_on_failure, :validate => :boolean, :default => false
|
61
|
+
|
59
62
|
def open_and_read(uri_string)
|
60
63
|
open(uri_string).read
|
61
64
|
end
|
@@ -71,6 +74,13 @@ class LogStash::Codecs::Avro < LogStash::Codecs::Base
|
|
71
74
|
decoder = Avro::IO::BinaryDecoder.new(datum)
|
72
75
|
datum_reader = Avro::IO::DatumReader.new(@schema)
|
73
76
|
yield LogStash::Event.new(datum_reader.read(decoder))
|
77
|
+
rescue => e
|
78
|
+
if tag_on_failure
|
79
|
+
@logger.error("Avro parse error, original data now in message field", :error => e)
|
80
|
+
yield LogStash::Event.new("message" => data, "tags" => ["_avroparsefailure"])
|
81
|
+
else
|
82
|
+
raise e
|
83
|
+
end
|
74
84
|
end
|
75
85
|
|
76
86
|
public
|
data/logstash-codec-avro.gemspec
CHANGED
data/spec/codecs/avro_spec.rb
CHANGED
@@ -31,6 +31,21 @@ describe LogStash::Codecs::Avro do
|
|
31
31
|
insist { event.get("bar") } == test_event.get("bar")
|
32
32
|
end
|
33
33
|
end
|
34
|
+
|
35
|
+
it "should throw exception if decoding fails" do
|
36
|
+
expect { subject.decode("not avro") { |_| } }.to raise_error NoMethodError
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context "#decode with tag_on_failure" do
|
41
|
+
let (:avro_config) { super.merge("tag_on_failure" => true) }
|
42
|
+
|
43
|
+
it "should tag event on failure" do
|
44
|
+
subject.decode("not avro") do |event|
|
45
|
+
insist { event.is_a? LogStash::Event }
|
46
|
+
insist { event.get("tags") } == ["_avroparsefailure"]
|
47
|
+
end
|
48
|
+
end
|
34
49
|
end
|
35
50
|
|
36
51
|
context "#encode" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-codec-avro
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.0
|
5
5
|
platform: java
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-02-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|