Skip to content

Latest commit

 

History

History
 
 

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

Zipkin instrumentation for PSR15 HTTP Server

This component contains the instrumentation for the standard PSR15 HTTP servers.

Getting started

Before using this library, make sure the interfaces for PSR15 HTTP server are installed:

composer require psr/http-server-middleware

Usage

In this example we use fast-route and request-handler middlewares but any HTTP server middleware supporting PSR15 middlewares will work.

use Zipkin\Instrumentation\Http\Server\Psr15\Middleware as ZipkinMiddleware;
use Zipkin\Instrumentation\Http\Server\HttpServerTracing;

// Create the routing dispatcher
$fastRouteDispatcher = FastRoute\simpleDispatcher(function (FastRoute\RouteCollector $r) {
    $r->get('/hello/{name}', HelloWorldController::class);
});

// Creates tracing component
$tracing = TracingBuilder::create()
            ->havingLocalServiceName('my_service')
            ->build();

$httpClientTracing = new HttpServerTracing($tracing);

$dispatcher = new Dispatcher([
    new Middlewares\FastRoute($fastRouteDispatcher),
    // ...
    new ZipkinMiddleware($serverTracing),
    new Middlewares\RequestHandler(),
]);

$response = $dispatcher->dispatch(new ServerRequest('/hello/world'));