-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added support for histogram
- Loading branch information
Chris Williams
authored and
Harry Bragg
committed
Dec 2, 2016
1 parent
74d0bd9
commit ebe2da0
Showing
2 changed files
with
78 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
/** | ||
* This file is part of graze/dog-statsd | ||
* | ||
* Copyright (c) 2016 Nature Delivered Ltd. <https://www.graze.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @license https://github.com/graze/dog-statsd/blob/master/LICENSE.md | ||
* @link https://github.com/graze/dog-statsd | ||
*/ | ||
|
||
namespace Graze\DogStatsD\Test\Unit; | ||
|
||
use Graze\DogStatsD\Test\TestCase; | ||
|
||
class HistogramTest extends TestCase | ||
{ | ||
public function testHistogram() | ||
{ | ||
$this->client->histogram('test_metric', 10); | ||
$this->assertEquals('test_metric:10|h', $this->client->getLastMessage()); | ||
|
||
$this->client->histogram('test_metric', 1.2); | ||
$this->assertEquals('test_metric:1.2|h', $this->client->getLastMessage()); | ||
} | ||
|
||
public function testHistogramSample() | ||
{ | ||
while ($this->client->getLastMessage() === '') { | ||
$this->client->histogram('test_metric', 5, 0.75); | ||
} | ||
$this->assertEquals('test_metric:5|h|@0.75', $this->client->getLastMessage()); | ||
} | ||
|
||
public function testHistogramTags() | ||
{ | ||
$this->client->histogram('test_metric', 10, 1.0, []); | ||
$this->assertEquals('test_metric:10|h', $this->client->getLastMessage()); | ||
|
||
$this->client->histogram('test_metric', 10, 1.0, ['tag1']); | ||
$this->assertEquals('test_metric:10|h|#tag1', $this->client->getLastMessage()); | ||
|
||
$this->client->histogram('test_metric', 10, 1.0, ['tag1', 'tag2']); | ||
$this->assertEquals('test_metric:10|h|#tag1,tag2', $this->client->getLastMessage()); | ||
|
||
$this->client->histogram('test_metric', 10, 1.0, ['tag1', 'tag1']); | ||
$this->assertEquals('test_metric:10|h|#tag1,tag1', $this->client->getLastMessage()); | ||
} | ||
} |