示例#1
0
 public function it_formats_metric(Metric $metric)
 {
     $metric->getName()->willReturn('foo.bar')->shouldBeCalled();
     $metric->getValue()->willReturn(100500)->shouldBeCalled();
     $metric->getTime()->willReturn(1426422536)->shouldBeCalled();
     $this->format($metric)->shouldReturn("foo.bar 100500 1426422536\n");
 }
示例#2
0
 /**
  * @param Metric $metric
  *
  * @return array
  */
 protected function serialize(Metric $metric)
 {
     $result = [];
     if ($meta = $metric->getMeta()) {
         $result['tags'] = $meta;
     }
     $result['fields'] = ['value' => $metric->getValue()];
     $result['timestamp'] = date(DATE_RFC3339, $metric->getTime());
     return $result;
 }
示例#3
0
 /**
  * @param Metric $metric
  *
  * @return string
  */
 public function format(Metric $metric)
 {
     return sprintf("%s %s %s\n", $metric->getName(), $metric->getValue(), $metric->getTime());
 }