From ed800dd9466d447b05201ab5f91048e7fe41fbfc Mon Sep 17 00:00:00 2001 From: Chris W Jones Date: Wed, 29 Nov 2023 11:51:55 -0500 Subject: [PATCH] Fix code style --- src/Profiler/DatadogProfiler.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Profiler/DatadogProfiler.php b/src/Profiler/DatadogProfiler.php index ea478a4..41c9e74 100644 --- a/src/Profiler/DatadogProfiler.php +++ b/src/Profiler/DatadogProfiler.php @@ -29,8 +29,8 @@ public function __construct(LoggerInterface $logger) $this->logger = $logger; $sampleRateString = getenv('DD_TRACE_SAMPLE_RATE'); - if(is_numeric($sampleRateString)) { - $sampleRate = floatval($sampleRateString); + if (is_numeric($sampleRateString)) { + $sampleRate = (float) $sampleRateString; $this->sampleRate = $sampleRate; } } @@ -41,7 +41,7 @@ public function start(string $name, ?string $kind = null): void return; } - if($this->rateLimited()) { + if ($this->rateLimited()) { return; } @@ -104,6 +104,7 @@ public function stopAndIgnore(): void private function rateLimited(): bool { $randomFloat = mt_rand() / mt_getrandmax(); // between 0 and 1 + return $randomFloat > $this->sampleRate; }