Skip to content

Commit 12edf0c

Browse files
author
anahan
committed
Merge branch 'master' into 2.0.x
2 parents 20beb12 + bfebfc7 commit 12edf0c

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

src/Process/CliProcess.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
<?php
2-
declare(strict_types=1);
2+
3+
declare(strict_types = 1);
34

45
namespace Jaeger\Process;
56

67
class CliProcess extends AbstractProcess
78
{
9+
public function __construct(string $serviceName)
10+
{
11+
parent::__construct($serviceName, [new ProcessIpTag()]);
12+
}
813
}

src/Process/InternalServerProcess.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@
33

44
namespace Jaeger\Process;
55

6-
class InternalServerProcess extends AbstractProcess
6+
class InternalServerProcess extends CliProcess
77
{
88
}

src/Process/ProcessIpTag.php

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
11
<?php
2-
declare(strict_types=1);
2+
3+
declare(strict_types = 1);
34

45
namespace Jaeger\Process;
56

67
use Jaeger\Tag\StringTag;
78

89
class ProcessIpTag extends StringTag
910
{
11+
private function getIp(): string
12+
{
13+
if (\array_key_exists('SERVER_ADDR', $_SERVER) && '' !== ($ip = (string)$_SERVER['SERVER_ADDR'])) {
14+
return $ip;
15+
}
16+
17+
if (false === $hostName = \gethostname()) {
18+
return '127.0.0.1';
19+
}
20+
21+
return \gethostbyname($hostName);
22+
}
23+
1024
public function __construct()
1125
{
12-
parent::__construct('ip', $_SERVER['SERVER_ADDR']);
26+
parent::__construct('ip', $this->getIp());
1327
}
1428
}

0 commit comments

Comments
 (0)