php zipkin
1.0.0
这是 OpenZipkin 的非官方 PHP 库。
不完整,只有一种零集成的传输。该库包含一个非常简单的实现,用于将跨度发送到 zipkin。
推荐的安装 PHP-Zipkin 的方式是通过 Composer
composer require drefined/php-zipkin
<?php
$ client = new GuzzleHttp Client ();
$ logger = new Drefined Zipkin Transport HTTPLogger ( $ client );
$ tracer = new Drefined Zipkin Tracer ( $ logger , 1.0 , true );
$ endpoint = new Drefined Zipkin Core Endpoint ( ' 127.0.0.1 ' , 8080 , ' test-trace ' );
$ trace = new Drefined Zipkin Core Trace ( $ tracer , $ endpoint );
$ trace -> createNewSpan ( ' test-server-trace ' );
$ trace -> record (
[Annotation:: generateServerRecv ()],
[BinaryAnnotation:: generateString ( ' server.request.uri ' , ' /server ' )]
);
$ trace -> record (
[Annotation:: generateServerSend ()],
[BinaryAnnotation:: generateString ( ' server.response ' , 200 )]
);
在适当的位置添加中间件和服务提供者。
<?php // laravel-project/app/Http/Kernel.php
namespace App Http ;
use ...
use Drefined Zipkin Instrumentation Laravel Middleware EnableZipkinTracing ;
class Kernel extends HttpKernel
{
...
protected $ middleware = [
...
EnableZipkinTracing::class,
];
. . .
}
<?php // laravel-project/config/app.php
use Drefined Zipkin Instrumentation Laravel Providers ZipkinTracingServiceProvider ;
return [
...
' providers ' => [
...
ZipkinTracingServiceProvider::class,
],
...
];