PHPackages                             umbrellio/event-tracker - 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. umbrellio/event-tracker

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

umbrellio/event-tracker
=======================

2.0.3(3mo ago)220.5k↓33%1PHPPHP &gt;=7.4CI failing

Since Feb 7Pushed 3mo ago5 watchersCompare

[ Source](https://github.com/umbrellio/event-tracker)[ Packagist](https://packagist.org/packages/umbrellio/event-tracker)[ RSS](/packages/umbrellio-event-tracker/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (15)Used By (0)

Event tracker
=============

[](#event-tracker)

Package for tracking any custom events and logging them to influxdb or prometheus in Laravel framework.

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

[](#installation)

- Install

```
composer require umbrellio/event-tracker
```

Features
--------

[](#features)

- Out of box it has few ready trackers:
    - Response time - middleware for logging response-time of different endpoints
    - Jobs duration - set of listeners for logging execution time of all jobs
    - Jobs log - set of listeners for logging all executed jobs
- Log anything you want by multipurpose classes - EventRepository and PrometheusRepository
- Log into influxdb directly or by telegraf
- Prometheus support
- Application metrics exporter

Known issues
------------

[](#known-issues)

- Prometheus integration. If your app deployed to kubernetes and it has more than one pod, where Prometheus gets metrics, then your metrics will be doubled. The reason it happens is one storage for metrics (Redis). Prometheus requests metrics from every fpm pod and they give same metrics, which prometheus sums up.

Integration
-----------

[](#integration)

### General

[](#general)

1. Execute `php artisan vendor:publish` for publishing config example in your `config` directory
2. Write your credentials and settings in config. If you don't need some connections or trackers you can delete them.

### Prometheus

[](#prometheus)

Each instances of your application must have own storage for your metrics. You cannot use shared storage with several replicas of your application. In that case scraping will return metrics for both the current replica and other replicas.

You could still use shared storage if you have only one fpm replica.

In distributed systems like Kubernetes probably your application is likely running in multiple instances and in different modes (fpm, horizon). Each of them produces metrics and each of them has to be monitored by Prometheus. The exporter provided by this package will solve mentioned above problem. Correct setup should include:

- Each replica has its own (local) redis instance to store metrics
- Each replica has its own exporter which exposes `/metrics`-endpoint and grabs metrics from the redis instance. The provided exporter is available: [event-tracker/exporter](ghcr.io/umbrellio/event-tracker/exporter:latest)
- Application writes metrics to that local redis instance
- `event_tracker.php` config has correct credentials for local redis

```
return [
    'connection' => 'prometheus',
    'connections' => [
        'prometheus' => [
            'redis' => [
                'client' => env('EVENT_TRACKER_REDIS_CLIENT', 'phpredis'),
                'credentials' => [
                    'host' => env('EVENT_TRACKER_REDIS_HOST', 'localhost'),
                    'username' => env('EVENT_TRACKER_REDIS_USERNAME', 'redis'),
                    'password' => env('EVENT_TRACKER_REDIS_PASSWORD'),
                    'port' => env('EVENT_TRACKER_REDIS_PORT', '6379'),
                    'database' => env('EVENT_TRACKER_REDIS_DATABASE', 0),
                ],
            ],
        ],
    ],
];
```

Trackers
--------

[](#trackers)

### Response time tracker

[](#response-time-tracker)

This tracker collects information about time, that your application spends for handle request on different endpoints.

All you need for integrate this tracker is include a middleware - `ResponseTimeTrackerMiddleware` in your route's list. This middleware has to be last one in your routes. Use Laravel's feature

- [Sorting middleware](https://laravel.com/docs/9.x/middleware#sorting-middleware).

> **Influx**
>
> Records have follow format: `app_prefix.response_time,action=ExampleController@index val=1608201916"`, where `url` is tag's name, and val is field's name.

> **Prometheus**
>
> - Buckets can be configured in config
> - Metrics have follow format: app\_prefix\_response\_time\_bucket{namespace="app-nc",action="ExampleController@index",le="1"} 1

You can change measurement name instead of 'response\_time' in config at `trackers` block. All trackers have this opportunity.

### Jobs duration tracker

[](#jobs-duration-tracker)

This one collects metrics about duration time of jobs in your application.

> **Influx**
>
> This tracker will write records in follow format: `app_prefix.jobs_duration,jobName=App\Example\JobName val=160820191`.

> **Prometheus**
>
> - Buckets can be configured in config
> - Metrics have follow format: app\_prefix\_jobs\_duration\_bucket{namespace="app-ns",jobName="App\\Jobs\\JobName",le="1"} 2

This tracker allows you to skip any jobs, you don't want to track via config.

### Jobs log

[](#jobs-log)

This one collects information about amount of each kind of jobs in application.

> **Influx**
>
> Format of writing will be: `app_prefix.jobs_log,event=processing,jobName=App\Example\JobName`

> **Prometheus**
>
> Metrics have follow format: app\_prefix\_jobs\_log{namespace="app-ns",jobName="App\\Jobs\\JobName",eventName="processed"} 2

You can skip any jobs similarly like in previous tracker.

### External api response

[](#external-api-response)

This one collects information about requests, that your application sends to external apis.

For integrate this tracker you need create all GuzzleClient's instances with config `on_stats`. During creating GuzzleClient in your ServiceProvider you need write something like:

```
$callbackCreator = app(Umbrellio\EventTracker\Trackers\ExternalApiResponse\GuzzleClientOnStatsCallbackCreator);
$client = new GuzzleHttp\Client(['on_stats' => $callbackCreator->create()]);

```

In this case you can modify client as you want. But if you dont need it - you can create new ServiceProvider and use tracker's binder:

```
class GuzzleClientServiceProvider extends ServiceProvider
{
    public function boot(Umbrellio\EventTracker\Trackers\ExternalApiResponse\GuzzleClientBinder $binder): void
    {
        $binder->bind($this->app);
    }
}

```

> **Influx**
>
> Format of writing will

be: `app_prefix.external_api_response,host=api.domain.com,status=200,total_time=1.0,connect_time=0.5,namelookup_time=0.5 val=1.0`

> **Prometheus**
>
> - Buckets can be configured in config
> - Metrics have follow format: app\_prefix\_external\_api\_response\_bucket{namespace="app-ns",host="domain.com",status=200,le="2"} 1

You can configure last three tags in `metrics` option, if you don't need something. Beside of this tags you can specify any fields from handlerStats attribute in GuzzleHttp\\TransferStats object.

By default, option `group_redirects_in_one_request` is set in `false`. It means **every** request will be tracked. Even if it was response with redirect status code. However if you want track common time of response, set this option to `true`.

Field `val` can be configured by option `main_metric`. This field must be one of list in `metrics` option.

### Custom trackers

[](#custom-trackers)

#### Influx

[](#influx)

You can create your own wrap for EventRepository class and log any custom events from your app. Pass `timestamp` attribute in `write` method for use specific time of event instead of current one. Use only nanoseconds for specify time. For example - 1612369449000000000.

#### Prometheus

[](#prometheus-1)

Similarly, like in Influx case, you can use PrometheusRepositoryContract for write custom metrics. There are methods for each type of Prometheus metrics: counter, gauge, histogram, summary.

For disable all trackers - use `enabled` field in package config.

Connections
-----------

[](#connections)

### Influx

[](#influx-1)

This connection allows you to send event directly in influx db. This way is not recommended, because there is can be problems with performance.

### Telegraf

[](#telegraf)

This connection just like previous one, but all events is sent to Telegraf daemon. This way is faster and more optimized than previous one.

### Prometheus

[](#prometheus-2)

This connection uses Redis for temporary storing metrics. All your events will be written to redis. All metrics can be fetched by `/metrics` endpoint (it will be automatically added to your routes). You can configure endpoint name.

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance80

Actively maintained with recent releases

Popularity30

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% 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 ~121 days

Recently: every ~264 days

Total

10

Last Release

103d ago

Major Versions

1.2.2 → 2.0.02023-08-08

### Community

Maintainers

![](https://www.gravatar.com/avatar/023972c6d4f6faeb92150036503d5cbcf7b01217869ad8ea29a07b677c075807?d=identicon)[umbrellio](/maintainers/umbrellio)

---

Top Contributors

[![qem19](https://avatars.githubusercontent.com/u/49522198?v=4)](https://github.com/qem19 "qem19 (5 commits)")[![lazeevv](https://avatars.githubusercontent.com/u/36244644?v=4)](https://github.com/lazeevv "lazeevv (2 commits)")[![antonkul](https://avatars.githubusercontent.com/u/178773850?v=4)](https://github.com/antonkul "antonkul (1 commits)")[![elvina-ero](https://avatars.githubusercontent.com/u/190482294?v=4)](https://github.com/elvina-ero "elvina-ero (1 commits)")[![nwdles](https://avatars.githubusercontent.com/u/53143265?v=4)](https://github.com/nwdles "nwdles (1 commits)")

---

Tags

exporterlaravelmetricsprometheus

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/umbrellio-event-tracker/health.svg)

```
[![Health](https://phpackages.com/badges/umbrellio-event-tracker/health.svg)](https://phpackages.com/packages/umbrellio-event-tracker)
```

###  Alternatives

[overtrue/laravel-query-logger

A dev tool to log all queries for laravel application.

413307.5k6](/packages/overtrue-laravel-query-logger)[guanguans/laravel-exception-notify

Monitor exception and report to the notification channels(Log、Mail、AnPush、Bark、Chanify、DingTalk、Discord、Gitter、GoogleChat、IGot、Lark、Mattermost、MicrosoftTeams、NowPush、Ntfy、Push、Pushback、PushBullet、PushDeer、PushMe、Pushover、PushPlus、QQ、RocketChat、ServerChan、ShowdocPush、SimplePush、Slack、Telegram、WeWork、WPush、XiZhi、YiFengChuanHua、ZohoCliq、ZohoCliqWebHook、Zulip).

14642.7k1](/packages/guanguans-laravel-exception-notify)[tray-labs/laravel-influxdb

A service made to provide, set up and use the library from influxdata influxphp in Laravel.

72164.7k](/packages/tray-labs-laravel-influxdb)

PHPackages © 2026

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