PHPackages                             inbox/opentracing-bundle-core - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. inbox/opentracing-bundle-core

ActiveLibrary[HTTP &amp; Networking](/categories/http)

inbox/opentracing-bundle-core
=============================

Symfony Opentracing bundle to easily enable distributed tracing

v1.4.2(11mo ago)00MITPHPPHP ^8.1

Since May 16Pushed 11mo agoCompare

[ Source](https://github.com/INBOKSS/OpentracingBundle-core)[ Packagist](https://packagist.org/packages/inbox/opentracing-bundle-core)[ RSS](/packages/inbox-opentracing-bundle-core/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (20)Versions (3)Used By (0)

auxmoney OpentracingBundle
==========================

[](#auxmoney-opentracingbundle)

[![test](https://github.com/auxmoney/OpentracingBundle-core/workflows/test/badge.svg)](https://github.com/auxmoney/OpentracingBundle-core/actions?query=workflow%3Atest)[![GitHub release (latest SemVer)](https://camo.githubusercontent.com/fc0dfe04b4cc37dc80a8086393b2e29d5c25dad90e5a6c4f30b8cdd7537ad378/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6175786d6f6e65792f4f70656e74726163696e6742756e646c652d636f7265)](https://camo.githubusercontent.com/fc0dfe04b4cc37dc80a8086393b2e29d5c25dad90e5a6c4f30b8cdd7537ad378/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6175786d6f6e65792f4f70656e74726163696e6742756e646c652d636f7265)[![Codacy Badge](https://camo.githubusercontent.com/0a4f7522edac838d5f4d76389ce45085b399dfae83ebac764604f5966a40a17d/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f47726164652f6663303434633838643465303436616238383133626530343033326132396134)](https://camo.githubusercontent.com/0a4f7522edac838d5f4d76389ce45085b399dfae83ebac764604f5966a40a17d/68747470733a2f2f6170692e636f646163792e636f6d2f70726f6a6563742f62616467652f47726164652f6663303434633838643465303436616238383133626530343033326132396134)[![Code Climate maintainability](https://camo.githubusercontent.com/32599aa5be56b630a5f3aed2a04b50944886f003dea3cc53671fee253cf8ba2b/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f6d61696e7461696e6162696c6974792f6175786d6f6e65792f4f70656e74726163696e6742756e646c652d636f7265)](https://camo.githubusercontent.com/32599aa5be56b630a5f3aed2a04b50944886f003dea3cc53671fee253cf8ba2b/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636c696d6174652f6d61696e7461696e6162696c6974792f6175786d6f6e65792f4f70656e74726163696e6742756e646c652d636f7265)[![Scrutinizer code quality (GitHub/Bitbucket)](https://camo.githubusercontent.com/f5843879e13b6894ee33715720c9a43a55deed4701e5eb57028f4adf5c2e581d/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f7175616c6974792f672f6175786d6f6e65792f4f70656e74726163696e6742756e646c652d636f7265)](https://camo.githubusercontent.com/f5843879e13b6894ee33715720c9a43a55deed4701e5eb57028f4adf5c2e581d/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f7175616c6974792f672f6175786d6f6e65792f4f70656e74726163696e6742756e646c652d636f7265)[![GitHub](https://camo.githubusercontent.com/904be93269f07a5d7bc40b6d7da4a5ab9634e2494c93b050e2b55b2f4e5ce75b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6175786d6f6e65792f4f70656e74726163696e6742756e646c652d636f7265)](https://camo.githubusercontent.com/904be93269f07a5d7bc40b6d7da4a5ab9634e2494c93b050e2b55b2f4e5ce75b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6175786d6f6e65792f4f70656e74726163696e6742756e646c652d636f7265)

This collection of symfony bundles provides everything needed for a symfony application to enable distributed tracing.

It utilizes the [PHP implementation](https://github.com/opentracing/opentracing-php) of the [opentracing specification](https://opentracing.io/specification/)and wraps it in an opinionated fashion. It also aims to never disrupt your application, by not throwing exceptions and sending tracing data to the agent as late as possible in the Symfony lifecycle.

The core contains:

- kernel/console event subscribers to automatically instrument the application, adding useful tags to root spans
- convenience functions to create tracing spans manually, including logging messages and tagging spans
- automatic tracing header propagation for PSR-18 clients
- a convenience function for passing the tracing headers to PSR-7 requests or arrays manually

Additional bundles contain:

- [a monolog processor](https://github.com/auxmoney/OpentracingBundle-Monolog) to enrich log contexts with the current span context
- [Guzzle client](https://github.com/auxmoney/OpentracingBundle-Guzzle) automatic spanning and header propagation
- [php-http/httplug-bundle](https://github.com/auxmoney/OpentracingBundle-HttplugBundle) automatic spanning and header propagation
- [Doctrine DBAL](https://github.com/auxmoney/OpentracingBundle-Doctrine-DBAL) automatic spanning
- [amqplib/RabbitMQ](https://github.com/auxmoney/OpentracingBundle-amqplib-RabbitMq) automatic spanning and header propagation
- [eMAGTechLabs/RabbitMqBundle](https://github.com/auxmoney/OpentracingBundle-eMAGTechLabs-RabbitMqBundle) automatic spanning and header propagation

Installation
------------

[](#installation)

### Choose tracer implementation

[](#choose-tracer-implementation)

The core itself is only a library and should not be installed directly. You need to choose from different tracer implementation bundles, which will then use this library.

#### Jaeger

[](#jaeger)

- require the dependencies:

```
    composer req auxmoney/opentracing-bundle-jaeger
```

- if not done already: spin up [development jaeger instance](https://www.jaegertracing.io/docs/latest/getting-started/) (All in One)

Note: when setting up a reliable production environment, keep in mind using the agent approach, that Jaeger proposes. Especially having the jaeger agent ideally available on `localhost` will prevent you from experiencing trace or span loss due to UDP packet size limitations by the involved networks.

#### Zipkin

[](#zipkin)

- require the dependencies:

```
    composer req auxmoney/opentracing-bundle-zipkin
```

- if not done already: spin up [development zipkin instance](https://zipkin.io/pages/quickstart) (Docker)

### Enable the bundle

[](#enable-the-bundle)

If you are using [Symfony Flex](https://github.com/symfony/flex), you are all set!

If you are not using it, you need to manually enable the bundle:

- add bundle to your application:

```
    # Symfony 3: AppKernel.php
    $bundles[] = new Auxmoney\OpentracingBundle\OpentracingBundle();
```

```
    # Symfony 4+: bundles.php
    Auxmoney\OpentracingBundle\OpentracingBundle::class => ['all' => true],
```

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

[](#configuration)

You can optionally configure environment variables, however, the default configuration will run fine out of the box for a tracing agent on localhost. If you cannot change environment variables in your project, you can alternatively overwrite the container parameters directly.

environment variablecontainer parametertypedefaultdescriptionAUXMONEY\_OPENTRACING\_AGENT\_HOSTauxmoney\_opentracing.agent.host`string``localhost`hostname or IP of the agentAUXMONEY\_OPENTRACING\_AGENT\_PORTauxmoney\_opentracing.agent.port`string`(depends on the chosen tracer)port of the agentAUXMONEY\_OPENTRACING\_PROJECT\_NAMEauxmoney\_opentracing.project.name`string``basename(kernel.project_dir)`passed to the tracer as tracer name / service nameAUXMONEY\_OPENTRACING\_SAMPLER\_CLASSauxmoney\_opentracing.sampler.class`string`(depends on the chosen tracer)class of the using samplerAUXMONEY\_OPENTRACING\_SAMPLER\_VALUEauxmoney\_opentracing.sampler.value`string`(depends on the chosen tracer and sampler)must be a JSON decodable string, for the configuration of the chosen samplerAUXMONEY\_OPENTRACING\_RESPONSE\_HEADERauxmoney\_opentracing.response.header`string``true`if HTTP responses should ship the trace id as header; set to `false` (as string) to deactivateUsage
-----

[](#usage)

### Propagation of tracing headers

[](#propagation-of-tracing-headers)

For [PSR-18](https://www.php-fig.org/psr/psr-18/) compatible clients, this bundle provides automatic tracing header propagation.

For [Guzzle](https://github.com/guzzle/guzzle) clients, the [Guzzle bundle](https://github.com/auxmoney/OpentracingBundle-Guzzle) provides automatic tracing header propagation.

#### Manual propagation of tracing headers

[](#manual-propagation-of-tracing-headers)

If you use neither PSR-18 nor Guzzle, you need to inject the trace headers into every outgoing [PSR-7](https://www.php-fig.org/psr/psr-7/) compatible request. To do so, simply use

```
    Auxmoney\OpentracingBundle\Service\Tracing::injectTracingHeaders(Psr\Http\Message\RequestInterface $request): Psr\Http\Message\RequestInterface
```

on the request and use the resulting request with your favorite request client.

If you are using a request that is not PSR-7 compatible, you can inject the headers directly into an array using

```
    Auxmoney\OpentracingBundle\Service\Tracing::injectTracingHeadersIntoCarrier(array $carrier): array
```

passing the array representing the headers of your request and use the resulting array with your favorite request client.

### Automatic tracing

[](#automatic-tracing)

Out of the box, the bundle will trace some spans automatically:

- span of the kernel lifecycle (from `kernel.request` to `kernel.finish_request`)
- span of controller lifecycles (from each `kernel.controller` to each `kernel.response`, including `kernel.exception`)
- span of the command lifecycle (from `console.command` to `console.terminate`, including `console.error`)

In case of exceptions thrown, it will additionally log exception types and messages to a controller/command span.

### Manual tracing

[](#manual-tracing)

You can inject the tracing service automatically (via autowiring) or use the provided service alias `@auxmoney_opentracing`.

#### Manual spanning

[](#manual-spanning)

You can define spans manually, by using

```
    Auxmoney\OpentracingBundle\Service\Tracing::startActiveSpan(string $operationName, array $options = null): void
```

and

```
    Auxmoney\OpentracingBundle\Service\Tracing::finishActiveSpan(): void
```

respectively.

`$operationName` is the displayed name of the trace operation, `$options` is an associative array of tracing options; the main usage is `$options['tags']`, which is an associative array of user defined tags (key value pairs). See the [documentation for starting spans](https://github.com/opentracing/opentracing-php#using-startspanoptions) for more information.

#### Tagging spans

[](#tagging-spans)

You can set tags (key value pairs) to the currently active span with

```
    Auxmoney\OpentracingBundle\Service\Tracing::setTagOfActiveSpan(string $key, string|bool|int|float $value): void
```

You should respect the [span conventions of the opentracing project](https://github.com/opentracing/specification/blob/master/semantic_conventions.md#span-tags-table)when setting tags to spans.

#### Logging in spans

[](#logging-in-spans)

You can always attach logs (key value pairs) to the currently active span with

```
    Auxmoney\OpentracingBundle\Service\Tracing::logInActiveSpan(array $fields): void
```

You should respect the [log conventions of the opentracing project](https://github.com/opentracing/specification/blob/master/semantic_conventions.md#log-fields-table)when logging fields.

#### Baggage items

[](#baggage-items)

You can propagate baggage items (key value pairs) in-band across process boundaries with

```
    Auxmoney\OpentracingBundle\Service\Tracing::setBaggageItem(string $key, string $value): void
```

and retrieve them with

```
    Auxmoney\OpentracingBundle\Service\Tracing::getBaggageItem(string $key): ?string
```

You should use this feature thoughtfully and with care. Every key and value is copied into every local and remote child of the associated Span, and that can add up to a lot of network and cpu overhead.

Development
-----------

[](#development)

Be sure to run

```
    composer run-script quality
```

every time before you push code changes. The tools run by this script are also run in the CI pipeline.

Doc
---

[](#doc)

Various informations regarding the bundle and its usage is available in the [doc section](./doc/README.md).

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance53

Moderate activity, may be stable

Popularity0

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 55.2% 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 ~0 days

Total

2

Last Release

358d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/27d181e94772bccefd4043cbedf2b8a5c1e5429f316ae6868cee0aee073608a1?d=identicon)[juris.malinens](/maintainers/juris.malinens)

---

Top Contributors

[![cawolf](https://avatars.githubusercontent.com/u/1932623?v=4)](https://github.com/cawolf "cawolf (53 commits)")[![semantic-release-bot](https://avatars.githubusercontent.com/u/32174276?v=4)](https://github.com/semantic-release-bot "semantic-release-bot (29 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (3 commits)")[![filisko](https://avatars.githubusercontent.com/u/8798694?v=4)](https://github.com/filisko "filisko (3 commits)")[![jmalinens](https://avatars.githubusercontent.com/u/569039?v=4)](https://github.com/jmalinens "jmalinens (2 commits)")[![GromNaN](https://avatars.githubusercontent.com/u/400034?v=4)](https://github.com/GromNaN "GromNaN (2 commits)")[![L3tum](https://avatars.githubusercontent.com/u/9307432?v=4)](https://github.com/L3tum "L3tum (1 commits)")[![pronata](https://avatars.githubusercontent.com/u/8860770?v=4)](https://github.com/pronata "pronata (1 commits)")[![dgafka](https://avatars.githubusercontent.com/u/6060791?v=4)](https://github.com/dgafka "dgafka (1 commits)")[![ujwaldhakal](https://avatars.githubusercontent.com/u/11195862?v=4)](https://github.com/ujwaldhakal "ujwaldhakal (1 commits)")

---

Tags

symfonypsr-18GuzzlemonologSymfony Bundlejaegeropentracingzipkindistributed-tracingauxmoneyopentracing-bundle

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/inbox-opentracing-bundle-core/health.svg)

```
[![Health](https://phpackages.com/badges/inbox-opentracing-bundle-core/health.svg)](https://phpackages.com/packages/inbox-opentracing-bundle-core)
```

###  Alternatives

[auxmoney/opentracing-bundle-core

Symfony Opentracing bundle to easily enable distributed tracing

25904.4k9](/packages/auxmoney-opentracing-bundle-core)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M647](/packages/sylius-sylius)[nelmio/api-doc-bundle

Generates documentation for your REST API from attributes

2.3k63.6M232](/packages/nelmio-api-doc-bundle)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[contao/core-bundle

Contao Open Source CMS

1231.6M2.3k](/packages/contao-core-bundle)

PHPackages © 2026

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