### Initialize Jaeger Tracer and Start/End Span Source: https://github.com/jonahgeorge/jaeger-client-php/blob/master/README.md Demonstrates how to initialize the Jaeger tracer with a configuration, start an active span, perform operations, close the span, and flush the tracer. This is a basic example of instrumenting a PHP application. ```php [ '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(); ``` -------------------------------- ### Install Dependencies with Composer Source: https://github.com/jonahgeorge/jaeger-client-php/blob/master/tests/README.md Installs project dependencies, including PHPUnit, using Composer. This command should be run from the project's root directory. ```Bash # run this command from project root $ composer install ``` -------------------------------- ### Install Jaeger Client PHP Source: https://github.com/jonahgeorge/jaeger-client-php/blob/master/README.md Installs the Jaeger client library for PHP using Composer. This is the primary method for integrating the library into your project. ```bash composer require jonahgeorge/jaeger-client-php ``` -------------------------------- ### Jaeger Dispatch Mode Configuration Source: https://github.com/jonahgeorge/jaeger-client-php/blob/master/README.md Illustrates how to configure the dispatch mode for sending trace data to Jaeger. It shows the available constants and an example configuration array. ```php class Config { const ZIPKIN_OVER_COMPACT_UDP = "zipkin_over_compact_udp"; const JAEGER_OVER_BINARY_UDP = "jaeger_over_binary_udp"; const JAEGER_OVER_BINARY_HTTP = "jaeger_over_binary_http"; ... } ``` ```php // config.php use Jaeger\Config; return [ 'sampler' => [ 'type' => Jaeger\SAMPLER_TYPE_CONST, 'param' => true, ], 'logging' => true, "tags" => [ // process. prefix works only with JAEGER_OVER_HTTP, JAEGER_OVER_BINARY // otherwise it will be shown as simple global tag "process.process-tag-key-1" => "process-value-1", // all tags with `process.` prefix goes to process section "process.process-tag-key-2" => "process-value-2", // all tags with `process.` prefix goes to process section "global-tag-key-1" => "global-tag-value-1", // this tag will be appended to all spans "global-tag-key-2" => "global-tag-value-2", // this tag will be appended to all spans ], "local_agent" => [ "reporting_host" => "localhost", // You can override port by setting local_agent.reporting_port value "reporting_port" => 6832 ], // Different ways to send data to Jaeger. Config::ZIPKIN_OVER_COMPACT - default): 'dispatch_mode' => Config::JAEGER_OVER_BINARY_UDP, ]; ``` -------------------------------- ### Configure Jaeger Client for IPv6 (PHP) Source: https://github.com/jonahgeorge/jaeger-client-php/blob/master/README.md Demonstrates how to configure the Jaeger client for PHP to use IPv6 by setting the 'ip_version' configuration option. This example shows the direct use of the 'ip_version' key. ```php use Jaeger\Config; $config = new Config( [ "ip_version" => Config::IPV6, // <-- or use Config::IP_VERSION constant 'logging' => true, 'dispatch_mode' => Config::JAEGER_OVER_BINARY_UDP, ], 'serviceNameExample', ); $config->initializeTracer(); ``` -------------------------------- ### Jaeger Sampler Configurations Source: https://github.com/jonahgeorge/jaeger-client-php/blob/master/README.md Provides configurations for different Jaeger samplers: Const, Probabilistic, and Rate Limiting. Each sampler has specific parameters for controlling trace sampling behavior. ```php 'sampler' => [ 'type' => Jaeger\SAMPLER_TYPE_CONST, 'param' => true, // boolean wheter to trace or not ] ``` ```php 'sampler' => [ 'type' => Jaeger\SAMPLER_TYPE_PROBABILISTIC, 'param' => 0.5, // float [0.0, 1.0] ] ``` ```php '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 ] ] ``` -------------------------------- ### Run Tests with Docker for PHP 7.1 Source: https://github.com/jonahgeorge/jaeger-client-php/blob/master/tests/README.md Executes the PHP unit tests using a Docker container with PHP 7.1. This command mounts the current directory into the container and runs the test script. ```Bash $ docker run --rm -it -v $(pwd):/usr/app php:7.1 ./usr/app/tests/php-test.sh ``` -------------------------------- ### Run Unit Tests Source: https://github.com/jonahgeorge/jaeger-client-php/blob/master/tests/README.md Executes all defined unit tests for the Jaeger PHP client library using Composer's test script. ```Bash $ composer test ``` -------------------------------- ### Run Tests with Docker for PHP 7.0 Source: https://github.com/jonahgeorge/jaeger-client-php/blob/master/tests/README.md Executes the PHP unit tests using a Docker container with PHP 7.0. This command mounts the current directory into the container and runs the test script. ```Bash $ docker run --rm -it -v $(pwd):/usr/app php:7.0 ./usr/app/tests/php-test.sh ``` -------------------------------- ### Run Tests with Docker for PHP 7.2 Source: https://github.com/jonahgeorge/jaeger-client-php/blob/master/tests/README.md Executes the PHP unit tests using a Docker container with PHP 7.2. This command mounts the current directory into the container and runs the test script. ```Bash $ docker run --rm -it -v $(pwd):/usr/app php:7.2 ./usr/app/tests/php-test.sh ``` -------------------------------- ### Configure Jaeger Client for IPv6 using Constant (PHP) Source: https://github.com/jonahgeorge/jaeger-client-php/blob/master/README.md Demonstrates an alternative way to configure the Jaeger client for PHP to use IPv6, utilizing the Config::IP_VERSION constant for the configuration key. This provides a more readable and maintainable configuration. ```php use Jaeger\Config; $config = new Config( [ Config::IP_VERSION => Config::IPV6, // <- 'logging' => true, 'dispatch_mode' => Config::JAEGER_OVER_BINARY_UDP, ], 'serviceNameExample', ); $config->initializeTracer(); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.