From d4918cef9ea96d66936e2aae7e0dc5290b446f96 Mon Sep 17 00:00:00 2001 From: Martin Tomec Date: Fri, 18 Nov 2016 14:28:34 +0100 Subject: [PATCH] Fixed default sampling function. For sampling rate 0.5 function gets arguments (0,2) and should return only 0 or 1 (not 2). --- src/Liuggio/StatsdClient/Service/StatsdService.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Liuggio/StatsdClient/Service/StatsdService.php b/src/Liuggio/StatsdClient/Service/StatsdService.php index 061e351..8e7fa09 100644 --- a/src/Liuggio/StatsdClient/Service/StatsdService.php +++ b/src/Liuggio/StatsdClient/Service/StatsdService.php @@ -55,7 +55,7 @@ public function __construct( /** * Actually defines the sampling rate used by the service. - * If set to 0.1, the service will automatically discard 10% + * If set to 0.1, the service will automatically discard 90% * of the incoming metrics. It will also automatically flag these * as sampled data to statsd. * @@ -68,7 +68,7 @@ public function setSamplingRate($samplingRate) } $this->samplingRate = $samplingRate; $this->samplingFunction = function($min, $max){ - return rand($min, $max); + return rand($min, $max - 1); }; }