我试图在我的 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 关注
- 264 浏览
添加回答
举报
0/150
提交
取消