diff --git a/src/M6Web/Component/Statsd/Client.php b/src/M6Web/Component/Statsd/Client.php index e3b8d4f..0c03568 100644 --- a/src/M6Web/Component/Statsd/Client.php +++ b/src/M6Web/Component/Statsd/Client.php @@ -63,9 +63,9 @@ public function __construct(array $servers, MessageFormatterInterface $messageFo * * @param array $servers les serveurs * - * @throws Exception - * * @return void + * + * @throws Exception */ protected function init(array $servers) { @@ -147,18 +147,18 @@ public function getServerKey($stats) /** * addToSend * - * @param string $stats grahite node - * @param string $value value - * @param float $sampleRate sampling rate - * @param string $unit unit - * @param array $tags Tags key => value for influxDb + * @param string $stats grahite node + * @param int|string $value value + * @param float $sampleRate sampling rate + * @param string $unit unit + * @param array $tags Tags key => value for influxDb * * @return Client */ protected function addToSend($stats, $value, $sampleRate, $unit, $tags) { $message = new MessageEntity( - (string) $stats, (int) $value, (string) $unit, (float) $sampleRate, $tags + (string) $stats, $value, (string) $unit, (float) $sampleRate, $tags ); $queue = [ @@ -322,9 +322,9 @@ public function send() * @param string $server server key * @param array $datas array de data à env * - * @throws Exception - * * @return bool + * + * @throws Exception */ public function writeDatas($server, $datas) { diff --git a/src/M6Web/Component/Statsd/MessageEntity.php b/src/M6Web/Component/Statsd/MessageEntity.php index bc0359d..3359355 100644 --- a/src/M6Web/Component/Statsd/MessageEntity.php +++ b/src/M6Web/Component/Statsd/MessageEntity.php @@ -25,11 +25,11 @@ class MessageEntity protected $tags = []; /** - * @param string $node node - * @param int $value value of the node - * @param string $unit units (ms for timer, c for counting ...) - * @param float $sampleRate sampling rate - * @param array $tags Tags key => value for influxDb + * @param string $node node + * @param int|string $value value of the node + * @param string $unit units (ms for timer, c for counting ...) + * @param float $sampleRate sampling rate + * @param array $tags Tags key => value for influxDb * * @return MessageEntity */ @@ -60,8 +60,8 @@ protected function checkConstructor() throw new Exception('node and unit have to be a string'); } - if (!is_int($this->value)) { - throw new Exception('value has to be an integer'); + if (!is_int($this->value) && !is_string($this->value)) { + throw new Exception('value has to be an integer or a string'); } if (!is_float($this->sampleRate) or ($this->sampleRate <= 0)) {