PHPackages                             dipenduroy/lumenzipkin - 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. [Debugging &amp; Profiling](/categories/debugging)
4. /
5. dipenduroy/lumenzipkin

ActiveLibrary[Debugging &amp; Profiling](/categories/debugging)

dipenduroy/lumenzipkin
======================

Distributed tracing for lumen using Zipkin

v1.0(5y ago)022MITPHP

Since Dec 2Pushed 5y ago1 watchersCompare

[ Source](https://github.com/Dipenduroy/lumen-zipkin)[ Packagist](https://packagist.org/packages/dipenduroy/lumenzipkin)[ Docs](https://github.com/dipenduroy/lumen-zipkin)[ RSS](/packages/dipenduroy-lumenzipkin/feed)WikiDiscussions main Synced today

READMEChangelog (1)Dependencies (2)Versions (2)Used By (0)

Distributed Tracing using Zipkin in Lumen framework
===================================================

[](#distributed-tracing-using-zipkin-in-lumen-framework)

[![Latest Stable Version](https://camo.githubusercontent.com/d33f2ffb68b7f1f0f254e66adfa9122a7dc9bab25a3c37e1565ae83945c49526/68747470733a2f2f706f7365722e707567782e6f72672f646970656e6475726f792f6c756d656e7a69706b696e2f762f737461626c65)](https://packagist.org/packages/dipenduroy/lumenzipkin)[![Total Downloads](https://camo.githubusercontent.com/2812ed841bdb3674d9d6f1a0fb0ba0114fcd5103cd8a77722d74fd9612187959/68747470733a2f2f706f7365722e707567782e6f72672f646970656e6475726f792f6c756d656e7a69706b696e2f646f776e6c6f616473)](https://packagist.org/packages/dipenduroy/lumenzipkin)[![License](https://camo.githubusercontent.com/52b676a6b8a11b40acf9baebef6cd86e51c3a4ddc823f3fd71291ee0189e2a42/68747470733a2f2f706f7365722e707567782e6f72672f646970656e6475726f792f6c756d656e7a69706b696e2f6c6963656e7365)](https://packagist.org/packages/dipenduroy/lumenzipkin)

Distributed Tracing of Guzzle HTTP Client (Micro Services internal calls) and dynamic profiling in Lumen

Contents
--------

[](#contents)

- [Distributed Tracing using Zipkin in Lumen framework](#Distributed-Tracing-using-Zipkin-in-Lumen-framework)
    - [Prerequisites](#prerequisites)
    - [Install](#install)
    - [Register LumenZipkinServiceProvider](#Register-LumenZipkinServiceProvider)
    - [Register ZipkinTraceMiddleware](#Register-ZipkinTraceMiddleware)
    - [Start Zipkin Server](#Start-Zipkin-Server)
    - [Usage](#Usage)
    - [Configuration](#Configuration)
    - [Running with a custom zipkin location](#Running-with-a-custom-zipkin-location)
    - [References](#references)

Prerequisites
-------------

[](#prerequisites)

- [Composer](https://getcomposer.org/doc/00-intro.md#installation-linux-unix-osx)
- [Docker](https://docs.docker.com/engine/installation/) (optional, if you have a zipkin endpoint this is not needed)

Install
-------

[](#install)

```
composer require dipenduroy/lumenzipkin
```

Register LumenZipkinServiceProvider
-----------------------------------

[](#register-lumenzipkinserviceprovider)

To enable Lumen Zipkin library, add below in bootstrap/app.php

```
$app->register(DipenduRoy\LumenZipkin\LumenZipkinServiceProvider::class);

```

Register ZipkinTraceMiddleware
------------------------------

[](#register-zipkintracemiddleware)

To automatically flush all the traces to zipkin server while script ends. This is required to push trace info to zipkin server.

Add **DipenduRoy\\LumenZipkin\\ZipkinTraceMiddleware::class** in middleware's list of bootstrap/app.php, If no middleware

```
$app->middleware([
    DipenduRoy\LumenZipkin\ZipkinTraceMiddleware::class
]);

```

Start Zipkin Server
-------------------

[](#start-zipkin-server)

Use Docker to start Zipkin Server

```
composer run-zipkin
```

Usage
-----

[](#usage)

Below example traces all guzzle calls between microservices. Similarly refer [zipkin-php](https://github.com/openzipkin/zipkin-php#local-tracing) for more customized tracing

```
	//Set your application variables below
	$baseUri='http://local.app/';
	$method='POST';
	$requestUrl='example/url';
	$queryString='?filter=category';
	$formParams=[];

	//Get Zipkin Trace Object
	$ZipkinTrace=app('Trace\ZipkinTrace');

	/* Creates the span for getting the guzzle client call */
    $childSpan = $ZipkinTrace->createChildClientSpan($baseUri);

    //Tags can be configured as per your requirement for filtering the requests from zipkin dashboard
    $childSpan->tag(\Zipkin\Tags\HTTP_HOST, $baseUri);
    $childSpan->tag(\Zipkin\Tags\HTTP_URL, $baseUri.$requestUrl);
    $childSpan->tag(\Zipkin\Tags\HTTP_PATH, $requestUrl);
    $childSpan->tag(\Zipkin\Tags\HTTP_METHOD, strtoupper($method));

	$childSpan->annotate('request_started', \Zipkin\Timestamp\now());
    $client = new \GuzzleHttp\Client([
            'base_uri'  =>  $baseUri,
        ]);
    $headers['accept'] = "application/json";
    $headers=array_merge($headers,$ZipkinTrace->getHeaders());
    $params=[
            'form_params' => $formParams,
            'headers'     => $headers,
            'query' => $queryString,
        ];
    try {
        $response = $client->request($method, $requestUrl, $params);
    } catch (\GuzzleHttp\Exception\TransferException $e) {
        $response = $e->getResponse();
        if ($e->hasResponse()) {
            $responseString = $e->getResponse()->getBody(true);
        } else {
            $childSpan->tag(\Zipkin\Tags\HTTP_STATUS_CODE, 503);
            $childSpan->tag(\Zipkin\Tags\ERROR, 'Guzzle Transfer Exception');
            $childSpan->annotate('request_failed', \Zipkin\Timestamp\now());
        }
    }
    $childSpan->tag(\Zipkin\Tags\HTTP_STATUS_CODE, $response->getStatusCode());
    $childSpan->annotate('request_finished', \Zipkin\Timestamp\now());

```

Configuration
-------------

[](#configuration)

Set below environment variable as required

**APP\_NAME** Environment variable is used for root trace name

**LUMEN\_ZIPKIN\_ENABLE\_SERVER\_ADDRESS** Environment variable is used to enable server address if available

Running with a custom zipkin location
-------------------------------------

[](#running-with-a-custom-zipkin-location)

If you need to pass the zipkin endpoint, just pass the reporter url as `HTTP_REPORTER_URL` env variable. Default zipkin location is - ****

```
HTTP_REPORTER_URL=http://myzipkin:9411/api/v2/span composer run-frontend
```

References
----------

[](#references)

Thanks to the below contributors

1. This library uses Zipkin PHP Library, [refer for more details](https://github.com/openzipkin/zipkin-php)
2. Know Zipkin [in detail](https://zipkin.io)
3. [Zipkin PHP Example](https://github.com/openzipkin/zipkin-php-example)

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

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

Unknown

Total

1

Last Release

2039d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5229482?v=4)[Dipendu Roy](/maintainers/dipenduroy)[@Dipenduroy](https://github.com/Dipenduroy)

---

Top Contributors

[![Dipenduroy](https://avatars.githubusercontent.com/u/5229482?v=4)](https://github.com/Dipenduroy "Dipenduroy (9 commits)")

---

Tags

phplumentracingdistributedzipkin

### Embed Badge

![Health badge](/badges/dipenduroy-lumenzipkin/health.svg)

```
[![Health](https://phpackages.com/badges/dipenduroy-lumenzipkin/health.svg)](https://phpackages.com/packages/dipenduroy-lumenzipkin)
```

###  Alternatives

[barryvdh/laravel-debugbar

PHP Debugbar integration for Laravel

19.3k133.0M757](/packages/barryvdh-laravel-debugbar)[datadog/dd-trace

PHP APM Client

52122.6M15](/packages/datadog-dd-trace)[glushkovds/phpclickhouse-laravel

Adapter of the most popular library https://github.com/smi2/phpClickHouse to Laravel

2051.5M2](/packages/glushkovds-phpclickhouse-laravel)

PHPackages © 2026

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