PHPackages                             cyberclick-tech/otel-bundle - 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. cyberclick-tech/otel-bundle

ActiveSymfony-bundle[Logging &amp; Monitoring](/categories/logging)

cyberclick-tech/otel-bundle
===========================

OpenTelemetry Symfony bundle with tracing, logging correlation, Doctrine instrumentation and Messenger middleware

0.1.0(2mo ago)0323MITPHPPHP &gt;=8.2

Since Mar 14Pushed 2mo agoCompare

[ Source](https://github.com/cyberclick-tech/otel-bundle)[ Packagist](https://packagist.org/packages/cyberclick-tech/otel-bundle)[ RSS](/packages/cyberclick-tech-otel-bundle/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (7)Dependencies (26)Versions (6)Used By (0)

cyberclick/otel-bundle
======================

[](#cyberclickotel-bundle)

Symfony bundle for OpenTelemetry instrumentation. Provides automatic tracing for HTTP requests, outgoing HTTP calls, console commands, Doctrine queries, and Symfony Messenger messages, plus log-trace correlation via Monolog.

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

[](#installation)

```
composer require cyberclick/otel-bundle
```

Register the bundle in `config/bundles.php`:

```
Cyberclick\OtelBundle\CyberclickOtelBundle::class => ['all' => true],
```

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

[](#configuration)

Set the required environment variables:

```
OTEL_SERVICE_NAME=myapp
OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4318
```

Optional:

```
OTEL_DB_INSTANCE=mydb  # Database name shown in DB spans (defaults to empty)
```

What it does out of the box
---------------------------

[](#what-it-does-out-of-the-box)

- **HTTP tracing**: Creates spans for every incoming HTTP request with `http.method`, `http.route`, `http.host`, `http.status_code`
- **Console tracing**: Creates spans for console commands with exit codes
- **Log correlation**: Injects `trace_id` and `span_id` into Monolog log records via a processor

Optional instrumentation
------------------------

[](#optional-instrumentation)

The following features require explicit configuration in your app's services:

### HTTP client tracing

[](#http-client-tracing)

Traces outgoing HTTP calls made via Symfony HttpClient. You choose which clients to instrument by decorating them in your services config:

```
# Trace ALL outgoing HTTP calls
Cyberclick\OtelBundle\HttpClient\TracingHttpClient:
    decorates: http_client
    arguments:
        $client: '@.inner'
        $tracer: '@cyberclick_otel.tracer'
```

```
# Trace only a specific scoped client
Cyberclick\OtelBundle\HttpClient\TracingHttpClient:
    decorates: http_client.catastro
    arguments:
        $client: '@.inner'
        $tracer: '@cyberclick_otel.tracer'
```

Spans are created with `http.method`, `http.url`, `http.host`, `http.status_code`.

### Doctrine tracing

[](#doctrine-tracing)

Creates spans for every SQL query with `db.system`, `db.name`, `db.statement`, `db.operation`.

If you use Doctrine's standard configuration, add the middleware to your DBAL connection:

```
doctrine:
    dbal:
        connections:
            default:
                middlewares:
                    - 'Cyberclick\OtelBundle\Doctrine\TracingMiddleware'
```

If you use a custom `EntityManagerFactory`, inject the middleware and pass it to `setMiddlewares()`:

```
use Cyberclick\OtelBundle\Doctrine\TracingMiddleware;
use Doctrine\DBAL\Driver\Middleware;

public static function create(array $parameters, ?Middleware $tracingMiddleware = null): EntityManager
{
    $dbalConfig = new \Doctrine\DBAL\Configuration();
    if ($tracingMiddleware !== null) {
        $dbalConfig->setMiddlewares([$tracingMiddleware]);
    }
    // ...
}
```

```
# services.yaml
App\EntityManagerFactory:
    arguments:
        $tracingMiddleware: '@Cyberclick\OtelBundle\Doctrine\TracingMiddleware'
```

### Messenger middleware

[](#messenger-middleware)

Traces Symfony Messenger message handling:

```
framework:
    messenger:
        buses:
            command.bus:
                middleware:
                    - cyberclick_otel.messenger.tracing_middleware
```

### Message tracer (RabbitMQ consumers)

[](#message-tracer-rabbitmq-consumers)

`MessageTracerInterface` provides manual span management for RabbitMQ consumers with automatic `forceFlush()` for long-running processes:

```
use Cyberclick\OtelBundle\Tracing\MessageTracerInterface;

final class MyConsumer
{
    public function __construct(private MessageTracerInterface $tracer) {}

    public function consume(string $queueName, string $body): void
    {
        $this->tracer->start($queueName, $body);
        $this->tracer->recordSpan('my_event', $body, 'domain_event', 'consume');

        try {
            // process message...
            $this->tracer->stopSpan('my_event');
            $this->tracer->end('OK');
        } catch (\Throwable $e) {
            $this->tracer->registerError($e);
            $this->tracer->stopSpan('my_event');
            $this->tracer->end('KO');
        }
    }
}
```

Custom span attributes
----------------------

[](#custom-span-attributes)

To add application-specific attributes to HTTP and message spans (e.g., tenant ID, user ID), implement `SpanAttributeExtractorInterface`:

```
use Cyberclick\OtelBundle\SpanAttributeExtractorInterface;
use Symfony\Component\HttpFoundation\Request;

final class MyAppSpanAttributeExtractor implements SpanAttributeExtractorInterface
{
    /**
     * Attributes added to the root HTTP span (called during kernel.controller).
     */
    public function fromRequest(Request $request): array
    {
        return [
            'enduser.id' => $request->attributes->get('authenticated_uid'),
            'tenant.id' => $request->get('tenantId'),
        ];
    }

    /**
     * Attributes added to RabbitMQ consumer spans.
     */
    public function fromMessageBody(?string $body): array
    {
        $data = json_decode($body ?? '{}');
        return [
            'tenant.id' => $data?->data?->attributes?->tenant_id ?? null,
        ];
    }
}
```

Register it in your services config to override the default (no-op) extractor:

```
Actel\Shared\Infrastructure\OpenTelemetry\MyAppSpanAttributeExtractor: ~

Cyberclick\OtelBundle\SpanAttributeExtractorInterface:
    alias: Actel\Shared\Infrastructure\OpenTelemetry\MyAppSpanAttributeExtractor
```

Service IDs
-----------

[](#service-ids)

ServiceDescription`cyberclick_otel.tracer_provider``TracerProvider` instance`cyberclick_otel.tracer``TracerInterface` instance`cyberclick_otel.messenger.tracing_middleware`Messenger middleware`Cyberclick\OtelBundle\Tracing\MessageTracerInterface`Message tracer for consumers`Cyberclick\OtelBundle\Doctrine\TracingMiddleware`Doctrine DBAL middleware`Cyberclick\OtelBundle\HttpClient\TracingHttpClient`HTTP client decorator (manual registration)Requirements
------------

[](#requirements)

- PHP &gt;= 8.2
- Symfony 7.x or 8.x
- OpenTelemetry PHP SDK

###  Health Score

39

—

LowBetter than 85% of packages

Maintenance85

Actively maintained with recent releases

Popularity16

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity40

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 ~6 days

Total

5

Last Release

79d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/2531844?v=4)[Hector Borras](/maintainers/hborras)[@hborras](https://github.com/hborras)

---

Top Contributors

[![hborras](https://avatars.githubusercontent.com/u/2531844?v=4)](https://github.com/hborras "hborras (8 commits)")

### Embed Badge

![Health badge](/badges/cyberclick-tech-otel-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/cyberclick-tech-otel-bundle/health.svg)](https://phpackages.com/packages/cyberclick-tech-otel-bundle)
```

###  Alternatives

[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.4M517](/packages/shopware-core)[sulu/sulu

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

1.3k1.4M196](/packages/sulu-sulu)[shopware/platform

The Shopware e-commerce core

3.4k1.5M3](/packages/shopware-platform)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

9317.2k55](/packages/open-dxp-opendxp)[shopware/storefront

Storefront for Shopware

674.4M209](/packages/shopware-storefront)[chameleon-system/chameleon-base

The Chameleon System core.

1027.9k4](/packages/chameleon-system-chameleon-base)

PHPackages © 2026

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