Skip to content

Commit

Permalink
[priority sampling] fixed integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
ufoot authored and p-lambert committed Nov 27, 2017
1 parent 04726f9 commit fd3a914
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions test/integration_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
require 'ddtrace/tracer'
require 'thread'

# rubocop:disable Metrics/ClassLength
class TracerIntegrationTest < Minitest::Test
def agent_receives_span_step1(tracer)
stats = tracer.writer.stats
Expand Down Expand Up @@ -164,24 +165,28 @@ def test_sampling_priority_metric_propagation
end

def test_priority_sampling_integration
tracer = Datadog::Tracer.new
tracer.configure(enabled: true, hostname: '127.0.0.1', port: '8126', priority_sampling: true)
# Whatever the sampling priority sampling is, all traces are sent to the agent,
# the agent then sends it or not depending on the priority, but they are all sent.
3.times do |i|
tracer = Datadog::Tracer.new
tracer.configure(enabled: true, hostname: '127.0.0.1', port: '8126', priority_sampling: true)

span_a = tracer.start_span('span_a')
span_b = tracer.start_span('span_b', child_of: span_a.context)
span_a = tracer.start_span('span_a')
span_b = tracer.start_span('span_b', child_of: span_a.context)

# I want to keep the trace to which `span_b` belongs
span_b.context.sampling_priority = 10
# I want to keep the trace to which `span_b` belongs
span_b.context.sampling_priority = i

span_b.finish
span_a.finish
span_b.finish
span_a.finish

try_wait_until { tracer.writer.stats[:traces_flushed] >= 2 }
stats = tracer.writer.stats
try_wait_until { tracer.writer.stats[:traces_flushed] >= 2 }
stats = tracer.writer.stats

assert_equal(1, stats[:traces_flushed], 'wrong number of traces flushed')
assert_equal(0, stats[:transport][:client_error])
assert_equal(0, stats[:transport][:server_error])
assert_equal(0, stats[:transport][:internal_error])
assert_equal(1, stats[:traces_flushed], 'wrong number of traces flushed')
assert_equal(0, stats[:transport][:client_error])
assert_equal(0, stats[:transport][:server_error])
assert_equal(0, stats[:transport][:internal_error])
end
end
end

0 comments on commit fd3a914

Please sign in to comment.