logstash-codec-avro 3.0.0-java → 3.1.0-java

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 82c13044b81979f3dcc59afc6e0b12c84bc399a8
4
- data.tar.gz: a63d24090bac54031cd9b4190ffb6eae7c3d951d
3
+ metadata.gz: 800d769a22f692329606bfe7b30fef7b22894038
4
+ data.tar.gz: 62f39efb3bcaf5074dd81d1b657f08a6ec857664
5
5
  SHA512:
6
- metadata.gz: 6f48ad5d631470cad389df4f431c841ba6ddf7f54692b19db13257ee2fe76d6e903875f31dc6d11b127b1571f06d2f2a14011396d9245b10c3b17f8820886851
7
- data.tar.gz: fb08fb0bd4c7996840871e4d9b4592d7dc42e2fb65c229a768b67fe87a99e3ac39c041f58bcecc0fb682c8e72161421cf24725fda99e3492bd619c4f995128eb
6
+ metadata.gz: 2a17a7e2514b3f8b97f019ff6bf0f5a8b6b68b19c41e6c5f95b324a79eb3ff72374276d37fde76f2a3f5c58384cf5466de73bd4c0d570f228a00c3d6d96ebbaa
7
+ data.tar.gz: 07cef39e0789d1638f9f55f5edf1e290358f445ce878642cd00bea65d54638baadf54c743f9e7721028d9dfbb0b03baf8e7180b1ac07f4c452255e6edca38607
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 3.1.0
2
+ - Introduce `tag_on_failure` option to tag events with `_avroparsefailure` instead of throwing an exception when decoding
3
+
1
4
  ## 3.0.0
2
5
  - breaking: Update to new Event API
3
6
 
@@ -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
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-codec-avro'
4
- s.version = '3.0.0'
4
+ s.version = '3.1.0'
5
5
  s.platform = 'java'
6
6
  s.licenses = ['Apache-2.0']
7
7
  s.summary = "Encode and decode avro formatted data"
@@ -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.0.0
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: 2016-09-08 00:00:00.000000000 Z
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