-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSpanExporterFactory.php
More file actions
31 lines (22 loc) · 901 Bytes
/
SpanExporterFactory.php
File metadata and controls
31 lines (22 loc) · 901 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
declare(strict_types=1);
namespace Instana;
use OpenTelemetry\SDK\Trace\SpanExporter\SpanExporterFactoryInterface;
use OpenTelemetry\SDK\Trace\SpanExporterInterface;
class SpanExporterFactory implements SpanExporterFactoryInterface
{
const DEFAULT_INSTANA_AGENT_HOST = '127.0.0.1';
const DEFAULT_INSTANA_AGENT_PORT = '42699';
public function create(): SpanExporterInterface
{
$host = $_SERVER['INSTANA_AGENT_HOST'] ?? self::DEFAULT_INSTANA_AGENT_HOST;
$port = $_SERVER['INSTANA_AGENT_PORT'] ?? self::DEFAULT_INSTANA_AGENT_PORT;
$endpoint = $host . ':' . $port;
$timeout = 10; //s
$transport = new InstanaTransport($endpoint, $timeout);
$uuid = $transport->getUuid();
$pid = $transport->getPid();
$converter = new SpanConverter($uuid, $pid);
return new SpanExporter($transport, $converter);
}
}