Skip to content

Commit

Permalink
fix rest_client tests
Browse files Browse the repository at this point in the history
  • Loading branch information
brettlangdon committed Feb 26, 2019
1 parent 2380483 commit ad0e209
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
1 change: 0 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@ namespace :spec do
:sidekiq,
:sinatra,
:sucker_punch,
:rest_client,
:shoryuken
].each do |contrib|
RSpec::Core::RakeTask.new(contrib) do |t|
Expand Down
42 changes: 40 additions & 2 deletions spec/ddtrace/contrib/rest_client/request_patch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@
end
end

context 'distributed tracing enabled' do
let(:rest_client_options) { { distributed_tracing: true } }
context 'distributed tracing default' do
# let(:rest_client_options) { { distributed_tracing: true } }

it_behaves_like 'instrumented request'

Expand Down Expand Up @@ -215,5 +215,43 @@
end
end
end

context 'distributed tracing disabled' do
let(:rest_client_options) { { distributed_tracing: false } }

it_behaves_like 'instrumented request'

shared_examples_for 'does not propagate distributed headers' do
let(:span) { tracer.writer.spans.first }

it 'does not propagate the headers' do
request

distributed_tracing_headers = { 'X-Datadog-Parent-Id' => span.span_id.to_s,
'X-Datadog-Trace-Id' => span.trace_id.to_s }

expect(a_request(:get, url).with(headers: distributed_tracing_headers)).to_not have_been_made
end
end

it_behaves_like 'does not propagate distributed headers'

context 'with sampling priority' do
let(:sampling_priority) { 0.2 }

before do
tracer.provider.context.sampling_priority = sampling_priority
end

it_behaves_like 'does not propagate distributed headers'

it 'does not propagate sampling priority headers' do
RestClient.get(url)

expect(a_request(:get, url).with(headers: { 'X-Datadog-Sampling-Priority' => sampling_priority.to_s }))
.to_not have_been_made
end
end
end
end
end

0 comments on commit ad0e209

Please sign in to comment.