Skip to content

Commit 03a9921

Browse files
committed
don't use the real clock in SpanSampler's limiter test
1 parent 45c3c05 commit 03a9921

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

test/test_span_sampler.cpp

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,8 @@ TEST_CASE("span rule limiter") {
307307

308308
auto finalized = finalize_config(config);
309309
REQUIRE(finalized);
310-
Tracer tracer{*finalized};
310+
auto clock = [frozen_time = default_clock()]() { return frozen_time; };
311+
Tracer tracer{*finalized, clock};
311312

312313
for (std::size_t i = 0; i < test_case.num_spans; ++i) {
313314
auto span = tracer.create_span();
@@ -326,10 +327,5 @@ TEST_CASE("span rule limiter") {
326327
}
327328
}
328329

329-
// The `TestCase` that expects 100 span allowed once failed because 101 were
330-
// allowed. I'm not sure how that works, but we are using a real clock and
331-
// different machines run these cases at different rates, so let's build in a
332-
// fudge factor.
333-
REQUIRE(count_of_sampled_spans >= test_case.expected_count - 10);
334-
REQUIRE(count_of_sampled_spans <= test_case.expected_count + 10);
330+
REQUIRE(count_of_sampled_spans == test_case.expected_count);
335331
}

0 commit comments

Comments
 (0)