carstensvendsen / jaeger-clone-php
Jaeger Bindings for PHP OpenTracing API
dev-master
2021-01-13 06:21 UTC
Requires
- php: ^7.4 || ^8.0
- ext-sockets: *
- opentracing/opentracing: dev-master
- packaged/thrift: ^0.10
- phlib/base_convert: ^1.0
- psr/cache: ^1.0
- psr/log: ^1.0
Requires (Dev)
- cache/array-adapter: ^1.0
- phpunit/phpunit: ^7.0 || ^9.0
- squizlabs/php_codesniffer: 3.*
- symfony/polyfill-php73: ^1.10
- symfony/polyfill-php80: ^1.20
This package is not auto-updated.
Last update: 2024-11-20 05:08:49 UTC
README
Jaeger Bindings for PHP OpenTracing API
This is a client-side library that can be used to instrument PHP apps for distributed trace collection, and to send those traces to Jaeger. See the OpenTracing PHP API for additional detail.
Contributing and Developing
Please see CONTRIBUTING.md.
Installation
Jaeger client can be installed via Composer:
composer require jonahgeorge/jaeger-client-php
Getting Started
<?php require_once 'vendor/autoload.php'; use Jaeger\Config; use OpenTracing\GlobalTracer; $config = new Config( [ 'sampler' => [ 'type' => Jaeger\SAMPLER_TYPE_CONST, 'param' => true, ], 'logging' => true, ], 'your-app-name' ); $config->initializeTracer(); $tracer = GlobalTracer::get(); $scope = $tracer->startActiveSpan('TestSpan', []); $scope->close(); $tracer->flush();
Samplers
List of supported samplers, for more info about samplers, please read Jaeger Sampling guide.
Const sampler
This sampler either samples everything, or nothing.
Configuration
'sampler' => [
'type' => Jaeger\SAMPLER_TYPE_CONST,
'param' => true, // boolean wheter to trace or not
],
Probabilistic sampler
This sampler samples request by given rate.
Configuration
'sampler' => [
'type' => Jaeger\SAMPLER_TYPE_PROBABILISTIC,
'param' => 0.5, // float [0.0, 1.0]
],
Rate limiting sampler
Samples maximum specified number of traces (requests) per second.
Requirements
psr/cache
PSR-6 cache component to store and retrieve sampler state between requests. Cache component is passed toJaeger\Config
trough its constructor.hrtime()
function, that can retrieve time in nanoseconds. You need eitherphp 7.3
or PECL/hrtime extension.
Configuration
'sampler' => [
'type' => Jaeger\SAMPLER_TYPE_RATE_LIMITING,
'param' => 100 // integer maximum number of traces per second,
'cache' => [
'currentBalanceKey' => 'rate.currentBalance' // string
'lastTickKey' => 'rate.lastTick' // string
]
],
Testing
Tests are located in the tests
directory. See tests/README.md.