Skip to content

Commit

Permalink
repair di transport
Browse files Browse the repository at this point in the history
  • Loading branch information
p committed Nov 7, 2024
1 parent 13f4900 commit 389488a
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions lib/datadog/di/transport.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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?
Expand Down

0 comments on commit 389488a

Please sign in to comment.