diff --git a/spec/datadog/tracing/contrib/faraday/middleware_spec.rb b/spec/datadog/tracing/contrib/faraday/middleware_spec.rb index 22097bdf1a0..b563384b426 100644 --- a/spec/datadog/tracing/contrib/faraday/middleware_spec.rb +++ b/spec/datadog/tracing/contrib/faraday/middleware_spec.rb @@ -28,12 +28,10 @@ let(:middleware_options) { {} } let(:configuration_options) { {} } let(:response_headers) { {} } - let(:non_billing_mode) { false } before do Datadog.configure do |c| c.tracing.instrument :faraday, configuration_options - c.tracing.apm.enabled = !non_billing_mode end end @@ -415,15 +413,19 @@ context 'when non-billing mode is enabled' do subject(:response) { client.get('/success') } - let(:non_billing_mode) { true } + before do + Datadog.configure do |c| + c.tracing.apm.enabled = false + end + # This cannot happen in actual apps but we do this to + # verify that sampling priority is set to 0 through distributed tracing without mocking an agent + allow(Datadog::Tracing::Distributed::Helpers).to receive(:should_skip_distributed_tracing?).and_return(false) + end + let(:headers) { response.env.request_headers } it do - expect(headers).to include( - 'x-datadog-trace-id' => low_order_trace_id(span.trace_id).to_s, - 'x-datadog-parent-id' => span.id.to_s, - 'x-datadog-sampling-priority' => '0' - ) + expect(headers).to include('x-datadog-sampling-priority' => '0') end end diff --git a/spec/datadog/tracing/contrib/grpc/datadog_interceptor/client_spec.rb b/spec/datadog/tracing/contrib/grpc/datadog_interceptor/client_spec.rb index 6f9fc7c802a..395bf881f6f 100644 --- a/spec/datadog/tracing/contrib/grpc/datadog_interceptor/client_spec.rb +++ b/spec/datadog/tracing/contrib/grpc/datadog_interceptor/client_spec.rb @@ -128,6 +128,9 @@ end context 'with non-billing mode' do + # We cannot get the trace as it is sent and flushed. + # But we can verify non-billing mode through distributed tracing + # Not sure why, putting a before block here has no effect let(:tracing_apm_enabled) { false } let(:force_execute_distributed_tracing) { true }