/** * @test */ public function itShouldProvideDefaultBuckets() { // .005, .01, .025, .05, .075, .1, .25, .5, .75, 1.0, 2.5, 5.0, 7.5, 10.0 $histogram = new Histogram($this->adapter, 'test', 'some_metric', 'this is for testing', array()); $histogram->observe(0.11); $histogram->observe(0.03); $this->assertThat($this->adapter->collect(), $this->equalTo(array(new MetricFamilySamples(array('name' => 'test_some_metric', 'help' => 'this is for testing', 'type' => Histogram::TYPE, 'labelNames' => array(), 'samples' => array(array('name' => 'test_some_metric_bucket', 'labelNames' => array('le'), 'labelValues' => array(0.005), 'value' => 0), array('name' => 'test_some_metric_bucket', 'labelNames' => array('le'), 'labelValues' => array(0.01), 'value' => 0), array('name' => 'test_some_metric_bucket', 'labelNames' => array('le'), 'labelValues' => array(0.025), 'value' => 0), array('name' => 'test_some_metric_bucket', 'labelNames' => array('le'), 'labelValues' => array(0.05), 'value' => 1), array('name' => 'test_some_metric_bucket', 'labelNames' => array('le'), 'labelValues' => array(0.075), 'value' => 1), array('name' => 'test_some_metric_bucket', 'labelNames' => array('le'), 'labelValues' => array(0.1), 'value' => 1), array('name' => 'test_some_metric_bucket', 'labelNames' => array('le'), 'labelValues' => array(0.25), 'value' => 2), array('name' => 'test_some_metric_bucket', 'labelNames' => array('le'), 'labelValues' => array(0.5), 'value' => 2), array('name' => 'test_some_metric_bucket', 'labelNames' => array('le'), 'labelValues' => array(0.75), 'value' => 2), array('name' => 'test_some_metric_bucket', 'labelNames' => array('le'), 'labelValues' => array(1.0), 'value' => 2), array('name' => 'test_some_metric_bucket', 'labelNames' => array('le'), 'labelValues' => array(2.5), 'value' => 2), array('name' => 'test_some_metric_bucket', 'labelNames' => array('le'), 'labelValues' => array(5), 'value' => 2), array('name' => 'test_some_metric_bucket', 'labelNames' => array('le'), 'labelValues' => array(7.5), 'value' => 2), array('name' => 'test_some_metric_bucket', 'labelNames' => array('le'), 'labelValues' => array(10), 'value' => 2), array('name' => 'test_some_metric_bucket', 'labelNames' => array('le'), 'labelValues' => array('+Inf'), 'value' => 2), array('name' => 'test_some_metric_count', 'labelNames' => array(), 'labelValues' => array(), 'value' => 2), array('name' => 'test_some_metric_sum', 'labelNames' => array(), 'labelValues' => array(), 'value' => 0.14))))))); }
/** * @test */ public function itShouldOverwriteWhenSettingTwice() { $gauge = new Gauge($this->adapter, 'test', 'some_metric', 'this is for testing', array('foo', 'bar')); $gauge->set(123, array('lalal', 'lululu')); $gauge->set(321, array('lalal', 'lululu')); $this->assertThat($this->adapter->collect(), $this->equalTo(array(new MetricFamilySamples(array('name' => 'test_some_metric', 'help' => 'this is for testing', 'type' => Gauge::TYPE, 'labelNames' => array('foo', 'bar'), 'samples' => array(array('name' => 'test_some_metric', 'labelNames' => array(), 'labelValues' => array('lalal', 'lululu'), 'value' => 321))))))); }
/** * @return MetricFamilySamples[] */ public function getMetricFamilySamples() { return $this->storageAdapter->collect(); }