我尝试在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/

10-12 06:21