1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* This file is part of graze/dog-statsd |
4
|
|
|
* |
5
|
|
|
* Copyright (c) 2016 Nature Delivered Ltd. <https://www.graze.com> |
6
|
|
|
* |
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
8
|
|
|
* file that was distributed with this source code. |
9
|
|
|
* |
10
|
|
|
* @license https://github.com/graze/dog-statsd/blob/master/LICENSE.md |
11
|
|
|
* @link https://github.com/graze/dog-statsd |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace Graze\DogStatsD\Test\Unit; |
15
|
|
|
|
16
|
|
|
use Graze\DogStatsD\Client; |
17
|
|
|
use Graze\DogStatsD\Test\TestCase; |
18
|
|
|
|
19
|
|
|
class NamespaceTest extends TestCase |
20
|
|
|
{ |
21
|
|
|
public function testNamespace() |
22
|
|
|
{ |
23
|
|
|
$this->client->configure([ |
24
|
|
|
'host' => '127.0.0.1', |
25
|
|
|
'port' => 8125, |
26
|
|
|
'namespace' => 'test_namespace', |
27
|
|
|
]); |
28
|
|
|
$this->assertEquals('test_namespace', $this->client->getNamespace()); |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
public function testNamespaceIncrement() |
32
|
|
|
{ |
33
|
|
|
$this->client->configure([ |
34
|
|
|
'host' => '127.0.0.1', |
35
|
|
|
'port' => 8125, |
36
|
|
|
'namespace' => 'test_namespace', |
37
|
|
|
]); |
38
|
|
|
$this->client->increment('test_metric'); |
39
|
|
|
$this->assertEquals('test_namespace.test_metric:1|c', $this->client->getLastMessage()); |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
public function testNamespaceEvent() |
43
|
|
|
{ |
44
|
|
|
$this->client->configure([ |
45
|
|
|
'host' => '127.0.0.1', |
46
|
|
|
'port' => 8125, |
47
|
|
|
'namespace' => 'test_namespace', |
48
|
|
|
]); |
49
|
|
|
$this->client->event('some_title', 'textAndThings'); |
50
|
|
|
$this->assertEquals('_e{10,13}:test_namespace.some_title|textAndThings', $this->client->getLastMessage()); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
public function testNamespaceSimpleService() |
54
|
|
|
{ |
55
|
|
|
$this->client->configure([ |
56
|
|
|
'host' => '127.0.0.1', |
57
|
|
|
'port' => 8125, |
58
|
|
|
'namespace' => 'test_namespace', |
59
|
|
|
]); |
60
|
|
|
$this->client->serviceCheck('service.api', Client::STATUS_OK); |
61
|
|
|
$this->assertEquals('_sc|test_namespace.service.api|0', $this->client->getLastMessage()); |
62
|
|
|
} |
63
|
|
|
} |
64
|
|
|
|