logstash-codec-fluent 3.4.1-java → 3.4.2-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
  SHA256:
3
- metadata.gz: fa2fd8d949aa00ed210e7715803b3bf20c3574a63dd6d7c4c962bb566652d756
4
- data.tar.gz: b14c9124fab77dc4c808f5af0ff291e79a5fd362cefccdcae19c7e1ad488e24e
3
+ metadata.gz: 24e4641948b23a723d4822aacde3922e21b5b89f5158f1fcfe4293e7cf205de0
4
+ data.tar.gz: 1a7ce136c2bdda235b35d4f562744909406e9d1cc8ab610a83f07a5adb973c6f
5
5
  SHA512:
6
- metadata.gz: d6314b384f04df293ba102eeabe9a0c500b1f0258e680a6157c09d907b5d98ac6006ce808f73d8044045d5a1553309600ca4cb973dee188a766e85075be84b6c
7
- data.tar.gz: b015062ffe93575ab9b176f2d06ea6cdf9bdb6cdb7408aaa79a4be5cec2ae08e57065e99f809c2ac3e8ef80cc0ac557172561a197fd9f59f001296663d1ff852
6
+ metadata.gz: 194d5afb6af9b32bfa02c81227222a0417ee2afcb01bf7f6551372fcc36dd968fb6a642b02f960a2f84eb010457812926fa06a2505738bc396c97021c8a24d7a
7
+ data.tar.gz: ca8b9aba97f93d56bb4aedc3d3e568f30b77ffc7ef03da7b368b59c531fd56c89def9dd45778e7ae2f331937fab4364e3b60bd79f777121275106b0a6a5303c4
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 3.4.2
2
+ - Fix: Convert LogStash::Timestamp values to iso-8601 to resolve crash issue with `msgpack` serialization [#30](https://github.com/logstash-plugins/logstash-codec-fluent/pull/30)
3
+
1
4
  ## 3.4.1
2
5
  - Fix: handle multiple PackForward-encoded messages in a single payload [#28](https://github.com/logstash-plugins/logstash-codec-fluent/pull/28)
3
6
 
@@ -75,10 +75,9 @@ class LogStash::Codecs::Fluent < LogStash::Codecs::Base
75
75
  # use normalize to make sure returned Hash is pure Ruby for
76
76
  # MessagePack#pack which relies on pure Ruby object recognition
77
77
  data = LogStash::Util.normalize(event.to_hash)
78
- # timestamp is serialized as a iso8601 string
79
- # merge to avoid modifying data which could have side effects if multiple outputs
78
+
80
79
  @packer.clear
81
- @on_event.call(event, @packer.pack([tag, epochtime, data.merge(LogStash::Event::TIMESTAMP => event.timestamp.to_iso8601)]))
80
+ @on_event.call(event, @packer.pack([tag, epochtime, normalize_timestamps(data)]))
82
81
  end # def encode
83
82
 
84
83
  def forwardable_tag(event)
@@ -145,4 +144,20 @@ class LogStash::Codecs::Fluent < LogStash::Codecs::Base
145
144
  event
146
145
  end
147
146
 
147
+ ## Serializes timestamp as a iso8601 string, otherwise fluentd complains when packing the data
148
+ # @param object any type of data such as Hash, Array, etc...
149
+ # @return same shape of input with iso8061 serialized timestamps
150
+ def normalize_timestamps(object)
151
+ case object
152
+ when Hash
153
+ object.inject({}){|result, (key, value)| result[key] = normalize_timestamps(value); result}
154
+ when Array
155
+ object.map{|element| normalize_timestamps(element)}
156
+ when LogStash::Timestamp
157
+ object.to_iso8601
158
+ else
159
+ object
160
+ end
161
+ end
162
+
148
163
  end # class LogStash::Codecs::Fluent
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-codec-fluent'
4
- s.version = '3.4.1'
4
+ s.version = '3.4.2'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "Reads the `fluentd` `msgpack` schema"
7
7
  s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
@@ -47,6 +47,28 @@ describe LogStash::Codecs::Fluent do
47
47
 
48
48
  end
49
49
 
50
+ describe "when encoding timestamps" do
51
+ let(:properties) { {:name => "foo", :custom_time => Time.now(), :time => { :custom_time => Time.now() }, :custom_times => [Time.now(), Time.now(), "2023-03-28"] } }
52
+
53
+ it "converts to iso8601 and encodes without issue" do
54
+ subject.on_event do |event, data|
55
+ @unpacker.feed_each(data) do |fields|
56
+ expect(fields[0]).to eq("log")
57
+ expect(fields[2]["name"]).to eq("foo")
58
+ expect(fields[2]["custom_time"]).not_to be_nil
59
+ expect(fields[2]["custom_time"].class).to eql(String) # iso8601 string
60
+ expect(fields[2]["time"]).not_to be_nil
61
+ expect(fields[2]["time"]["custom_time"]).not_to be_nil
62
+ expect(fields[2]["time"]["custom_time"].class).to eql(String)
63
+ expect(fields[2]["custom_times"]).not_to be_nil
64
+ expect(fields[2]["custom_times"][0].class).to eql(String)
65
+ expect(fields[2]["custom_times"][2]).to eql("2023-03-28")
66
+ end
67
+ end
68
+ subject.encode(event)
69
+ end
70
+ end
71
+
50
72
  describe "event encoding with EventTime" do
51
73
 
52
74
  let(:config) { super().merge "nanosecond_precision" => true }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-codec-fluent
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.1
4
+ version: 3.4.2
5
5
  platform: java
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-22 00:00:00.000000000 Z
11
+ date: 2023-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement