function it_collects_and_publishes_the_metrics(MetricCollector $collector, MetricPublisher $publisher, InputInterface $input, OutputInterface $output)
 {
     $metrics = [new Metric('first', 1), new Metric('bar', 0.5)];
     $collector->collect()->shouldBeCalled()->willReturn($metrics);
     $publisher->publish($metrics)->shouldBeCalled();
     $this->run($input, $output);
 }
 function it_allows_to_add_a_collector(MetricCollector $first, MetricCollector $added)
 {
     $this->beConstructedWith([$first]);
     $this->addCollector($added);
     $m1 = new Metric('first', 1);
     $m2 = new Metric('second', 2);
     $first->collect()->willReturn([$m1]);
     $added->collect()->willReturn([$m2]);
     $this->collect()->shouldBeLike([$m1, $m2]);
 }
Example #3
0
 /**
  * {@inheritdoc}
  */
 public function collect()
 {
     return array_map(function (Metric $metric) {
         return new Metric($this->namespace . '.' . $metric->getName(), $metric->getValue());
     }, $this->decoratedCollector->collect());
 }
 function it_prefixes_every_metric_with_the_namespace(MetricCollector $collector)
 {
     $collector->collect()->willReturn([new Metric('foo', 1), new Metric('bar.baz', 'string')]);
     $this->collect()->shouldBeLike([new Metric('my_namespace.foo', 1), new Metric('my_namespace.bar.baz', 'string')]);
 }