We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5d7a4b1 commit 0cf3b8eCopy full SHA for 0cf3b8e
src/Process/ProcessIpTag.php
@@ -1,14 +1,28 @@
1
<?php
2
-declare(strict_types=1);
+
3
+declare(strict_types = 1);
4
5
namespace Jaeger\Process;
6
7
use Jaeger\Tag\StringTag;
8
9
class ProcessIpTag extends StringTag
10
{
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
24
public function __construct()
25
- parent::__construct('ip', $_SERVER['SERVER_ADDR']);
26
+ parent::__construct('ip', $this->getIp());
27
}
28
0 commit comments