logstash-codec-fluent 3.4.1-java → 3.4.3-java

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
  SHA256:
3
- metadata.gz: fa2fd8d949aa00ed210e7715803b3bf20c3574a63dd6d7c4c962bb566652d756
4
- data.tar.gz: b14c9124fab77dc4c808f5af0ff291e79a5fd362cefccdcae19c7e1ad488e24e
3
+ metadata.gz: 5cda92410b315daf405815fab12044bf29951b972f4173b8976854375a63e322
4
+ data.tar.gz: 3b3dc8fe1d69d82a10306ca4bb8c35b6ee613a6d4c19d670c5d839dc6609cdd6
5
5
  SHA512:
6
- metadata.gz: d6314b384f04df293ba102eeabe9a0c500b1f0258e680a6157c09d907b5d98ac6006ce808f73d8044045d5a1553309600ca4cb973dee188a766e85075be84b6c
7
- data.tar.gz: b015062ffe93575ab9b176f2d06ea6cdf9bdb6cdb7408aaa79a4be5cec2ae08e57065e99f809c2ac3e8ef80cc0ac557172561a197fd9f59f001296663d1ff852
6
+ metadata.gz: 1af628264fba7316ef61c68ff0b0ff6ddf6136c2613f4720a80d1e2c43d772d86c281a9dae49a508c135834b14aa9654673f488d856d82c93ef72e2ed717a970
7
+ data.tar.gz: e8126519435802ec52cc3f39142621d7cff4c01993f7214639c9cc4bcd07c9565244db38e705a204fb7fd747fa14597a400847ceecceb9928c78a79346fb176d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 3.4.3
2
+ - Fix: reduce overhead of unpacking packforward-payloads by reusing a single instance [#32](https://github.com/logstash-plugins/logstash-codec-fluent/pull/32)
3
+
4
+ ## 3.4.2
5
+ - 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)
6
+
1
7
  ## 3.4.1
2
8
  - Fix: handle multiple PackForward-encoded messages in a single payload [#28](https://github.com/logstash-plugins/logstash-codec-fluent/pull/28)
3
9
 
@@ -54,6 +54,7 @@ class LogStash::Codecs::Fluent < LogStash::Codecs::Base
54
54
  end
55
55
  @packer = @factory.packer
56
56
  @decoder = @factory.unpacker
57
+ @packforward_decoder = nil
57
58
  end
58
59
 
59
60
  def decode(data, &block)
@@ -75,10 +76,9 @@ class LogStash::Codecs::Fluent < LogStash::Codecs::Base
75
76
  # use normalize to make sure returned Hash is pure Ruby for
76
77
  # MessagePack#pack which relies on pure Ruby object recognition
77
78
  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
79
+
80
80
  @packer.clear
81
- @on_event.call(event, @packer.pack([tag, epochtime, data.merge(LogStash::Event::TIMESTAMP => event.timestamp.to_iso8601)]))
81
+ @on_event.call(event, @packer.pack([tag, epochtime, normalize_timestamps(data)]))
82
82
  end # def encode
83
83
 
84
84
  def forwardable_tag(event)
@@ -117,7 +117,7 @@ class LogStash::Codecs::Fluent < LogStash::Codecs::Base
117
117
  raise(LogStash::Error, "PackedForward with compression is not supported")
118
118
  end
119
119
 
120
- entries_decoder = @factory.unpacker
120
+ entries_decoder = (@packforward_decoder ||= @factory.unpacker).tap(&:reset)
121
121
  entries_decoder.feed_each(entries) do |entry|
122
122
  yield generate_event(entry[1], entry[0], tag)
123
123
  end
@@ -145,4 +145,20 @@ class LogStash::Codecs::Fluent < LogStash::Codecs::Base
145
145
  event
146
146
  end
147
147
 
148
+ ## Serializes timestamp as a iso8601 string, otherwise fluentd complains when packing the data
149
+ # @param object any type of data such as Hash, Array, etc...
150
+ # @return same shape of input with iso8061 serialized timestamps
151
+ def normalize_timestamps(object)
152
+ case object
153
+ when Hash
154
+ object.inject({}){|result, (key, value)| result[key] = normalize_timestamps(value); result}
155
+ when Array
156
+ object.map{|element| normalize_timestamps(element)}
157
+ when LogStash::Timestamp
158
+ object.to_iso8601
159
+ else
160
+ object
161
+ end
162
+ end
163
+
148
164
  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.3'
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.3
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: 2024-06-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -20,8 +20,8 @@ dependencies:
20
20
  - !ruby/object:Gem::Version
21
21
  version: '2.99'
22
22
  name: logstash-core-plugin-api
23
- prerelease: false
24
23
  type: :runtime
24
+ prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
@@ -37,8 +37,8 @@ dependencies:
37
37
  - !ruby/object:Gem::Version
38
38
  version: '1.0'
39
39
  name: logstash-mixin-event_support
40
- prerelease: false
41
40
  type: :runtime
41
+ prerelease: false
42
42
  version_requirements: !ruby/object:Gem::Requirement
43
43
  requirements:
44
44
  - - "~>"
@@ -51,8 +51,8 @@ dependencies:
51
51
  - !ruby/object:Gem::Version
52
52
  version: '1.0'
53
53
  name: logstash-mixin-validator_support
54
- prerelease: false
55
54
  type: :runtime
55
+ prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
58
  - - "~>"
@@ -65,8 +65,8 @@ dependencies:
65
65
  - !ruby/object:Gem::Version
66
66
  version: '1.1'
67
67
  name: msgpack
68
- prerelease: false
69
68
  type: :runtime
69
+ prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
@@ -79,8 +79,8 @@ dependencies:
79
79
  - !ruby/object:Gem::Version
80
80
  version: 1.0.0
81
81
  name: logstash-devutils
82
- prerelease: false
83
82
  type: :development
83
+ prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - ">="
@@ -127,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
127
  - !ruby/object:Gem::Version
128
128
  version: '0'
129
129
  requirements: []
130
- rubygems_version: 3.1.6
130
+ rubygems_version: 3.3.26
131
131
  signing_key:
132
132
  specification_version: 4
133
133
  summary: Reads the `fluentd` `msgpack` schema