我尝试将 OpenTracing + Jaeger 应用于我的 PHP 项目,并按照此处的 "入门" 示例进行操作 https://github.com/jonahgeorge/jaeger-client-php。跟踪器、跨度和作用域已成功创建,但是 Jaeger 没有看到我的服务。
下面是我的 .php 和 docker-compose.yml 文件:
下面是我的 .php 和 docker-compose.yml 文件:
<?php
require_once __DIR__ . '/vendor/autoload.php';
use Jaeger\Config;
use OpenTracing\GlobalTracer;
class OpenTracing
{
public function __construct()
{
$config = new Config(
[
'sampler' => [
'type' => 'const',
'param' => true,
],
'logging' => true,
'local_agent' => [
'reporting_host' => 'localhost',
'reporting_port' => 5775
]
],
'test.service'
);
$config->initializeTracer();
$tracer = GlobalTracer::get();
$parent = $tracer->startActiveSpan('parent');
sleep(1);
$child = $tracer->startActiveSpan('child');
$child->close();
sleep(3);
$parent->close();
}
}
version: '3'
services:
jaeger:
image: jaegertracing/all-in-one:1.6
container_name: as-jaeger
ports:
- "5775:5775/udp"
- "6831:6831/udp"
- "6832:6832/udp"
- "5778:5778"
- "16686:16686"
- "14268:14268"
- "9411:9411"
environment:
- COLLECTOR_ZIPKIN_HTTP_PORT=9411