我試圖在我的 PHP 項目中實現 OpenTracing + Jaeger,遵循“開始”示例https://github.com/jonahgeorge/jaeger-client-phpTracer、spans 和 scopes 已成功創建,但 Jaeger 沒有看到我的服務。下面有我的.php和docker-compose.yml文件:<?phprequire_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
1 回答

慕慕森
TA貢獻1856條經驗 獲得超17個贊
'reporting_host' 必須不是 'localhost',而是 'jaeger',就像在 docker-compose.yml 中調用的服務一樣。 'reporting_host' => 'jaeger',
此外,我畢竟需要添加$tracer->flush();
,它會關閉所有實體并在幕后通過 UDP 發送。
- 1 回答
- 0 關注
- 294 瀏覽
添加回答
舉報
0/150
提交
取消