PHPackages                             softinvest/opentelemetry-laravel12 - 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. softinvest/opentelemetry-laravel12

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

softinvest/opentelemetry-laravel12
==================================

This package provides a simple way to use Telemetry From OpenTelemetry Otel to your Laravel v12 application to Measure performance across jobs and services.

v1.0.0(7mo ago)03MITPHPPHP &gt;=8.3

Since Sep 28Pushed 7mo agoCompare

[ Source](https://github.com/appsinvest/laraotel-opentelemetry-laravel12)[ Packagist](https://packagist.org/packages/softinvest/opentelemetry-laravel12)[ GitHub Sponsors](https://github.com/appsinvest)[ RSS](/packages/softinvest-opentelemetry-laravel12/feed)WikiDiscussions 2.x Synced 1mo ago

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

SoftInvest OpenTelemetry Laravel Package
========================================

[](#softinvest-opentelemetry-laravel-package)

[![Total Downloads](https://camo.githubusercontent.com/4f04f9ceff2dcc7619ea5306eb864bf8da25a3ebe6e8402427aa937b38b2f37d/68747470733a2f2f706f7365722e707567782e6f72672f736f6674696e766573742f6f70656e74656c656d657472792d6c61726176656c31322f646f776e6c6f616473)](https://packagist.org/packages/softinvest/opentelemetry-laravel12)[![License](https://camo.githubusercontent.com/8ce2e914eccbb22095d075483195b60aa6295b734ce35262d3639fd57cd81c3d/68747470733a2f2f706f7365722e707567782e6f72672f736f6674696e766573742f6f70656e74656c656d657472792d6c61726176656c31322f6c6963656e7365)](https://github.com/Mahmoud-Italy/softinvest-opentelemetry-laravel12/blob/2.x/LICENSE.md)

This package provides a simple way to use Telemetry From [OpenTelemetry](https://opentelemetry.io/) OTel into your Laravel application to Measure performance across jobs and services, database queries, events etc..

Introduction
------------

[](#introduction)

[OpenTelemetry](https://opentelemetry.io/), or OTel for short, is an Observability tools designed to create and manage telemetry data such as [traces](https://opentelemetry.io/docs/concepts/signals/traces/), [metrics](https://opentelemetry.io/docs/concepts/signals/metrics/) and [logs](https://opentelemetry.io/docs/concepts/signals/logs/), to collect information on how your entire system is behaving.

You can easily measure performance of a Laravel powered system. It can transmit the results to a tracing tool like Jaeger, Zipkin Or you can export data into Console, Json, text etc..

Bundle Zipkin and Jaeger into your Application
----------------------------------------------

[](#bundle-zipkin-and-jaeger-into-your-application)

To visualize traces exported from our application, we need to integrate open source tracing tools [Zipkin](https://zipkin.io/) and [Jaeger](https://www.jaegertracing.io/) into our setup using docker.

First, we create a `docker-compose.yaml` file in the root of our project, with content as follows:

```
version: '3.7'
services:
    zipkin:
        image: openzipkin/zipkin-slim
        ports:
            - "9411:9411"
    jaeger:
        image: jaegertracing/all-in-one
        environment:
            COLLECTOR_ZIPKIN_HOST_PORT: 9412

        ports:
            - "9412:9412"
            - "16686:16686"
```

Next, we pull in Zipkin and Jaeger by running `docker-compose up -d`.

We can confirm that Zipkin is up by navigating to `http://localhost:9411/` on our browser. For Jaeger, navigating to `http://localhost:16686/` on our browser should display the Jaeger home page.

[![softinvest](assets/jaeger.png)](assets/jaeger.png)[![softinvest](assets/zipkin.png)](assets/zipkin.png)

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

[](#installation)

You can install the package via composer:

```
composer require softinvest/opentelemetry-laravel12
```

***Important Note: The [opentelemetry extension](https://opentelemetry.io/docs/zero-code/php/) must be enabled on your machine.***

Usage
-----

[](#usage)

### Configuration

[](#configuration)

Publish the configuration file:

```
php artisan vendor:publish --provider="SoftInvest\OpenTelemetryLaravel\OpenTelemetryServiceProvider" --tag="config"
```

### Update the environment variables

[](#update-the-environment-variables)

You can find them in configuration file: `config/otel.php`.

### Register the middleware

[](#register-the-middleware)

you can register the middleware in the `app/Http/Kernel.php`:

```
protected $middleware = [
    \SoftInvest\OpenTelemetryLaravel\Middlewares\MeasureRequest::class,
    // ...
];
```

In laravel 11 you can not register in the kernel.php the middlewares anymore. You can register your global middleware in `bootstrap/app.php`

```
->withMiddleware(function (Middleware $middleware) {
    $middleware->append(\SoftInvest\OpenTelemetryLaravel\Middlewares\MeasureRequest::class);
})
```

or you can set the env variable `OTEL_AUTO_TRACE_REQUESTS` to `true` to enable it automatically.

### Watchers

[](#watchers)

This package provides some watchers to help you trace your application:

- `SoftInvest\OpenTelemetryLaravel\Watchers\AuthenticateWatcher` to trace authentications.
- `SoftInvest\OpenTelemetryLaravel\Watchers\CacheWatcher` to trace cache operations.
- `SoftInvest\OpenTelemetryLaravel\Watchers\DatabaseQueryWatcher` to trace database queries.
- `SoftInvest\OpenTelemetryLaravel\Watchers\QueueWatcher` to trace job execution.
- `SoftInvest\OpenTelemetryLaravel\Watchers\RedisWatcher` to trace redis operations.
- `SoftInvest\OpenTelemetryLaravel\Watchers\EventWatcher` to trace event opearations.
- `SoftInvest\OpenTelemetryLaravel\Watchers\HttpClientWatcher` to trace http client requests.
- `SoftInvest\OpenTelemetryLaravel\Watchers\LogWatcher` to trace log operations.

You can enable or disable them in the configuration file: `config/otel.php`.

### Custom span

[](#custom-span)

You can create a custom span by using the `SoftInvest\OpenTelemetryLaravel\Facades\Measure` facade:

```
use SoftInvest\OpenTelemetryLaravel\Facades\Measure;

Measure::span('my-web-request')->measure(function() {
    // ...
});
```

or manually start and end a span:

```
Measure::start('my-web-request');

// ...

Measure::end();
```

and you can modify the span attributes by using a closure:

```
Measure::start('my-web-request', function($span) {
    $span->setAttribute('key', 'value');
    // ...
});

// ...
Measure::end();
```

of course, you can get the span instance by using the `Measure::span()` method:

```
$span = Measure::span('my-web-request');
$span->setAttribute('key', 'value');
$scope = $span->activate();

// ...

$span->end();
$scope->detach();
```

[![softinvest](assets/jaeger-result.png)](assets/jaeger-result.png)[![softinvest](assets/zipkin-result.png)](assets/zipkin-result.png)[![softinvest](assets/log-json.png)](assets/log-json.png)

Available Drivers
-----------------

[](#available-drivers)

```
'default' => env('OTEL_DEFAULT_TRACER', 'log'),

# available drivers: `console`, `log`, `text`, `zipkin`, `http-json`, `http-binary`, `grpc`.
'tracers' => [
    'console' => [
        'driver' => 'console',
        'transport' => 'stream',
        'span_exporter' => 'console',
    ],

    'log' => [
        'driver' => 'log',
        'transport' => 'stream',
        'span_exporter' => 'console',
        'endpoint' => storage_path('logs/otel.log'),
    ],

    'text' => [
        'driver' => 'text',
        'transport' => 'stream',
        'endpoint' => storage_path('logs/otel.text'),
    ],

    'zipkin' => [
        'driver' => 'zipkin',
        'transport' => 'http',
        'span_exporter' => 'otlp',
        'endpoint' => env('OTEL_EXPORTER_ZIPKIN_ENDPOINT', 'http://zipkin:9411/api/v2/spans'),
        'content_type' => 'application/json',
    ],

    'http-json' => [
        'driver' => 'http-json',
        'transport' => 'http',
        'span_exporter' => 'otlp',
        'endpoint' => env('OTEL_HTTP_JSON_ENDPOINT', 'http://localhost:9411/v1/traces'),
        'content_type' => 'application/json',
    ],

    'http-binary' => [
        'driver' => 'http-binary',
        'transport' => 'http',
        'span_exporter' => 'otlp',
        'endpoint' => env('OTEL_HTTP_BINARY_ENDPOINT', 'http://localhost:4318/v1/traces'),
        'content_type' => 'application/x-protobuf',
    ],
],
```

Available Logs Level
--------------------

[](#available-logs-level)

```
use SoftInvest\OpenTelemetryLaravel\Facades\Logger;

Logger::debug('my log message');
Logger::info('my log message');
Logger::warning('my log message');
Logger::error('my log message');
```

UML Diagram of the package design
---------------------------------

[](#uml-diagram-of-the-package-design)

[![softinvest](assets/openTelemetry-collectors-Diagram.drawio.png)](assets/openTelemetry-collectors-Diagram.drawio.png)

Testing
-------

[](#testing)

```
composer test
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance63

Regular maintenance activity

Popularity3

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 95.4% 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

227d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3435693ce772ee50f22731e0f2031eaa6804789e6583ee0467f5b669d2919770?d=identicon)[softinvest](/maintainers/softinvest)

---

Top Contributors

[![Mahmoud-Italy](https://avatars.githubusercontent.com/u/17962343?v=4)](https://github.com/Mahmoud-Italy "Mahmoud-Italy (62 commits)")[![bugfix666](https://avatars.githubusercontent.com/u/151177991?v=4)](https://github.com/bugfix666 "bugfix666 (1 commits)")[![maltf0](https://avatars.githubusercontent.com/u/30283943?v=4)](https://github.com/maltf0 "maltf0 (1 commits)")[![reindert-vetter](https://avatars.githubusercontent.com/u/16726304?v=4)](https://github.com/reindert-vetter "reindert-vetter (1 commits)")

---

Tags

softinvest-opentelemetry-laravel12

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/softinvest-opentelemetry-laravel12/health.svg)

```
[![Health](https://phpackages.com/badges/softinvest-opentelemetry-laravel12/health.svg)](https://phpackages.com/packages/softinvest-opentelemetry-laravel12)
```

###  Alternatives

[keepsuit/laravel-opentelemetry

OpenTelemetry integration for laravel

142347.8k](/packages/keepsuit-laravel-opentelemetry)[laraotel/opentelemetry-laravel

This package provides a simple way to use Telemetry From OpenTelemetry Otel to your Laravel application to Measure performance across jobs and services.

822.4k](/packages/laraotel-opentelemetry-laravel)[open-telemetry/symfony-sdk-bundle

OpenTelemetry Symfony integration

1182.6k4](/packages/open-telemetry-symfony-sdk-bundle)

PHPackages © 2026

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