PHPackages                             shifudeen/elastic-apm-laravel - 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. shifudeen/elastic-apm-laravel

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

shifudeen/elastic-apm-laravel
=============================

Laravel APM agent for Elastic v2 intake API

v1.5.1(6y ago)011MITPHPPHP &gt;=7.1

Since Dec 30Pushed 6y agoCompare

[ Source](https://github.com/shifudeen/elastic-apm-laravel)[ Packagist](https://packagist.org/packages/shifudeen/elastic-apm-laravel)[ RSS](/packages/shifudeen-elastic-apm-laravel/feed)WikiDiscussions master Synced yesterday

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

Elastic APM
===========

[](#elastic-apm)

[![CircleCI](https://camo.githubusercontent.com/8441cf71ac47ee89d430ca24cb48c54f48aa1a44686beffa413d4635423c5de1/68747470733a2f2f636972636c6563692e636f6d2f67682f61726b6169747a676172726f2f656c61737469632d61706d2d6c61726176656c2e7376673f7374796c653d737667)](https://circleci.com/gh/arkaitzgarro/elastic-apm-laravel)[![Latest Stable Version](https://camo.githubusercontent.com/80fdc82fb2e8167c781710d2cd3df10d8ba3bba4e1115dbeec3bf203cb777b64/68747470733a2f2f706f7365722e707567782e6f72672f61726b6169747a676172726f2f656c61737469632d61706d2d6c61726176656c2f762f737461626c65)](https://packagist.org/packages/shifudeen/elastic-apm-laravel)[![License](https://camo.githubusercontent.com/65e7a118abe2725633459852ed92de4b8d803d654c3ec56724d191bef43c8a5d/68747470733a2f2f706f7365722e707567782e6f72672f61726b6169747a676172726f2f656c61737469632d61706d2d6c61726176656c2f6c6963656e7365)](https://packagist.org/packages/shifudeen/elastic-apm-laravel)

Elastic APM agent for v2 intake API. Compatible with Laravel 5.5+.

Transactions listTransaction detail[![](public/apm-transaction-list.png)](public/apm-transaction-list.png)[![](public/apm-transaction-detail.png)](public/apm-transaction-detail.png)Installation
------------

[](#installation)

Require this package with composer:

```
composer require shifudeen/elastic-apm-laravel

```

Add the ServiceProvider class to the providers array in `config/app.php`:

```
'providers' => [
    // ... more providers
    \AG\ElasticApmLaravel\ServiceProvider::class,
],
```

From here, we will take care of everything based on your configuration. The agent and the middleware will be registered, and transactions will be sent to Elastic.

Agent configuration
-------------------

[](#agent-configuration)

The following environment variables are supported in the default configuration:

VariableDescriptionAPM\_ACTIVE`true` or `false` defaults to `true`. If `false`, the agent will collect, but not send, transaction data; span collection will also be disabled.APM\_ACTIVE\_CLI`true` or `false` defaults to `true`. If `false`, the agent will not collect or send transaction or span data for non-HTTP requests but HTTP requests will still follow APM\_ACTIVE. When APM\_ACTIVE is `false`, this will have no effect.APM\_APPNAMEName of the app as it will appear in APM. Invalid special characters will be replaced with a hyphen.APM\_APPVERSIONVersion of the app as it will appear in APM.APM\_SERVERURLURL to the APM intake service.APM\_SECRETTOKENSecret token, if required.APM\_USEROUTEURI`true` or `false` defaults to `true`. The default behavior is to record the URL as defined in your routes configuration. Set to `false` to record the requested URL, but keep in mind that this can result in excessive unique entries in APM.APM\_IGNORE\_PATTERNSIgnore specific routes or jobs by transaction name. Should be a regular expression, and will match multiple patterns via pipe `|` in the regex. Note that 4 backslashes should be used to match a single backslash. Example: `"/\/health-check|^OPTIONS |Foo\\\\Bar\\\\Job/"`APM\_QUERYLOG`true` or `false` defaults to 'true'. Set to `false` to completely disable query logging, or to `auto` if you would like to use the threshold feature.APM\_THRESHOLDQuery threshold in milliseconds, defaults to `200`. If a query takes longer then 200ms, we enable the query log. Make sure you set `APM_QUERYLOG=auto`.APM\_BACKTRACEDEPTHDefaults to `25`. Depth of backtrace in query span.APM\_MAXTRACEITEMSDefaults to `1000`. Max number of child items displayed when viewing trace details.You may also publish the `elastic-apm-laravel.php` configuration file to change additional settings:

```
php artisan vendor:publish --tag=config
```

Once published, open the `config/elastic-apm-laravel.php` file and review the various settings.

Collectors
----------

[](#collectors)

The default collectors typically listen on events to measure portions of the request such as framework loading, database queries, or jobs.

The SpanCollector in particular allows you to measure any section of your own code via the `ApmCollector` Facade:

```
use AG\ElasticApmLaravel\Facades\ApmCollector;

ApmCollector::startMeasure('my-custom-span', 'custom', 'measure', 'My custom span');

// do something amazing

ApmCollector::stopMeasure('my-custom-span');
```

To record an additional span around your job execution, you may include the provided job middleware (Laravel 6+ only ):

```
public function middleware()
{
    return [
        app(\AG\ElasticApmLaravel\Jobs\Middleware\RecordTransaction::class),
    ];
}
```

### Add a collector for other events

[](#add-a-collector-for-other-events)

You can add extra collector(s) to listen to your own application events or Laravel events like `Illuminate\Mail\Events\MessageSending` for example. We created a base collector that already includes functionality to measure events, that you can extend from:

```
// app/Collectors/MailMessageCollector.php

namespace YourApp\Collectors;

use AG\ElasticApmLaravel\Contracts\DataCollector;
use AG\ElasticApmLaravel\Collectors\EventDataCollector;

use Illuminate\Mail\Events\MessageSending;
use Illuminate\Mail\Events\MessageSent;

class MailMessageCollector extends EventDataCollector implements DataCollector
{
    public function getName(): string
    {
        return 'mail-message-collector';
    }

    protected function registerEventListeners(): void
    {
        $this->app->events->listen(MessageSending::class, function (\Swift_Message $message) {
            $this->startMeasure(
                'mail #' . $message->getId(),
                'mail.delivery',
            );
        });

        $this->app->events->listen(MessageSent::class, function (\Swift_Message $message) {
            $this->stopMeasure('mail #' . $message->getId());
        });
    }
}
```

Don't forget to register your collector when the application starts:

```
// app/Providers/AppServiceProvider.php

use AG\ElasticApmLaravel\Facades\ApmCollector;

use YourApp\Collectors\MailMessageCollector;

public function boot()
{
    // ...
    ApmCollector::addCollector(MailMessageCollector::class);
}
```

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

[](#development)

Get Composer. Follow the instructions defined on the official [Composer page](https://getcomposer.org/doc/00-intro.md), or if you are using `homebrew`, just run:

```
brew install composer
```

Install project dependencies:

```
composer install
```

Run the unit test suite:

```
php vendor/bin/codecept run unit
```

Please adhere to [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md) and [Symfony](https://symfony.com/doc/current/contributing/code/standards.html) coding standard. Run the following commands before pushing your code:

```
php ./vendor/bin/php-cs-fixer fix --config .php_cs
```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

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

15

Last Release

2210d ago

PHP version history (2 changes)v1.0.0PHP &gt;=7.3

v1.5.1PHP &gt;=7.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/8624678?v=4)[Saifuddin Nair](/maintainers/shifudeen)[@shifudeen](https://github.com/shifudeen)

---

Top Contributors

[![arkaitzgarro](https://avatars.githubusercontent.com/u/1712467?v=4)](https://github.com/arkaitzgarro "arkaitzgarro (25 commits)")[![cykirsch](https://avatars.githubusercontent.com/u/8845299?v=4)](https://github.com/cykirsch "cykirsch (9 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (9 commits)")[![shifudeen](https://avatars.githubusercontent.com/u/8624678?v=4)](https://github.com/shifudeen "shifudeen (4 commits)")[![countless-integers](https://avatars.githubusercontent.com/u/2060726?v=4)](https://github.com/countless-integers "countless-integers (2 commits)")

---

Tags

laravelapmelastic

###  Code Quality

TestsCodeception

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/shifudeen-elastic-apm-laravel/health.svg)

```
[![Health](https://phpackages.com/badges/shifudeen-elastic-apm-laravel/health.svg)](https://phpackages.com/packages/shifudeen-elastic-apm-laravel)
```

###  Alternatives

[arkaitzgarro/elastic-apm-laravel

Laravel APM agent for Elastic v2 intake API

84433.6k](/packages/arkaitzgarro-elastic-apm-laravel)[yadahan/laravel-authentication-log

Laravel Authentication Log provides authentication logger and notification for Laravel.

416632.8k5](/packages/yadahan-laravel-authentication-log)[masterro/laravel-mail-viewer

Easily view in browser outgoing emails.

6392.1k](/packages/masterro-laravel-mail-viewer)[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)[hryha/laravel-request-logger

A Laravel package to log requests and responses

102.2k](/packages/hryha-laravel-request-logger)

PHPackages © 2026

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