chocofamilyme / laravel-jaeger
Jaeger wrapper for Laravel
Installs: 31 553
Dependents: 1
Suggesters: 0
Security: 0
Stars: 17
Watchers: 5
Forks: 10
Open Issues: 4
Requires
- php: ^8.0
- ext-json: *
- jonahgeorge/jaeger-client-php: ^1.4
- laravel/framework: ^9.0|^10.0
Requires (Dev)
- orchestra/testbench: ^7.0
- phpunit/phpunit: ^9.5
- vimeo/psalm: ^4.6.0
This package is auto-updated.
Last update: 2024-11-16 10:57:05 UTC
README
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
- You need to inject
\Chocofamilyme\LaravelJaeger\Jaeger
class by DI - Start new span by command
$jaeger->start('Some operation', [ 'tag1' => 'test', 'tag2' => 'test' ]);
- do some stuff
- (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.