logstash-output-dynatrace 0.7.1 → 0.8.0

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: 81b4a8c2170a81fb234ff285214b21e531d8b33a304ccbe25b643a10d05a7c28
4
- data.tar.gz: 70e9196d107abd6655ea8394fac223713bd8120c5305c5f22075d402f897d65d
3
+ metadata.gz: d6854ef3745f76258a310201110f0ad2c4eb584f5eaeb1a947b90bdaddcefd28
4
+ data.tar.gz: 8a9e2c1477a26137756bc7a1a2e0356d3ddc85f070553a7543db10c74f960dc1
5
5
  SHA512:
6
- metadata.gz: 6c67bc08595859467e6c32da87b60e0da67e99f3df4eb8b59d1ecedd8b96676429fe908b4e0678ea4f74736445fab3880a25461d439ef8fef3ce6100b9bc7ada
7
- data.tar.gz: c0c78831f7436a02ae3faafab913a725af81d9bf8a14111b7de5d4e46bac3b473f22b325ef27280f5bb4262279a86dadf6ec2b19250b89819e90b7e7f5b8c32b
6
+ metadata.gz: fb86589466be40fe1483c96bf4ec626272cfa1fbe11b7a6105d8a347af3a821ede7800f0c56d300272223d0ec862d60fb090ef5310c9fde29a0c908d9e73bc0d
7
+ data.tar.gz: d40f8eb38fc24a574af1c876be615f36e81bfdf3e249a27b1d294504ce4e4717a44ae48106f1ef0c5ae2cd19d5e828aa2627dc88a7a26044e6edbb5ff5f781bf
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.7.2
2
+
3
+ - Log response bodies when the response is `200` indicating the request was only partially accepted
4
+
1
5
  ## 0.7.1
2
6
 
3
7
  - Fix an error where max payload size was calculated using character count instead of bytes
data/README.md CHANGED
@@ -109,6 +109,15 @@ This option may be required if you are using a self-signed certificate, an expir
109
109
  > NOTE: Starting in plugin version `0.5.0`, this option has no effect in versions of Logstash older than `8.1.0`.
110
110
  > If this functionality is required, it is recommended to update Logstash or stay at plugin version `0.4.x` or older.
111
111
 
112
+ ### `max_payload_size`
113
+
114
+ * Value type is [number](https://www.elastic.co/docs/reference/logstash/configuration-file-structure#number)
115
+ * Optional
116
+ * Default value is `9_500_000`
117
+
118
+ It is recommended **not** to set this optional configuration unless you have a specific reason to do so.
119
+ If you, for example, are using a proxy with a payload size limit, this configuration can be used to reduce the maximum size batch that is sent to the server.
120
+
112
121
  ### `proxy`
113
122
 
114
123
  * Value type is [string](https://www.elastic.co/guide/en/logstash/current/configuration-file-structure.html#string) or [hash](https://www.elastic.co/guide/en/logstash/current/configuration-file-structure.html#hash)
@@ -76,7 +76,7 @@ module LogStash
76
76
  config :debug_include_body, validate: :boolean, default: false
77
77
 
78
78
  # Maximum size payload to send to the Dynatrace API in Bytes. Batches of events which would be larger than max_payload_size when serialized will be split into smaller batches of events.
79
- config :max_payload_size, validate: :number, default: 4_500_000
79
+ config :max_payload_size, validate: :number, default: 9_500_000
80
80
 
81
81
  # Disable cookie support. Overridden default value from LogStash::PluginMixins::HttpClient
82
82
  config :cookies, :validate => :boolean, :default => false
@@ -160,6 +160,10 @@ module LogStash
160
160
  end
161
161
  end
162
162
 
163
+ def log_partial_success_response(response)
164
+ @logger.warn("Encountered partial success response", code: response.code, body: response.body)
165
+ end
166
+
163
167
  def log_error_response(response, ingest_endpoint_url, event)
164
168
  log_failure(
165
169
  "Encountered non-2xx HTTP code #{response.code}",
@@ -267,6 +271,8 @@ module LogStash
267
271
  response = client.post(ingest_endpoint_url, body: event, headers: headers)
268
272
 
269
273
  if response_success?(response)
274
+ # some events were not accepted but we don't know which ones or why
275
+ log_partial_success_response(response) if response_partial_success?(response)
270
276
  [:success, event, attempt]
271
277
  elsif retryable_response?(response)
272
278
  log_retryable_response(response)
@@ -315,6 +321,10 @@ module LogStash
315
321
  response.code >= 200 && response.code <= 299
316
322
  end
317
323
 
324
+ def response_partial_success?(response)
325
+ response.code == 200
326
+ end
327
+
318
328
  def retryable_response?(response)
319
329
  RETRYABLE_CODES.include?(response.code)
320
330
  end
@@ -168,6 +168,19 @@ describe LogStash::Outputs::Dynatrace do
168
168
  end
169
169
  end
170
170
 
171
+ context 'with partial success responses' do
172
+ let(:ingest_endpoint_url) { "http://localhost:#{port}/partial" }
173
+
174
+ before do
175
+ allow(subject).to receive(:log_partial_success_response)
176
+ end
177
+
178
+ it 'should warn on partial success' do
179
+ subject.multi_receive([event])
180
+ expect(subject).to have_received(:log_partial_success_response)
181
+ end
182
+ end
183
+
171
184
  context 'with retryable failing requests' do
172
185
  let(:ingest_endpoint_url) { "http://localhost:#{port}/retry" }
173
186
  let(:api_key) { 'placeholder-key' }
@@ -188,17 +201,6 @@ describe LogStash::Outputs::Dynatrace do
188
201
  end
189
202
  end
190
203
 
191
- context 'with more than 4.5MB of events' do
192
- before do
193
- allow(subject).to receive(:send_event) { |e, att| [:success, e, att] }
194
- subject.multi_receive([1, 2].map { |n| LogStash::Event.new({ 'n' => n.to_s * 2_500_001 }) })
195
- end
196
-
197
- it 'should split the chunk into multiple requests' do
198
- expect(subject).to have_received(:send_event).exactly(2).times
199
- end
200
- end
201
-
202
204
  shared_examples('send small and drop large') do
203
205
  it 'should only send the small event' do
204
206
  expect(subject).to have_received(:send_event).exactly(1).times
@@ -210,26 +212,6 @@ describe LogStash::Outputs::Dynatrace do
210
212
  .exactly(:once)
211
213
  end
212
214
  end
213
-
214
- context 'with one small event and one too large event' do
215
- before do
216
- allow(subject).to receive(:send_event) { |e, att| [:success, e, att] }
217
- subject.multi_receive([LogStash::Event.new({ 'event' => 'small' }),
218
- LogStash::Event.new({ 'event' => 'n' * 4_500_001 })])
219
- end
220
-
221
- include_examples('send small and drop large')
222
- end
223
-
224
- context 'with one too large event and one small event' do
225
- before do
226
- allow(subject).to receive(:send_event) { |e, att| [:success, e, att] }
227
- subject.multi_receive([LogStash::Event.new({ 'event' => 'n' * 4_500_001 }),
228
- LogStash::Event.new({ 'event' => 'small' })])
229
- end
230
-
231
- include_examples('send small and drop large')
232
- end
233
215
  end
234
216
 
235
217
  context 'max_payload_size 500' do
data/spec/spec_helper.rb CHANGED
@@ -98,7 +98,12 @@ class TestApp < Sinatra::Base
98
98
 
99
99
  multiroute(%w[get post put patch delete], '/good') do
100
100
  self.class.last_request = request
101
- [200, 'YUP']
101
+ [204, 'YUP']
102
+ end
103
+
104
+ multiroute(%w[get post put patch delete], '/partial') do
105
+ self.class.last_request = request
106
+ [200, 'partial success']
102
107
  end
103
108
 
104
109
  multiroute(%w[get post put patch delete], '/bad') do
data/version.yaml CHANGED
@@ -1 +1 @@
1
- logstash-output-dynatrace: '0.7.1'
1
+ logstash-output-dynatrace: '0.8.0'
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.1
4
+ version: 0.8.0
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-04-23 00:00:00.000000000 Z
11
+ date: 2025-05-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logstash-codec-json