PHP OpenTracing + Jaeger:服务不出现在Jaeger



我试图在我的PHP项目中实现OpenTracing + Jaeger,按照"入门"示例 https://github.com/jonahgeorge/jaeger-client-php

跟踪器、跨度和范围已成功创建,但 Jaeger 看不到我的服务。

以下是我的.phpdocker-compose.yml文件:

<?php
require_once __DIR__ . '/vendor/autoload.php';
use JaegerConfig;
use OpenTracingGlobalTracer;
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

'reporting_host' 必须不是 'localhost',而是 'jaeger',就像 docker-compose.yml 中的服务一样。'reporting_host' => 'jaeger',

另外,我需要添加$tracer->flush();毕竟,它会关闭所有实体并在幕后通过UDP进行发送。

相关内容

  • 没有找到相关文章

最新更新