3 namespace Liuggio\StatsdClient\Entity;
5 use Liuggio\StatsdClient\Entity\StatsdDataInterface;
7 class StatsdData implements StatsdDataInterface
13 private $sampleRate = 1;
18 public function setKey($key)
26 public function getKey()
34 public function setValue($value)
36 $this->value = $value;
42 public function getValue()
48 public function setMetric($metric)
50 $this->metric = $metric;
53 public function getMetric()
59 * @param float $sampleRate
61 public function setSampleRate($sampleRate)
63 $this->sampleRate = $sampleRate;
69 public function getSampleRate()
71 return $this->sampleRate;
75 * @param bool $withMetric
79 public function getMessage($withMetric = true)
82 $result = sprintf('%s:%s', $this->getKey(), $this->getValue());
84 $result = sprintf('%s:%s|%s', $this->getKey(), $this->getValue(), $this->getMetric());
87 $sampleRate = $this->getSampleRate();
89 $result.= "|@$sampleRate";
98 public function __toString()
100 return $this->getMessage();