gpt4 book ai didi

php - PHP OpenTracing + Jaeger:Jaeger中未显示服务

转载 作者:行者123 更新时间:2023-12-02 19:23:43 25 4
gpt4 key购买 nike

我尝试在PHP项目中实现OpenTracing + Jaeger,遵循https://github.com/jonahgeorge/jaeger-client-php的“入门”示例

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

以下是我的.phpdocker-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

最佳答案

就像在docker-compose.yml中调用的服务一样,“reporting_host”必须不是“localhost”,而不能是“jaeger”。'reporting_host' => 'jaeger',
另外,我毕竟需要添加$tracer->flush();,它关闭所有实体,并在后台通过UDP发送。

关于php - PHP OpenTracing + Jaeger:Jaeger中未显示服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57976158/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com