We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6815786 commit ebe1a89Copy full SHA for ebe1a89
1 file changed
src/Sampler/RateLimitingSampler.php
@@ -18,7 +18,8 @@ public function __construct(float $rate, GeneratorInterface $generator)
18
public function doDecide(int $tracerId, string $operationName): SamplerResult
19
{
20
$key = $this->generator->generate($tracerId, $operationName);
21
- if (false !== ($current = apcu_add($key, sprintf('%s:%d', time(), 1), 1 / $this->rate))) {
+ $ttl = max((int)(1 / $this->rate + 1), 1);
22
+ if (false !== ($current = apcu_add($key, sprintf('%s:%d', time(), 1), $ttl))) {
23
return new SamplerResult(
24
true, 0x01, [
25
new SamplerTypeTag('ratelimiting'),
0 commit comments