jcchavezs/zipkin-instrumentation-guzzle

Zipkin instrumentation for Guzzle HTTP Client

1.0.3 2020-05-21 08:09 UTC

This package is auto-updated.

Last update: 2020-05-21 10:04:02 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. They are not mandatory.
$tags = [
   'instance' => $_SERVER['SERVER_NAME']
];

$client = new Client([
    'handler' => Middleware\handlerStack($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,
]);