jcchavezs/zipkin-instrumentation-guzzle

Zipkin instrumentation for Guzzle HTTP Client

1.0.2 2018-11-20 13:32 UTC

README

Build Status Latest Stable Version Total Downloads License

Zipkin instrumentation for Guzzle HTTP Client.

Install

composer require jcchavezs/zipkin-instrumentation-guzzle

Usage

ZipkinGuzzle\Middleware is an Guzzle middleware that can be used along with GuzzleHttp\Client in order to create a span and propagate the context.

Default handler

use Zipkin\TracingBuilder;
use ZipkinGuzzle\Middleware;

$tracing = TracingBuilder::create()->build();

// Default tags for all spans being created.
$tags = [
   'instance' => $_SERVER['SERVER_NAME']
];

$client = new Client([
    'handler' => Middleware\handlerStack(Tracing $tracing, $tags),
]);

Custom handler

use GuzzleHttp\HandlerStack;
use Zipkin\TracingBuilder;
use ZipkinGuzzle\Middleware;

$tracing = TracingBuilder::create()->build();

$stack = HandlerStack::create();
$stack->push(Middleware\tracing($tracing));

$client = new Client([
    'handler' => $stack,
]);