PHPackages                             lucagiardina/lara-zipkin - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Logging &amp; Monitoring](/categories/logging)
4. /
5. lucagiardina/lara-zipkin

ActiveLibrary[Logging &amp; Monitoring](/categories/logging)

lucagiardina/lara-zipkin
========================

Wrapper for openzipkin/zipkin

1.0.0(7y ago)6174[3 issues](https://github.com/luca-giardina/lara-zipkin/issues)MITPHPPHP ^7.0

Since Mar 12Pushed 7y ago2 watchersCompare

[ Source](https://github.com/luca-giardina/lara-zipkin)[ Packagist](https://packagist.org/packages/lucagiardina/lara-zipkin)[ RSS](/packages/lucagiardina-lara-zipkin/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (1)Versions (3)Used By (0)

Lara-Zipkin
===========

[](#lara-zipkin)

Wrapper for Laravel and Lumen using php-zipking

[![Latest Stable Version](https://camo.githubusercontent.com/02873b1127976ce577d0557b5507c63fcabe13de6fd6a0fb033397556800e319/68747470733a2f2f706f7365722e707567782e6f72672f6c7563616769617264696e612f6c6172612d7a69706b696e2f762f737461626c65)](https://packagist.org/packages/lucagiardina/lara-zipkin)[![Total Downloads](https://camo.githubusercontent.com/4e330367942fca6783a5b9b1cc6dd54a5d2a6c1821b6afee007b0f52eca2206c/68747470733a2f2f706f7365722e707567782e6f72672f6c7563616769617264696e612f6c6172612d7a69706b696e2f646f776e6c6f616473)](https://packagist.org/packages/lucagiardina/lara-zipkin)[![Latest Unstable Version](https://camo.githubusercontent.com/59aa23dcffd7cbd923caa4219e6bde31e4f60a58c9d1c26f91c3db89237f4792/68747470733a2f2f706f7365722e707567782e6f72672f6c7563616769617264696e612f6c6172612d7a69706b696e2f762f756e737461626c65)](https://packagist.org/packages/lucagiardina/lara-zipkin)[![License](https://camo.githubusercontent.com/eb29edcee55839ddb6351955bec0e7598908043254090736363dd6fba6c696de/68747470733a2f2f706f7365722e707567782e6f72672f6c7563616769617264696e612f6c6172612d7a69706b696e2f6c6963656e7365)](https://packagist.org/packages/lucagiardina/lara-zipkin)[![Monthly Downloads](https://camo.githubusercontent.com/347880871904ad029a8769be00b66bbe3a6eba61c56c7e68c9b01f6bead513dd/68747470733a2f2f706f7365722e707567782e6f72672f6c7563616769617264696e612f6c6172612d7a69706b696e2f642f6d6f6e74686c79)](https://packagist.org/packages/lucagiardina/lara-zipkin)[![Daily Downloads](https://camo.githubusercontent.com/cdba010536601060bd2d265221b527c3a7ff7bbb9d8889efba5cde5ef28b5626/68747470733a2f2f706f7365722e707567782e6f72672f6c7563616769617264696e612f6c6172612d7a69706b696e2f642f6461696c79)](https://packagist.org/packages/lucagiardina/lara-zipkin)

Getting Started
---------------

[](#getting-started)

In .env you should set

```
ZIPKIN_TRACING_ENABLED=true|false
ZIPKIN_ENDPOINT_NAME=Your_Project_Name
ZIPKIN_ENDPOINT_URL=http://localhost:9411/api/v2/spans

```

**Lumen Setup**

edit app.php

```
$app->register(\Giardina\LaraZipkin\LaraZipkinServiceProvider::class);

```

if you want to use the middleware to auto track requests add to $app-&gt;middleware(\[\]);

```
$app->middleware([
    \Giardina\LaraZipkin\Middleware\LaraZipkinTerminateMiddleware::class
]);

$app->routeMiddleware([
    'tracing' => \Giardina\LaraZipkin\Middleware\LaraZipkinLumenMiddleware::class,
]);

```

**Laravel Setup**

edit app.php

```
'providers' => [
    ..
    ..
    \Giardina\LaraZipkin\LaraZipkinServiceProvider::class,
],

```

if you want to use the middleware to auto track requests edit Kernel.php

```
protected $middleware = [
    ..
    ..
    \Giardina\LaraZipkin\Middleware\LaraZipkinTerminateMiddleware::class
];
protected $routeMiddleware = [
    ..
    ..
    'tracing' => \Giardina\LaraZipkin\Middleware\LaraZipkinLaravelMiddleware::class
]

```

LaraZipkinTerminateMiddleware send spans to Zipkin after the response is sent (so it doesn't affect performances)

the Middleware tracks the requests trying to create low cardinality span (ex `/route/{param}/and/{id}`)

I suggest you to give names to the routes so you will never have a problem!

N.B. if you are going to use the Middleware to create the main span and want to track the other middlewares using the LaraZipkinClient object I suggest you to add the middleware that creates the main span into the protected $middlewarePriority array:

Using the ZipkinClient object
-----------------------------

[](#using-the-zipkinclient-object)

The LaraZipkinServiceProvider creates into the app container an object:

```
app('ZipkinClient')

```

### Methods

[](#methods)

#### getNextSpan

[](#getnextspan)

This method allows you to create a main span. By default the Middleware creates a span named with the route name or with the route pattern (ex. /your/route/66) or if there is no route name nor route pattern it will use the request url.

Use this method only if you want to create a new main span and change the context or if you are not going to use the Middleware.

```
public function getNextSpan( $name = 'no-name', $kind = 'SERVER', $headers = null ) : Span

```

#### track

[](#track)

This method will create a child span into the main span named `$spanName` of the kind `$kind` if `$spanName` doesn't exists already. If `$method` is set it adds an annotation into the childspan: "$method . '\_starts'"

```
app('ZipkinClient')->track($spanName, $method, $kind = 'PRODUCER');

```

#### finishTrack

[](#finishtrack)

This method will finish the span named $spanName. If `$method` is set it adds an annotation into the childspan: `$method . '_starts'`

```
app('ZipkinClient')->finishTrack($spanName, $method = null);

```

#### trackCall

[](#trackcall)

This method will create a child span into the span named `$spanName` of the kind `$kind`. The name for the new child span will be `$callName` and it will add a note `$callName . '_starts'` to the child span If `$method` is set it adds an annotation into the childspan: "$method . '\_starts'"

```
app('ZipkinClient')->trackCall($spanName, $callName = null, $kind = 'CONSUMER');

```

#### trackEndCall

[](#trackendcall)

This method will finish the span named `$callName` into `$spanName`.

```
app('ZipkinClient')->trackEndCall($spanName, $callName);

```

#### tagBy

[](#tagby)

This method allows to add a tag to the main span in order to search by tag

```
public function tagBy($name, $value)

```

N.B.
====

[](#nb)

It's possible to use the core object itself as detailed at  using the method `public function getTracer() : Tracer`

The Middleware add Tags in the main span for:

```
app('ZipkinClient')->tagBy('x.forwarded.for', $request->ip());
app('ZipkinClient')->tagBy(Tags\HTTP_ROUTE, $request->fullUrl());
app('ZipkinClient')->tagBy(Tags\HTTP_METHOD, $request->method());
app('ZipkinClient')->tagBy('http.request', json_encode($request->all()));

app('ZipkinClient')->tagBy(Tags\HTTP_STATUS_CODE, $response->status());

```

Examples
--------

[](#examples)

Tracking another Middleware
===========================

[](#tracking-another-middleware)

```
/**
 * Handle an incoming request.
 *
 * @param  \Illuminate\Http\Request  $request
 * @param  \Closure  $next
 * @param  string|null  $guard
 * @return mixed
 */
public function handle($request, Closure $next)
{
    app('ZipkinClient')->track('Authenticate', 'handle');

    ...
    code
    ...

    app('ZipkinClient')->finishTrack('Authenticate', 'handle');

    return $next($request);
}
```

Tracking third party
====================

[](#tracking-third-party)

```
class Foo extends Bar
{
   public function foo()
   {
       app('ZipkinClient')->track('Foo', __FUNCTION__);

       ..
       code
       ..

       app('ZipkinClient')->trackCall('Foo', 'third_party->call');
       $fooService->barMethod();
       app('ZipkinClient')->trackEndCall('Foo', 'third_party->call');

       app('ZipkinClient')->finishTrack('Foo');
   }
}
```

Send propagation headers via Guzzle request
===========================================

[](#send-propagation-headers-via-guzzle-request)

```
$client = new Client();
$res = $client->request('GET', 'http://foo.com/bar', [
   'headers' => [
       'X-B3-TraceId' => (string) app('ZipkinClient')->getTraceId(),
       'X-B3-SpanId' => (string) app('ZipkinClient')->getTraceSpanId(),
       'X-B3-ParentId' => (string) app('ZipkinClient')->getTraceSpanId(),
       'X-B3-Sampled' => app('ZipkinClient')->isSampled()
   ]
]);
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~8 days

Total

2

Last Release

2610d ago

Major Versions

0.0.6 → 1.0.02019-03-20

### Community

Maintainers

![](https://www.gravatar.com/avatar/4ef589c795466231859c8b72e2f15ca247b857d89f4058ed85e196d7967824d0?d=identicon)[luca-giardina](/maintainers/luca-giardina)

---

Top Contributors

[![luca-giardina](https://avatars.githubusercontent.com/u/32329772?v=4)](https://github.com/luca-giardina "luca-giardina (9 commits)")

---

Tags

laravelzipkin

### Embed Badge

![Health badge](/badges/lucagiardina-lara-zipkin/health.svg)

```
[![Health](https://phpackages.com/badges/lucagiardina-lara-zipkin/health.svg)](https://phpackages.com/packages/lucagiardina-lara-zipkin)
```

###  Alternatives

[psr/log

Common interface for logging libraries

10.4k1.2B9.2k](/packages/psr-log)[itsgoingd/clockwork

php dev tools in your browser

5.9k27.6M94](/packages/itsgoingd-clockwork)[graylog2/gelf-php

A php implementation to send log-messages to a GELF compatible backend like Graylog2.

41838.2M138](/packages/graylog2-gelf-php)[bugsnag/bugsnag-psr-logger

Official Bugsnag PHP PSR Logger.

32132.5M2](/packages/bugsnag-bugsnag-psr-logger)[consolidation/log

Improved Psr-3 / Psr\\Log logger based on Symfony Console components.

15462.2M7](/packages/consolidation-log)[datadog/php-datadogstatsd

An extremely simple PHP datadogstatsd client

19124.6M15](/packages/datadog-php-datadogstatsd)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
