php zipkin
1.0.0
This is an unofficial PHP library for OpenZipkin.
Incomplete, only has one transport with zero integrations. This library contains a very minimal implementation for just sending spans to zipkin.
The recommended way to install PHP-Zipkin is through Composer
composer require drefined/php-zipkin
<?php
$client = new GuzzleHttpClient();
$logger = new DrefinedZipkinTransportHTTPLogger($client);
$tracer = new DrefinedZipkinTracer($logger, 1.0, true);
$endpoint = new DrefinedZipkinCoreEndpoint('127.0.0.1', 8080, 'test-trace');
$trace = new DrefinedZipkinCoreTrace($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)]
);
Add middleware and service provider in proper locations.
<?php // laravel-project/app/Http/Kernel.php
namespace AppHttp;
use ...
use DrefinedZipkinInstrumentationLaravelMiddlewareEnableZipkinTracing;
class Kernel extends HttpKernel
{
...
protected $middleware = [
...
EnableZipkinTracing::class,
];
...
}
<?php // laravel-project/config/app.php
use DrefinedZipkinInstrumentationLaravelProvidersZipkinTracingServiceProvider;
return [
...
'providers' => [
...
ZipkinTracingServiceProvider::class,
],
...
];