Skip to content

Commit

Permalink
Merge pull request #2673 from DataDog/isolate-trace-transport
Browse files Browse the repository at this point in the history
Rename conflicting `send_payload` method
  • Loading branch information
lloeki authored Mar 8, 2023
2 parents e8eda87 + 9291a88 commit e3cdbb4
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion lib/ddtrace/transport/http/traces.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def initialize(http_response, options = {})

# Extensions for HTTP client
module Client
def send_payload(request)
def send_traces_payload(request)
send_request(request) do |api, env|
api.send_traces(env)
end
Expand Down
2 changes: 1 addition & 1 deletion lib/ddtrace/transport/traces.rb
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def send_traces(traces)
responses = chunker.encode_in_chunks(traces.lazy).map do |encoded_traces, trace_count|
request = Request.new(EncodedParcel.new(encoded_traces, trace_count))

client.send_payload(request).tap do |response|
client.send_traces_payload(request).tap do |response|
if downgrade?(response)
downgrade!
return send_traces(traces)
Expand Down
4 changes: 2 additions & 2 deletions spec/ddtrace/transport/http/traces_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@

let(:api) { instance_double(Datadog::Transport::HTTP::API::Instance) }

describe '#send_payload' do
subject(:send_payload) { client.send_payload(request) }
describe '#send_traces_payload' do
subject(:send_traces_payload) { client.send_traces_payload(request) }

let(:request) { instance_double(Datadog::Transport::Traces::Request) }
let(:response) { instance_double(Datadog::Transport::HTTP::Traces::Response) }
Expand Down
16 changes: 8 additions & 8 deletions spec/ddtrace/transport/traces_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@

allow(Datadog::Transport::HTTP::Client).to receive(:new).with(api_v1).and_return(client_v1)
allow(Datadog::Transport::HTTP::Client).to receive(:new).with(api_v2).and_return(client_v2)
allow(client_v1).to receive(:send_payload).with(request).and_return(response)
allow(client_v2).to receive(:send_payload).with(request).and_return(response)
allow(client_v1).to receive(:send_traces_payload).with(request).and_return(response)
allow(client_v2).to receive(:send_traces_payload).with(request).and_return(response)

allow(Datadog::Transport::Traces::Request).to receive(:new).and_return(request)
end
Expand All @@ -190,7 +190,7 @@

it 'sends to only the current API once' do
is_expected.to eq(responses)
expect(client_v2).to have_received(:send_payload).with(request).once
expect(client_v2).to have_received(:send_traces_payload).with(request).once

expect(health_metrics).to have_received(:transport_chunked).with(1)
end
Expand All @@ -206,7 +206,7 @@

it 'successfully sends a single request' do
is_expected.to eq(responses)
expect(client_v2).to have_received(:send_payload).with(request).once
expect(client_v2).to have_received(:send_traces_payload).with(request).once

expect(health_metrics).to have_received(:transport_chunked).with(1)
end
Expand All @@ -232,8 +232,8 @@
it 'attempts each API once as it falls back after each failure' do
is_expected.to eq(responses)

expect(client_v2).to have_received(:send_payload).with(request).once
expect(client_v1).to have_received(:send_payload).with(request).once
expect(client_v2).to have_received(:send_traces_payload).with(request).once
expect(client_v1).to have_received(:send_traces_payload).with(request).once

expect(health_metrics).to have_received(:transport_chunked).with(1)
end
Expand All @@ -248,8 +248,8 @@
it 'attempts each API once as it falls back after each failure' do
is_expected.to eq(responses)

expect(client_v2).to have_received(:send_payload).with(request).once
expect(client_v1).to have_received(:send_payload).with(request).once
expect(client_v2).to have_received(:send_traces_payload).with(request).once
expect(client_v1).to have_received(:send_traces_payload).with(request).once

expect(health_metrics).to have_received(:transport_chunked).with(1)
end
Expand Down

0 comments on commit e3cdbb4

Please sign in to comment.