Skip to content

Commit eee091b

Browse files
committed
out_otlp: must not retry with 400 response
The specifications are as follows: > The client MUST NOT retry the request when it receives HTTP 400 Bad Request response. Signed-off-by: Shizuo Fujita <fujita@clear-code.com>
1 parent 1846a4d commit eee091b

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

lib/fluent/plugin/out_otlp.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,11 @@ def export(record)
110110
response = connection.post
111111

112112
if response.status != 200
113+
if response.status == 400
114+
# The client MUST NOT retry the request when it receives HTTP 400 Bad Request response.
115+
raise Fluent::UnrecoverableError, "got unrecoverable error response from '#{uri}', response code is #{response.status}"
116+
end
117+
113118
if @http_config.retryable_response_codes&.include?(response.status)
114119
raise RetryableResponse, "got retryable error response from '#{uri}', response code is #{response.status}"
115120
end

test/fluent/plugin/test_out_otlp.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,27 @@ def test_unrecoverable_error
179179
d.instance_shutdown
180180
end
181181

182+
def test_unrecoverable_error_400_status_code
183+
server_response_code(400)
184+
event = { "type" => "otlp_logs", "message" => TestData::JSON::LOGS }
185+
186+
d = create_driver(%[
187+
<http>
188+
endpoint "http://127.0.0.1:#{@port}"
189+
error_response_as_unrecoverable false
190+
retryable_response_codes [400]
191+
</http>
192+
])
193+
d.run(default_tag: "otlp.test", shutdown: false) do
194+
d.feed(event)
195+
end
196+
197+
assert_match(%r{got unrecoverable error response from 'http://127.0.0.1:#{@port}/v1/logs', response code is 400},
198+
d.instance.log.out.logs.join)
199+
200+
d.instance_shutdown
201+
end
202+
182203
def test_error_with_disabled_unrecoverable
183204
server_response_code(500)
184205
event = { "type" => "otlp_logs", "message" => TestData::JSON::LOGS }

0 commit comments

Comments
 (0)