-
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.
* test processors * add tag processors to inject tags at runtime * manuall check version of tag processors
- Loading branch information
Harry Bragg
committed
Jun 26, 2018
1 parent
c477f21
commit f001f5d
Showing
6 changed files
with
126 additions
and
25 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
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
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,48 @@ | ||
<?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 TagProcessorTest extends TestCase | ||
{ | ||
public function testSingleProcessor() | ||
{ | ||
$this->client->addTagProcessor(function (array $tags) { | ||
$tags['custom'] = 1; | ||
return $tags; | ||
}); | ||
$this->client->increment('test_metric', 1, 1, ['tag']); | ||
$this->assertEquals('test_metric:1|c|#tag,custom:1', $this->client->getLastMessage()); | ||
} | ||
|
||
public function testMultipleProcessors() | ||
{ | ||
$this->client->addTagProcessor(function (array $tags) { | ||
$tags['custom'] = 1; | ||
return $tags; | ||
}); | ||
$this->client->addTagProcessor(function (array $tags) { | ||
$this->assertArrayHasKey( | ||
'custom', | ||
$tags, | ||
'ensure that the processors get processed in the order they are attached to the client' | ||
); | ||
$tags['second'] = 2; | ||
return $tags; | ||
}); | ||
$this->client->increment('test_metric', 1, 1, ['tag' => 'value']); | ||
$this->assertEquals('test_metric:1|c|#tag:value,custom:1,second:2', $this->client->getLastMessage()); | ||
} | ||
} |