def test_should_sample_utilizes_sample_rate(self): client = make_client("test-service", sample_rate=1) baseplate_observer = TraceBaseplateObserver(client) span = Span("test-id", "test-parent", "test-span-id", None, 0, "test", self.mock_context) self.assertTrue(baseplate_observer.should_sample(span)) baseplate_observer.sample_rate = 0 self.assertFalse(baseplate_observer.should_sample(span))
def test_should_sample_utilizes_force_sampling(self): client = make_client("test-service", sample_rate=0) baseplate_observer = TraceBaseplateObserver(client) span_with_forced = Span("test-id", "test-parent", "test-span-id", False, 1, "test", self.mock_context) span_without_forced = Span("test-id", "test-parent", "test-span-id", False, 0, "test", self.mock_context) self.assertTrue(baseplate_observer.should_sample(span_with_forced)) self.assertFalse(baseplate_observer.should_sample(span_without_forced))
def test_should_sample_utilizes_sampled_setting(self): client = make_client("test-service", sample_rate=0) baseplate_observer = TraceBaseplateObserver(client) span_with_sampled_flag = Span("test-id", "test-parent", "test-span-id", True, 0, "test", self.mock_context) self.assertTrue( baseplate_observer.should_sample(span_with_sampled_flag))