Skip to content

Commit

Permalink
Fixed: Priority sampling with specs.
Browse files Browse the repository at this point in the history
  • Loading branch information
delner committed Dec 17, 2018
1 parent 6b126f7 commit c33dc35
Show file tree
Hide file tree
Showing 44 changed files with 80 additions and 55 deletions.
2 changes: 1 addition & 1 deletion spec/ddtrace/configuration/pin_setup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
}
end

let(:tracer) { Datadog::Tracer.new(writer: FauxWriter.new) }
let(:tracer) { get_test_tracer }

it do
expect(target.datadog_pin.service).to eq('my-service')
Expand Down
2 changes: 1 addition & 1 deletion spec/ddtrace/context_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
RSpec.describe Datadog::Context do
subject(:context) { described_class.new(options) }
let(:options) { {} }
let(:tracer) { ::Datadog::Tracer.new(writer: FauxWriter.new) }
let(:tracer) { get_test_tracer }

describe '#current_root_span' do
subject(:current_root_span) { context.current_root_span }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
RSpec.describe 'ActiveModelSerializers patcher' do
include_context 'AMS serializer'

let(:tracer) { ::Datadog::Tracer.new(writer: FauxWriter.new) }
let(:tracer) { get_test_tracer }

def all_spans
tracer.writer.spans(:keep)
Expand Down
2 changes: 1 addition & 1 deletion spec/ddtrace/contrib/active_record/multi_db_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
require 'sqlite3'

RSpec.describe 'ActiveRecord multi-database implementation' do
let(:tracer) { ::Datadog::Tracer.new(writer: FauxWriter.new) }
let(:tracer) { get_test_tracer }
let(:configuration_options) { { tracer: tracer, service_name: default_db_service_name } }
let(:default_db_service_name) { 'default-db' }

Expand Down
2 changes: 1 addition & 1 deletion spec/ddtrace/contrib/active_record/performance_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require 'sqlite3'

RSpec.describe 'ActiveRecord tracing performance' do
let(:tracer) { ::Datadog::Tracer.new(writer: FauxWriter.new) }
let(:tracer) { get_test_tracer }
let(:options) { { tracer: tracer } }
let(:spans) { tracer.writer.spans }

Expand Down
2 changes: 1 addition & 1 deletion spec/ddtrace/contrib/active_record/tracer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
require_relative 'app'

RSpec.describe 'ActiveRecord instrumentation' do
let(:tracer) { ::Datadog::Tracer.new(writer: FauxWriter.new) }
let(:tracer) { get_test_tracer }
let(:configuration_options) { { tracer: tracer } }

before(:each) do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
RSpec.describe Datadog::Contrib::ActiveSupport::Notifications::Subscription do
describe 'instance' do
subject(:subscription) { described_class.new(tracer, span_name, options, &block) }
let(:tracer) { ::Datadog::Tracer.new(writer: FauxWriter.new) }
let(:tracer) { get_test_tracer }
let(:span_name) { double('span_name') }
let(:options) { {} }
let(:payload) { {} }
Expand Down
2 changes: 1 addition & 1 deletion spec/ddtrace/contrib/aws/instrumentation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
require 'ddtrace/ext/http'

RSpec.describe 'AWS instrumentation' do
let(:tracer) { ::Datadog::Tracer.new(writer: FauxWriter.new) }
let(:tracer) { get_test_tracer }

let(:client) { ::Aws::S3::Client.new(stub_responses: responses) }
let(:responses) { true }
Expand Down
2 changes: 1 addition & 1 deletion spec/ddtrace/contrib/concurrent_ruby/integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
remove_patch!(:concurrent_ruby)
end

let(:tracer) { ::Datadog::Tracer.new(writer: FauxWriter.new) }
let(:tracer) { get_test_tracer }
let(:configuration_options) { { tracer: tracer } }

subject(:deferred_execution) do
Expand Down
2 changes: 1 addition & 1 deletion spec/ddtrace/contrib/dalli/instrumentation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
let(:test_port) { ENV.fetch('TEST_MEMCACHED_PORT', '11211') }

let(:client) { ::Dalli::Client.new("#{test_host}:#{test_port}") }
let(:tracer) { ::Datadog::Tracer.new(writer: FauxWriter.new) }
let(:tracer) { get_test_tracer }
let(:pin) { ::Dalli.datadog_pin }

def all_spans
Expand Down
2 changes: 1 addition & 1 deletion spec/ddtrace/contrib/delayed_job/plugin_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def job_data
end)
end

let(:tracer) { ::Datadog::Tracer.new(writer: FauxWriter.new) }
let(:tracer) { get_test_tracer }

before do
Datadog.configure { |c| c.use :delayed_job, tracer: tracer }
Expand Down
2 changes: 1 addition & 1 deletion spec/ddtrace/contrib/elasticsearch/patcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

let(:client) { Elasticsearch::Client.new(url: server) }
let(:pin) { Datadog::Pin.get_from(client) }
let(:tracer) { Datadog::Tracer.new(writer: FauxWriter.new) }
let(:tracer) { get_test_tracer }

before do
Datadog.configure do |c|
Expand Down
2 changes: 1 addition & 1 deletion spec/ddtrace/contrib/elasticsearch/transport_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
let(:server) { "http://#{host}:#{port}" }

let(:client) { Elasticsearch::Client.new(url: server) }
let(:tracer) { Datadog::Tracer.new(writer: FauxWriter.new) }
let(:tracer) { get_test_tracer }

let(:spans) { tracer.writer.spans }
let(:span) { spans.first }
Expand Down
2 changes: 1 addition & 1 deletion spec/ddtrace/contrib/excon/instrumentation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require 'ddtrace/contrib/excon/middleware'

RSpec.describe Datadog::Contrib::Excon::Middleware do
let(:tracer) { Datadog::Tracer.new(writer: FauxWriter.new) }
let(:tracer) { get_test_tracer }

let(:connection_options) { { mock: true } }
let(:middleware_options) { {} }
Expand Down
2 changes: 1 addition & 1 deletion spec/ddtrace/contrib/faraday/middleware_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require 'ddtrace/ext/distributed'

RSpec.describe 'Faraday middleware' do
let(:tracer) { Datadog::Tracer.new(writer: FauxWriter.new) }
let(:tracer) { get_test_tracer }

let(:client) do
::Faraday.new('http://example.com') do |builder|
Expand Down
2 changes: 1 addition & 1 deletion spec/ddtrace/contrib/graphql/tracer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
end
end

let(:tracer) { ::Datadog::Tracer.new(writer: FauxWriter.new) }
let(:tracer) { get_test_tracer }

def pop_spans
tracer.writer.spans(:keep)
Expand Down
2 changes: 1 addition & 1 deletion spec/ddtrace/contrib/http/patcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require 'net/http'

RSpec.describe 'net/http patcher' do
let(:tracer) { ::Datadog::Tracer.new(writer: FauxWriter.new) }
let(:tracer) { get_test_tracer }
let(:host) { 'example.com' }

before do
Expand Down
2 changes: 1 addition & 1 deletion spec/ddtrace/contrib/mongodb/client_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
require 'mongo'

RSpec.describe 'Mongo::Client instrumentation' do
let(:tracer) { Datadog::Tracer.new(writer: FauxWriter.new) }
let(:tracer) { get_test_tracer }

let(:client) { Mongo::Client.new(*client_options) }
let(:client_options) { [["#{host}:#{port}"], { database: database }] }
Expand Down
2 changes: 1 addition & 1 deletion spec/ddtrace/contrib/mysql2/patcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
require 'mysql2'

RSpec.describe 'Mysql2::Client patcher' do
let(:tracer) { Datadog::Tracer.new(writer: FauxWriter.new) }
let(:tracer) { get_test_tracer }

let(:client) do
Mysql2::Client.new(
Expand Down
2 changes: 1 addition & 1 deletion spec/ddtrace/contrib/racecar/patcher_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require 'active_support'
require 'ddtrace'
RSpec.describe 'Racecar patcher' do
let(:tracer) { ::Datadog::Tracer.new(writer: FauxWriter.new) }
let(:tracer) { get_test_tracer }

def all_spans
tracer.writer.spans(:keep)
Expand Down
2 changes: 1 addition & 1 deletion spec/ddtrace/contrib/rack/distributed_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
RSpec.describe 'Rack integration distributed tracing' do
include Rack::Test::Methods

let(:tracer) { Datadog::Tracer.new(writer: FauxWriter.new) }
let(:tracer) { get_test_tracer }
let(:rack_options) { { tracer: tracer } }

let(:spans) { tracer.writer.spans }
Expand Down
2 changes: 1 addition & 1 deletion spec/ddtrace/contrib/rack/integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
RSpec.describe 'Rack integration tests' do
include Rack::Test::Methods

let(:tracer) { Datadog::Tracer.new(writer: FauxWriter.new) }
let(:tracer) { get_test_tracer }
let(:rack_options) { { tracer: tracer } }

let(:spans) { tracer.writer.spans }
Expand Down
2 changes: 1 addition & 1 deletion spec/ddtrace/contrib/rack/middleware_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
subject(:middleware) { described_class.new(app) }
let(:app) { instance_double(Rack::Builder) }

let(:tracer) { Datadog::Tracer.new(writer: FauxWriter.new) }
let(:tracer) { get_test_tracer }
let(:configuration_options) { { tracer: tracer } }

before(:each) do
Expand Down
2 changes: 1 addition & 1 deletion spec/ddtrace/contrib/rack/request_queuing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
RSpec.describe 'Rack integration request queuing' do
include Rack::Test::Methods

let(:tracer) { Datadog::Tracer.new(writer: FauxWriter.new) }
let(:tracer) { get_test_tracer }
let(:rack_options) { { tracer: tracer } }

let(:spans) { tracer.writer.spans }
Expand Down
2 changes: 1 addition & 1 deletion spec/ddtrace/contrib/rack/resource_name_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
RSpec.describe 'Rack integration with other middleware' do
include Rack::Test::Methods

let(:tracer) { Datadog::Tracer.new(writer: FauxWriter.new) }
let(:tracer) { get_test_tracer }
let(:rack_options) do
{
application: app,
Expand Down
2 changes: 1 addition & 1 deletion spec/ddtrace/contrib/rails/action_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require 'ddtrace/contrib/rails/rails_helper'

RSpec.describe 'ActionController tracing' do
let(:tracer) { ::Datadog::Tracer.new(writer: FauxWriter.new) }
let(:tracer) { get_test_tracer }
let(:rails_options) { { tracer: tracer } }

before(:each) do
Expand Down
2 changes: 1 addition & 1 deletion spec/ddtrace/contrib/rails/middleware_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def index
end)
end

let(:tracer) { ::Datadog::Tracer.new(writer: FauxWriter.new) }
let(:tracer) { get_test_tracer }

def all_spans
tracer.writer.spans(:keep)
Expand Down
2 changes: 1 addition & 1 deletion spec/ddtrace/contrib/rails/railtie_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
before(:each) { skip 'Test not compatible with Rails < 4.0' if Rails.version < '4.0' }
include_context 'Rails test application'

let(:tracer) { ::Datadog::Tracer.new(writer: FauxWriter.new) }
let(:tracer) { get_test_tracer }

let(:routes) { { '/' => 'test#index' } }
let(:controllers) { [controller] }
Expand Down
2 changes: 1 addition & 1 deletion spec/ddtrace/contrib/rake/instrumentation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
require 'ddtrace/contrib/rake/patcher'

RSpec.describe Datadog::Contrib::Rake::Instrumentation do
let(:tracer) { Datadog::Tracer.new(writer: FauxWriter.new) }
let(:tracer) { get_test_tracer }
let(:configuration_options) { { tracer: tracer, enabled: true } }
let(:spans) { tracer.writer.spans }
let(:span) { spans.first }
Expand Down
2 changes: 1 addition & 1 deletion spec/ddtrace/contrib/redis/miniapp_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
require 'ddtrace'

RSpec.describe 'Redis mini app test' do
let(:tracer) { ::Datadog::Tracer.new(writer: FauxWriter.new) }
let(:tracer) { get_test_tracer }

def all_spans
tracer.writer.spans(:keep)
Expand Down
2 changes: 1 addition & 1 deletion spec/ddtrace/contrib/redis/redis_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
require 'ddtrace'

RSpec.describe 'Redis test' do
let(:tracer) { ::Datadog::Tracer.new(writer: FauxWriter.new) }
let(:tracer) { get_test_tracer }

def all_spans
tracer.writer.spans(:keep)
Expand Down
2 changes: 1 addition & 1 deletion spec/ddtrace/contrib/resque/instrumentation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
RSpec.describe 'Resque instrumentation' do
include_context 'Resque job'

let(:tracer) { ::Datadog::Tracer.new(writer: FauxWriter.new) }
let(:tracer) { get_test_tracer }
let(:pin) { ::Resque.datadog_pin }
let(:spans) { tracer.writer.spans }
let(:span) { spans.first }
Expand Down
2 changes: 1 addition & 1 deletion spec/ddtrace/contrib/rest_client/request_patch_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
require 'restclient/request'

RSpec.describe Datadog::Contrib::RestClient::RequestPatch do
let(:tracer) { Datadog::Tracer.new(writer: FauxWriter.new) }
let(:tracer) { get_test_tracer }
let(:rest_client_options) { {} }

before do
Expand Down
2 changes: 1 addition & 1 deletion spec/ddtrace/contrib/sequel/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
require 'ddtrace/contrib/sequel/patcher'

RSpec.describe 'Sequel configuration' do
let(:tracer) { Datadog::Tracer.new(writer: FauxWriter.new) }
let(:tracer) { get_test_tracer }
let(:spans) { tracer.writer.spans }
let(:span) { spans.first }

Expand Down
2 changes: 1 addition & 1 deletion spec/ddtrace/contrib/sequel/instrumentation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
require 'ddtrace/contrib/sequel/integration'

RSpec.describe 'Sequel instrumentation' do
let(:tracer) { Datadog::Tracer.new(writer: FauxWriter.new) }
let(:tracer) { get_test_tracer }
let(:configuration_options) { { tracer: tracer } }
let(:sequel) do
Sequel.sqlite(':memory:').tap do |s|
Expand Down
2 changes: 1 addition & 1 deletion spec/ddtrace/contrib/shoryuken/tracer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
require 'shoryuken'

RSpec.describe Datadog::Contrib::Shoryuken::Tracer do
let(:tracer) { ::Datadog::Tracer.new(writer: FauxWriter.new) }
let(:tracer) { get_test_tracer }
let(:options) { { tracer: tracer } }
let(:spans) { tracer.writer.spans }
let(:span) { spans.first }
Expand Down
2 changes: 1 addition & 1 deletion spec/ddtrace/contrib/sinatra/activerecord_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
RSpec.describe 'Sinatra instrumentation with ActiveRecord' do
include Rack::Test::Methods

let(:tracer) { Datadog::Tracer.new(writer: FauxWriter.new) }
let(:tracer) { get_test_tracer }
let(:options) { { tracer: tracer } }

let(:span) { spans.first }
Expand Down
2 changes: 1 addition & 1 deletion spec/ddtrace/contrib/sinatra/multi_app_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
RSpec.describe 'Sinatra instrumentation for multi-apps' do
include Rack::Test::Methods

let(:tracer) { Datadog::Tracer.new(writer: FauxWriter.new) }
let(:tracer) { get_test_tracer }
let(:options) { { tracer: tracer } }

let(:span) { spans.first }
Expand Down
4 changes: 2 additions & 2 deletions spec/ddtrace/contrib/sinatra/tracer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
RSpec.describe 'Sinatra instrumentation' do
include Rack::Test::Methods

let(:tracer) { Datadog::Tracer.new(writer: FauxWriter.new) }
let(:tracer) { get_test_tracer }
let(:options) { { tracer: tracer } }

let(:span) { spans.first }
Expand Down Expand Up @@ -386,7 +386,7 @@
include_context 'app with simple route'

subject(:response) { get '/' }
let(:tracer) { Datadog::Tracer.new(writer: FauxWriter.new, enabled: false) }
let(:tracer) { get_test_tracer(enabled: false) }

it do
is_expected.to be_ok
Expand Down
12 changes: 3 additions & 9 deletions spec/ddtrace/integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,8 @@ def agent_receives_span_step3
end

describe 'sampling priority metrics' do
let(:tracer) do
get_test_tracer.tap do |t|
t.configure(priority_sampling: true)
t.writer = writer
end
end

let(:writer) { FauxWriter.new(priority_sampler: Datadog::PrioritySampler.new) }
# Sampling priority is enabled by default
let(:tracer) { get_test_tracer }

context 'when #sampling_priority is set on a child span' do
let(:parent_span) { tracer.start_span('parent span') }
Expand All @@ -180,7 +174,7 @@ def agent_receives_span_step3
end.finish
end.finish

try_wait_until(attempts: 30) { writer.spans(:keep).any? }
try_wait_until(attempts: 30) { tracer.writer.spans(:keep).any? }
end

it do
Expand Down
Loading

0 comments on commit c33dc35

Please sign in to comment.