diff --git a/lib/datadog/di/transport.rb b/lib/datadog/di/transport.rb index aa86f53009f..d4529e92b02 100644 --- a/lib/datadog/di/transport.rb +++ b/lib/datadog/di/transport.rb @@ -35,11 +35,16 @@ def send_diagnostics(payload) StringIO.new(JSON.dump(payload)), 'application/json', 'event.json' ) payload = {'event' => event_payload} - send_request('Probe status submission', DIAGNOSTICS_PATH, payload) + # Core transport unconditionally specifies headers to underlying + # Net::HTTP client, ends up passing 'nil' as headers if none are + # specified by us, which then causes Net::HTTP to die with an exception. + send_request('Probe status submission', + path: DIAGNOSTICS_PATH, form: payload, headers: {}) end def send_input(payload) - send_request('Probe snapshot submission', INPUT_PATH, payload, + send_request('Probe snapshot submission', + path: INPUT_PATH, body: payload.to_s, headers: {'content-type' => 'application/json'},) end @@ -53,13 +58,9 @@ def send_input(payload) attr_reader :client - def send_request(desc, path, payload, headers: {}) + def send_request(desc, **options) # steep:ignore:start - env = OpenStruct.new( - path: path, - form: payload, - headers: headers, - ) + env = OpenStruct.new(**options) # steep:ignore:end response = client.post(env) unless response.ok?