Skip to content

Commit

Permalink
Merge pull request #36 from utopia-php/feat-add-sampler
Browse files Browse the repository at this point in the history
Use greater than instead of lesser than for sampler
  • Loading branch information
christyjacob4 authored May 17, 2024
2 parents 048042f + ddd0024 commit c6dfdb6
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Logger/Logger.php
Original file line number Diff line number Diff line change
@@ -57,7 +57,8 @@ public function addLog(Log $log): int
}

if (! is_null($this->samplePercent)) {
if (rand(0, 100) <= $this->samplePercent) {
$rand = rand(1, 100);
if ($rand >= $this->samplePercent) {
return 0;
}
}
2 changes: 1 addition & 1 deletion tests/e2e/AdapterBase.php
Original file line number Diff line number Diff line change
@@ -84,6 +84,6 @@ public function testSampler(): void

$zeroPercentage = ($zeroCount / count($results)) * 100;

$this->assertLessThan(20, $zeroPercentage);
$this->assertGreaterThan(85, $zeroPercentage);
}
}

0 comments on commit c6dfdb6

Please sign in to comment.