def test_sampling(self): """Test Sampling.""" tracer = WavefrontTracer(ConsoleReporter(), self.application_tags, samplers=[ConstantSampler(True)]) self.assertTrue(tracer.sample('test_op', 1, 0)) tracer = WavefrontTracer(ConsoleReporter(), self.application_tags, samplers=[ConstantSampler(False)]) self.assertFalse(tracer.sample('test_op', 1, 0))
def test_negative_child_sampling(self): """Test child span with positive sampling.""" tracer = WavefrontTracer(ConsoleReporter(), self.application_tags, samplers=[ConstantSampler(True)]) parent_ctx = WavefrontSpanContext(trace_id=uuid.uuid1(), span_id=uuid.uuid1(), decision=False) span = tracer.start_span('test_op', child_of=parent_ctx) self.assertTrue(tracer.sample(span.operation_name, span.trace_id, 0)) self.assertIsNotNone(span) self.assertEqual(parent_ctx.trace_id, span.trace_id) self.assertTrue(span.context.is_sampled()) self.assertIsNotNone(span.context.get_sampling_decision()) self.assertFalse(span.context.get_sampling_decision())