logstash-output-dynatrace 0.7.0 → 0.7.1

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: 4db961537a03cb5b21240ab63ea56877ceebcf0a075c5db85feb736b787d05df
4
- data.tar.gz: 185005382c4ac576fde60eeffa8d3f1a5e037445b3dd92b2126be22f0a3481dc
3
+ metadata.gz: 81b4a8c2170a81fb234ff285214b21e531d8b33a304ccbe25b643a10d05a7c28
4
+ data.tar.gz: 70e9196d107abd6655ea8394fac223713bd8120c5305c5f22075d402f897d65d
5
5
  SHA512:
6
- metadata.gz: 0b14e9eba2edf866eff03c2fa7333ec23733bb6622dd841fcc3da9ddf5cfe5e5b1104238a2857cadc7474bc49444773ee0b5ae7cabcbbaddbefd28e4da403bb8
7
- data.tar.gz: 334f37197001b662b86c451c1dcb1faa059f94d1d4045ad43e66590f08663e7a90ea5979bbe247d3d2d7774a0f0e386d6f97c33663e6bef70c0dc6b909557ce3
6
+ metadata.gz: 6c67bc08595859467e6c32da87b60e0da67e99f3df4eb8b59d1ecedd8b96676429fe908b4e0678ea4f74736445fab3880a25461d439ef8fef3ce6100b9bc7ada
7
+ data.tar.gz: c0c78831f7436a02ae3faafab913a725af81d9bf8a14111b7de5d4e46bac3b473f22b325ef27280f5bb4262279a86dadf6ec2b19250b89819e90b7e7f5b8c32b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.7.1
2
+
3
+ - Fix an error where max payload size was calculated using character count instead of bytes
4
+
1
5
  ## 0.7.0
2
6
 
3
7
  - Add new development dependency `rackup` for logstash 8.x compatibility
@@ -122,11 +122,11 @@ module LogStash
122
122
 
123
123
  def offer(serialized_event)
124
124
  # 2 square brackets, the length of all previously serialized strings, commas, and the current event size
125
- batch_size_bytes = 2 + @batch_events_size + @serialized_events.length + serialized_event.length
125
+ batch_size_bytes = 2 + @batch_events_size + @serialized_events.length + serialized_event.bytesize
126
126
  return false if batch_size_bytes > @max_batch_size
127
127
 
128
128
  @serialized_events.push(serialized_event)
129
- @batch_events_size += serialized_event.length
129
+ @batch_events_size += serialized_event.bytesize
130
130
  true
131
131
  end
132
132
 
@@ -178,8 +178,8 @@ module LogStash
178
178
 
179
179
  events.each do |event|
180
180
  serialized_event = LogStash::Json.dump(event.to_hash)
181
- if serialized_event.length > @max_payload_size
182
- log_params = { size: serialized_event.length }
181
+ if serialized_event.bytesize > @max_payload_size
182
+ log_params = { size: serialized_event.bytesize }
183
183
  log_params[:body] = serialized_event if @debug_include_body
184
184
  log_warning('Event larger than max_payload_size dropped', log_params)
185
185
  next
@@ -232,17 +232,38 @@ describe LogStash::Outputs::Dynatrace do
232
232
  end
233
233
  end
234
234
 
235
- context 'max_payload_size 2MB' do
236
- let(:config) { { 'ingest_endpoint_url' => ingest_endpoint_url, 'api_key' => api_key, 'max_payload_size' => 2_000_000 } }
235
+ context 'max_payload_size 500' do
236
+ let(:max_payload_size) { 500 }
237
+ let(:config) { { 'ingest_endpoint_url' => ingest_endpoint_url, 'api_key' => api_key, 'max_payload_size' => max_payload_size } }
237
238
  subject { LogStash::Outputs::Dynatrace.new(config) }
238
239
 
239
240
  before do
240
241
  allow(subject).to receive(:send_event) { |e, att| [:success, e, att] }
241
- subject.multi_receive([1, 2].map { |n| LogStash::Event.new({ 'n' => n.to_s * 1_250_000 }) })
242
242
  end
243
243
 
244
- it 'should split the chunk into multiple requests' do
245
- expect(subject).to have_received(:send_event).exactly(2).times
244
+ it 'should send 2 400B messages in multiple requests' do
245
+ subject.multi_receive([1, 2].map { |n| LogStash::Event.new({ 'n' => n.to_s * 400 }) })
246
+ expect(subject).to have_received(:send_event).exactly(2).times do |s|
247
+ expect(s.bytesize).to be <= max_payload_size
248
+ end
249
+ end
250
+
251
+ it 'should send 2 100B messages in a single request' do
252
+ subject.multi_receive([1, 2].map { |n| LogStash::Event.new({ 'n' => n.to_s * 100 }) })
253
+ expect(subject).to have_received(:send_event).exactly(1).times do |s|
254
+ expect(s.bytesize).to be <= max_payload_size
255
+ end
256
+ end
257
+
258
+ it 'should drop messages larger than max_payload_size' do
259
+ subject.multi_receive([
260
+ LogStash::Event.new({ 'event' => '🤣' * 400 }),
261
+ LogStash::Event.new({ 'event' => 'n' * 600 }),
262
+ LogStash::Event.new({ 'event' => 'n' * 400 }),
263
+ ])
264
+ expect(subject).to have_received(:send_event).exactly(1).times do |s|
265
+ expect(s.bytesize).to be <= max_payload_size
266
+ end
246
267
  end
247
268
  end
248
269
 
data/version.yaml CHANGED
@@ -1 +1 @@
1
- logstash-output-dynatrace: '0.7.0'
1
+ logstash-output-dynatrace: '0.7.1'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-dynatrace
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dynatrace Open Source Engineering
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-01-08 00:00:00.000000000 Z
11
+ date: 2025-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logstash-codec-json