chocofamilyme/laravel-jaeger

Jaeger wrapper for Laravel
40,323 18
Install
composer require chocofamilyme/laravel-jaeger
Latest Version:3.0.0
PHP:^8.0
License:MIT
Last Updated:Jul 26, 2024
Links: GitHub  ·  Packagist
Maintainer: chocofamilyme

Laravel Jaeger wrapper

Requirements

  • PHP ^8.0
  • Laravel ^9.0

Installation

You can install the package via composer:

composer require chocofamilyme/laravel-jaeger

You can publish the config file with:

php artisan vendor:publish --provider="Chocofamilyme\LaravelJaeger\LaravelJaegerServiceProvider" --tag="config"

Basic Usage

  1. You need to inject \Chocofamilyme\LaravelJaeger\Jaeger class by DI
  2. Start new span by command
    $jaeger->start('Some operation', [
        'tag1' => 'test',
        'tag2' => 'test'
    ]);
  1. do some stuff
  2. (optional) stop span
    $jaeger->stop('Some operation', [
        'tag3' => 'test',
    ]);

All unstopped spans will be automatically stopped when application is terminated

Controlling the rate of traces

In the configuration file you may modify JAEGER_SAMPLE_RATE variable to configure the rate. The variable accepts values from 0 to 1.

For example, if you set 0.1 then only 10% of all traces is displayed. Set 1 to output them all.

Listeners

There are 4 available listeners, they are disabled by default, you can turn on or write your own implementation for this listeners in config file

'listeners' => [
    'http' => [
        'enabled' => env('JAEGER_HTTP_LISTENER_ENABLED', false),
        'handler' => \Chocofamilyme\LaravelJaeger\JaegerMiddleware::class,
    ],
    'console' => [
        'enabled' => env('JAEGER_CONSOLE_LISTENER_ENABLED', false),
        'handler' => \Chocofamilyme\LaravelJaeger\Listeners\CommandListener::class,
    ],
    'query' => [
        'enabled' => env('JAEGER_QUERY_LISTENER_ENABLED', false),
        'handler' => \Chocofamilyme\LaravelJaeger\Listeners\QueryListener::class,
    ],
    'job' => [
        'enabled' => env('JAEGER_JOB_LISTENER_ENABLED', false),
        'handler' => \Chocofamilyme\LaravelJaeger\Listeners\JobListener::class,
    ],
]
  • Http - Start new span for every http request
  • Console - Start new span for every running artisan console commands
  • Query - Start new span for every executed database query
  • Job - Start new span for every dispatched queue job

Testing

composer test

Changelog

Read changelog here

License

The MIT License (MIT). Please see License File for more information.

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

641,106,524 9,700
laravel/framework

The Laravel Framework.

593,882,149 34,959
laravel/tinker

Powerful REPL for the Laravel framework.

502,645,077 7,441
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

418,291,778 609
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

394,964,158 4,660

Version History

Version Released PHP Laravel License
3.0.0 ^8.0 ^9.0|^10.0 MIT
2.0.1 ^8.0 ^9.0 MIT
2.0.0 ^8.0 ^9.0 MIT
1.0.1 ^8.0 ^9.0 MIT
1.0.0 ^8.0 ^8.0|^9.0 MIT