我试图将OpenTracing + Jaeger实现到我的PHP项目中,遵循"Get started“示例,https://github.com/jonahgeorge/jaeger-client-php
已经成功地创建了跟踪器、跨度和作用域,但Jaeger没有看到我的服务。
下面是我的.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发布于 2019-09-18 06:36:52
'reporting_host‘必须不是'localhost',而是'jaeger',就像docker中的服务-come.yml调用的那样。'reporting_host' => 'jaeger',
另外,我需要添加$tracer->flush();,因为它关闭了所有实体,并通过UDP在幕后发送。
https://stackoverflow.com/questions/57976158
复制相似问题