├── .editorconfig ├── .github └── workflows │ └── main.yaml ├── .gitignore ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── build └── .gitignore ├── composer.json ├── examples ├── config.php └── jaeger.php ├── phpcs.xml.dist ├── phpunit.xml.dist ├── scripts └── thrift-gen.sh ├── src └── Jaeger │ ├── AgentClient │ └── HttpAgentClient.php │ ├── Codec │ ├── BinaryCodec.php │ ├── CodecInterface.php │ ├── CodecUtility.php │ ├── TextCodec.php │ └── ZipkinCodec.php │ ├── Config.php │ ├── Constants.php │ ├── Mapper │ └── SpanToJaegerMapper.php │ ├── Reporter │ ├── CompositeReporter.php │ ├── InMemoryReporter.php │ ├── JaegerReporter.php │ ├── LoggingReporter.php │ ├── NullReporter.php │ ├── RemoteReporter.php │ └── ReporterInterface.php │ ├── ReporterFactory │ ├── AbstractReporterFactory.php │ ├── JaegerHttpReporterFactory.php │ ├── JaegerReporterFactory.php │ ├── ReporterFactoryInterface.php │ └── ZipkinReporterFactory.php │ ├── Sampler │ ├── ConstSampler.php │ ├── ProbabilisticSampler.php │ ├── RateLimitingSampler.php │ └── SamplerInterface.php │ ├── Scope.php │ ├── ScopeManager.php │ ├── Sender │ ├── JaegerSender.php │ ├── SenderInterface.php │ └── UdpSender.php │ ├── Span.php │ ├── SpanContext.php │ ├── Thrift │ ├── Agent │ │ ├── AgentClient.php │ │ ├── AgentIf.php │ │ ├── Agent_emitBatch_args.php │ │ ├── Agent_emitZipkinBatch_args.php │ │ ├── AggregationValidatorClient.php │ │ ├── AggregationValidatorIf.php │ │ ├── AggregationValidator_validateTrace_args.php │ │ ├── AggregationValidator_validateTrace_result.php │ │ ├── BaggageRestriction.php │ │ ├── BaggageRestrictionManagerClient.php │ │ ├── BaggageRestrictionManagerIf.php │ │ ├── BaggageRestrictionManager_getBaggageRestrictions_args.php │ │ ├── BaggageRestrictionManager_getBaggageRestrictions_result.php │ │ ├── Dependencies.php │ │ ├── DependencyClient.php │ │ ├── DependencyIf.php │ │ ├── DependencyLink.php │ │ ├── Dependency_getDependenciesForTrace_args.php │ │ ├── Dependency_getDependenciesForTrace_result.php │ │ ├── Dependency_saveDependencies_args.php │ │ ├── OperationSamplingStrategy.php │ │ ├── PerOperationSamplingStrategies.php │ │ ├── ProbabilisticSamplingStrategy.php │ │ ├── RateLimitingSamplingStrategy.php │ │ ├── SamplingManagerClient.php │ │ ├── SamplingManagerIf.php │ │ ├── SamplingManager_getSamplingStrategy_args.php │ │ ├── SamplingManager_getSamplingStrategy_result.php │ │ ├── SamplingStrategyResponse.php │ │ ├── SamplingStrategyType.php │ │ ├── ValidateTraceResponse.php │ │ └── Zipkin │ │ │ ├── Annotation.php │ │ │ ├── AnnotationType.php │ │ │ ├── BinaryAnnotation.php │ │ │ ├── Constant.php │ │ │ ├── Endpoint.php │ │ │ ├── Response.php │ │ │ ├── Span.php │ │ │ ├── ZipkinCollectorClient.php │ │ │ ├── ZipkinCollectorIf.php │ │ │ ├── ZipkinCollector_submitZipkinBatch_args.php │ │ │ └── ZipkinCollector_submitZipkinBatch_result.php │ ├── Batch.php │ ├── BatchSubmitResponse.php │ ├── CollectorClient.php │ ├── CollectorIf.php │ ├── Collector_submitBatches_args.php │ ├── Collector_submitBatches_result.php │ ├── Crossdock │ │ ├── Downstream.php │ │ ├── JoinTraceRequest.php │ │ ├── ObservedSpan.php │ │ ├── StartTraceRequest.php │ │ ├── TraceResponse.php │ │ ├── TracedServiceClient.php │ │ ├── TracedServiceIf.php │ │ ├── TracedService_joinTrace_args.php │ │ ├── TracedService_joinTrace_result.php │ │ ├── TracedService_startTrace_args.php │ │ ├── TracedService_startTrace_result.php │ │ └── Transport.php │ ├── Log.php │ ├── Process.php │ ├── Span.php │ ├── SpanRef.php │ ├── SpanRefType.php │ ├── Tag.php │ └── TagType.php │ ├── ThriftUdpTransport.php │ ├── Tracer.php │ └── Util │ └── RateLimiter.php └── tests ├── Jaeger ├── Codec │ ├── TextCodecTest.php │ └── ZipkinCodecTest.php ├── ConfigTest.php ├── Logger │ └── StackLogger.php ├── Mapper │ └── SpanToJaegerMapperTest.php ├── Reporter │ ├── CompositeReporterTest.php │ ├── InMemoryReporterTest.php │ ├── LoggingReporterTest.php │ ├── NullReporterTest.php │ └── RemoteReporterTest.php ├── Sampler │ ├── ConstSamplerTest.php │ ├── ProbablisticSamplerTest.php │ └── RateLimitSamplerTest.php ├── ScopeManagerTest.php ├── ScopeTest.php ├── Sender │ ├── JaegerThriftSenderTest.php │ └── UdpSenderTest.php ├── SpanContextTest.php ├── SpanTest.php ├── ThriftUdpTransportTest.php └── TracerTest.php ├── README.md └── php-test.sh /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | end_of_line = lf 6 | insert_final_newline = true 7 | indent_style = space 8 | indent_size = 4 9 | trim_trailing_whitespace = true 10 | 11 | [*.md] 12 | trim_trailing_whitespace = false 13 | 14 | [*.yml] 15 | indent_style = space 16 | indent_size = 2 17 | -------------------------------------------------------------------------------- /.github/workflows/main.yaml: -------------------------------------------------------------------------------- 1 | name: Test 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | run: 7 | runs-on: ubuntu-latest 8 | strategy: 9 | matrix: 10 | php-versions: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1'] 11 | name: PHP ${{ matrix.php-versions }} 12 | steps: 13 | - name: Checkout 14 | uses: actions/checkout@v2 15 | 16 | - name: Setup PHP 17 | uses: shivammathur/setup-php@v2 18 | with: 19 | php-version: ${{ matrix.php-versions }} 20 | coverage: xdebug 21 | 22 | - name: Get composer cache directory 23 | id: composercache 24 | run: echo "::set-output name=dir::$(composer config cache-files-dir)" 25 | 26 | - name: Cache dependencies 27 | uses: actions/cache@v2 28 | with: 29 | path: ${{ steps.composercache.outputs.dir }} 30 | key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} 31 | restore-keys: ${{ runner.os }}-composer- 32 | 33 | - name: Install dependencies 34 | run: | 35 | composer install \ 36 | --no-interaction \ 37 | --no-ansi \ 38 | --no-progress 39 | 40 | - name: Run lint 41 | run: composer lint 42 | 43 | - name: Run test 44 | run: composer test 45 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Please do not use this ignore file to define platform specific files. 2 | # 3 | # For these purposes create a global .gitignore file, which is a list of rules 4 | # for ignoring files in every Git repository on your computer. 5 | # 6 | # https://help.github.com/articles/ignoring-files/#create-a-global-gitignore 7 | 8 | jaeger-idl 9 | vendor 10 | 11 | composer.lock 12 | composer.phar 13 | 14 | jaeger-client-php.iml 15 | 16 | phpunit.xml 17 | phpcs.xml 18 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to Contribute to Jaeger 2 | 3 | We'd love your help! 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Jonah George, José Carlos Chávez 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /build/.gitignore: -------------------------------------------------------------------------------- 1 | * 2 | !.gitignore 3 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "jonahgeorge/jaeger-client-php", 3 | "description": "Jaeger Bindings for PHP OpenTracing API", 4 | "keywords": [ 5 | "jaeger", 6 | "opentracing", 7 | "trace", 8 | "tracing" 9 | ], 10 | "license": "MIT", 11 | "authors": [ 12 | { 13 | "name": "Jonah George", 14 | "homepage": "http://twitter.com/jonahgeorge" 15 | }, 16 | { 17 | "name": "José Carlos Chávez", 18 | "email": "jcchavezs@gmail.com" 19 | }, 20 | { 21 | "name": "Contributors", 22 | "homepage": "https://github.com/jonahgeorge/jaeger-client-php/graphs/contributors" 23 | } 24 | ], 25 | "require": { 26 | "php": "^7.1 || ^8.0 || ^8.1", 27 | "ext-sockets": "*", 28 | "opentracing/opentracing": "^1.0", 29 | "packaged/thrift": "^0.13", 30 | "psr/cache": "^1.0 || ^2.0 || ^3.0", 31 | "psr/log": "^1.0 || ^2.0 || ^3.0" 32 | }, 33 | "require-dev": { 34 | "phpunit/phpunit": "^7 || ^8 || ^9", 35 | "squizlabs/php_codesniffer": "3.*", 36 | "cache/array-adapter": "^1.0", 37 | "symfony/polyfill-php73": "^1.10" 38 | }, 39 | "config": { 40 | "optimize-autoloader": true, 41 | "preferred-install": "dist", 42 | "sort-packages": true 43 | }, 44 | "autoload": { 45 | "psr-4": { 46 | "Jaeger\\": "src/Jaeger/" 47 | }, 48 | "files": [ 49 | "./src/Jaeger/Constants.php" 50 | ] 51 | }, 52 | "autoload-dev": { 53 | "Jaeger\\Tests\\": "tests/Jaeger/" 54 | }, 55 | "minimum-stability": "dev", 56 | "prefer-stable": true, 57 | "scripts": { 58 | "fix-lint": "./vendor/bin/phpcbf", 59 | "lint": "./vendor/bin/phpcs", 60 | "test": "./vendor/bin/phpunit" 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /examples/config.php: -------------------------------------------------------------------------------- 1 | [ 7 | 'type' => Jaeger\SAMPLER_TYPE_CONST, 8 | 'param' => true, 9 | ], 10 | 'logging' => true, 11 | "tags" => [ 12 | // process. prefix works only with JAEGER_OVER_HTTP, JAEGER_OVER_BINARY 13 | // otherwise it will be shown as simple global tag 14 | "process.process-tag-key-1" => "process-value-1", // all tags with `process.` prefix goes to process section 15 | "process.process-tag-key-2" => "process-value-2", // all tags with `process.` prefix goes to process section 16 | "global-tag-key-1" => "global-tag-value-1", // this tag will be appended to all spans 17 | "global-tag-key-2" => "global-tag-value-2", // this tag will be appended to all spans 18 | ], 19 | "local_agent" => [ 20 | "reporting_host" => "localhost", 21 | // You can override port by setting local_agent.reporting_port value 22 | // "reporting_port" => 6832 23 | ], 24 | // Different ways to send data to Jaeger. Config::ZIPKIN_OVER_COMPACT - default): 25 | 'dispatch_mode' => Config::JAEGER_OVER_BINARY_UDP, 26 | ]; 27 | -------------------------------------------------------------------------------- /examples/jaeger.php: -------------------------------------------------------------------------------- 1 | initializeTracer(); 14 | 15 | $tracer = GlobalTracer::get(); 16 | 17 | $scope = $tracer->startActiveSpan('JaegerSpan', []); 18 | $scope->getSpan()->setTag("tag1", "value1"); 19 | $scope->getSpan()->setTag("tag2", "value2"); 20 | $scope->getSpan()->setTag("tag3", "value2"); 21 | $scope->getSpan()->log([ 22 | "key1" => "value1", 23 | "key2" => 2, 24 | "key3" => true 25 | ]); 26 | 27 | $scope->getSpan()->addBaggageItem("baggage-item1", "baggage-value1"); 28 | $scope->getSpan()->addBaggageItem("baggage-item2", "baggage-value2"); 29 | $scope->getSpan()->addBaggageItem("baggage-item3", "baggage-value3"); 30 | 31 | $nestedSpanScope = $tracer->startActiveSpan("Nested1"); 32 | $nestedSpanScope->getSpan()->setTag("tag1", "value1"); 33 | $nestedSpanScope->getSpan()->setTag("tag2", "value2"); 34 | $nestedSpanScope->getSpan()->setTag("tag3", "value2"); 35 | $nestedSpanScope->getSpan()->log([ 36 | "key1" => "value1", 37 | "key2" => 2, 38 | "key3" => true 39 | ]); 40 | 41 | $nestedSpanScope->getSpan()->addBaggageItem("baggage-item1", "baggage-value1"); 42 | $nestedSpanScope->getSpan()->addBaggageItem("baggage-item2", "baggage-value2"); 43 | $nestedSpanScope->getSpan()->addBaggageItem("baggage-item3", "baggage-value3"); 44 | 45 | sleep(1); 46 | 47 | $nestedSpanScope->close(); 48 | 49 | sleep(1); 50 | $scope->close(); 51 | $tracer->flush(); 52 | -------------------------------------------------------------------------------- /phpcs.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | The coding standard for Jaeger Client 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 29 | src 30 | 31 | 36 | src/Jaeger/Thrift/* 37 | 38 | -------------------------------------------------------------------------------- /phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | src/Jaeger 10 | 11 | src/ 12 | src/Jaeger/Constants.php 13 | src/Jaeger/Thrift/Agent/AgentIf.php 14 | src/Jaeger/Thrift/Agent/AggregationValidatorIf.php 15 | src/Jaeger/Thrift/Agent/BaggageRestrictionManagerIf.php 16 | src/Jaeger/Thrift/Agent/DependencyIf.php 17 | src/Jaeger/Thrift/Agent/SamplingManagerIf.php 18 | src/Jaeger/Thrift/CollectorIf.php 19 | src/Jaeger/Thrift/Crossdock/TracedServiceIf.php 20 | 21 | 22 | 23 | 24 | 25 | 26 | tests/Jaeger 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 42 | 43 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /scripts/thrift-gen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | set -e 4 | 5 | cd "$(dirname "$0")/.." 6 | 7 | # checkout jaeger thrift files 8 | rm -rf jaeger-idl 9 | git clone https://github.com/jaegertracing/jaeger-idl 10 | 11 | # define thrift cmd 12 | THRIFT="docker run -u $(id -u) -v '${PWD}:/data' thrift:0.11.0 thrift -o /data/jaeger-idl" 13 | THRIFT_CMD="${THRIFT} --gen php:psr4,oop" 14 | 15 | # generate php files 16 | FILES=$(find jaeger-idl/thrift -type f -name \*.thrift) 17 | for f in ${FILES}; do 18 | echo "${THRIFT_CMD} "/data/${f}"" 19 | eval $THRIFT_CMD "/data/${f}" 20 | done 21 | 22 | # move generated files 23 | rm -rf src/Jaeger/Thrift 24 | mv jaeger-idl/gen-php/Jaeger/Thrift src/Jaeger/Thrift 25 | 26 | # remove thrift files 27 | rm -rf jaeger-idl 28 | -------------------------------------------------------------------------------- /src/Jaeger/AgentClient/HttpAgentClient.php: -------------------------------------------------------------------------------- 1 | input_ = $input; 15 | $this->output_ = $output ? $output : $input; 16 | } 17 | 18 | public function emitZipkinBatch(array $spans) 19 | { 20 | } 21 | 22 | public function emitBatch(\Jaeger\Thrift\Batch $batch) 23 | { 24 | $batch->write($this->output_); 25 | $this->output_->getTransport()->flush(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/Jaeger/Codec/BinaryCodec.php: -------------------------------------------------------------------------------- 1 | getTraceId()); 31 | $carrier[self::SPAN_ID_NAME] = dechex($spanContext->getSpanId()); 32 | if ($spanContext->getParentId() != null) { 33 | $carrier[self::PARENT_ID_NAME] = dechex($spanContext->getParentId()); 34 | } 35 | $carrier[self::FLAGS_NAME] = (int) $spanContext->getFlags(); 36 | } 37 | 38 | /** 39 | * {@inheritdoc} 40 | * 41 | * @see \Jaeger\Tracer::extract 42 | * 43 | * @param mixed $carrier 44 | * @return SpanContext|null 45 | */ 46 | public function extract($carrier) 47 | { 48 | $traceId = "0"; 49 | $spanId = "0"; 50 | $parentId = "0"; 51 | $flags = 0; 52 | 53 | if (isset($carrier[strtolower(self::SAMPLED_NAME)])) { 54 | if ($carrier[strtolower(self::SAMPLED_NAME)] === "1" || 55 | strtolower($carrier[strtolower(self::SAMPLED_NAME)] === "true") 56 | ) { 57 | $flags = $flags | SAMPLED_FLAG; 58 | } 59 | } 60 | 61 | if (isset($carrier[strtolower(self::TRACE_ID_NAME)])) { 62 | $traceId = CodecUtility::hexToInt64($carrier[strtolower(self::TRACE_ID_NAME)], 16, 10); 63 | } 64 | 65 | if (isset($carrier[strtolower(self::PARENT_ID_NAME)])) { 66 | $parentId = CodecUtility::hexToInt64($carrier[strtolower(self::PARENT_ID_NAME)], 16, 10); 67 | } 68 | 69 | if (isset($carrier[strtolower(self::SPAN_ID_NAME)])) { 70 | $spanId = CodecUtility::hexToInt64($carrier[strtolower(self::SPAN_ID_NAME)], 16, 10); 71 | } 72 | 73 | if (isset($carrier[strtolower(self::FLAGS_NAME)])) { 74 | if ($carrier[strtolower(self::FLAGS_NAME)] === "1") { 75 | $flags = $flags | DEBUG_FLAG; 76 | } 77 | } 78 | 79 | if ($traceId != "0" && $spanId != "0") { 80 | return new SpanContext($traceId, $spanId, $parentId, $flags); 81 | } 82 | 83 | return null; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/Jaeger/Constants.php: -------------------------------------------------------------------------------- 1 | reporters = $reporters; 25 | } 26 | 27 | /** 28 | * {@inheritdoc} 29 | * 30 | * @param Span $span 31 | * @return void 32 | */ 33 | public function reportSpan(Span $span) 34 | { 35 | foreach ($this->reporters as $reporter) { 36 | $reporter->reportSpan($span); 37 | } 38 | } 39 | 40 | /** 41 | * {@inheritdoc} 42 | * 43 | * @return void 44 | */ 45 | public function close() 46 | { 47 | foreach ($this->reporters as $reporter) { 48 | $reporter->close(); 49 | } 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/Jaeger/Reporter/InMemoryReporter.php: -------------------------------------------------------------------------------- 1 | spans[] = $span; 26 | } 27 | 28 | /** 29 | * @return Span[] 30 | */ 31 | public function getSpans(): array 32 | { 33 | return $this->spans; 34 | } 35 | 36 | /** 37 | * {@inheritdoc} 38 | * 39 | * Only implemented to satisfy the sampler interface. 40 | * 41 | * @return void 42 | */ 43 | public function close() 44 | { 45 | // nothing to do 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/Jaeger/Reporter/JaegerReporter.php: -------------------------------------------------------------------------------- 1 | sender = $sender; 23 | } 24 | 25 | public function reportSpan(Span $span) 26 | { 27 | $this->sender->append($span); 28 | } 29 | 30 | public function close() 31 | { 32 | $this->sender->flush(); 33 | $this->sender->close(); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Jaeger/Reporter/LoggingReporter.php: -------------------------------------------------------------------------------- 1 | logger = $logger ?? new NullLogger(); 27 | } 28 | 29 | /** 30 | * {@inheritdoc} 31 | * 32 | * @param Span $span 33 | * @return void 34 | */ 35 | public function reportSpan(Span $span) 36 | { 37 | $this->logger->debug('Reporting span ' . $span->getOperationName()); 38 | } 39 | 40 | /** 41 | * {@inheritdoc} 42 | * 43 | * Only implemented to satisfy the sampler interface. 44 | * 45 | * @return void 46 | */ 47 | public function close() 48 | { 49 | // nothing to do 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/Jaeger/Reporter/NullReporter.php: -------------------------------------------------------------------------------- 1 | transport = $transport; 23 | } 24 | 25 | /** 26 | * {@inheritdoc} 27 | * 28 | * @param Span $span 29 | * @return void 30 | */ 31 | public function reportSpan(Span $span) 32 | { 33 | $this->transport->append($span); 34 | } 35 | 36 | /** 37 | * {@inheritdoc} 38 | * 39 | * @return void 40 | */ 41 | public function close() 42 | { 43 | $this->transport->flush(); 44 | $this->transport->close(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Jaeger/Reporter/ReporterInterface.php: -------------------------------------------------------------------------------- 1 | config = $config; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/Jaeger/ReporterFactory/JaegerHttpReporterFactory.php: -------------------------------------------------------------------------------- 1 | config->getLocalAgentReportingHost(), 19 | $this->config->getLocalAgentReportingPort(), 20 | "/api/traces" 21 | ); 22 | 23 | try { 24 | $transport->open(); 25 | } catch (TTransportException $e) { 26 | $this->config->getLogger()->warning($e->getMessage()); 27 | } 28 | $protocol = new TBinaryProtocol($transport); 29 | $client = new HttpAgentClient($protocol); 30 | $this->config->getLogger()->debug('Initializing HTTP Jaeger Tracer with Jaeger.Thrift over Binary protocol'); 31 | $sender = new JaegerSender($client, $this->config->getLogger()); 32 | $sender->setMaxBufferLength($this->config->getMaxBufferLength()); 33 | return new JaegerReporter($sender); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/Jaeger/ReporterFactory/JaegerReporterFactory.php: -------------------------------------------------------------------------------- 1 | config->getLocalAgentReportingHost(), 22 | $this->config->getLocalAgentReportingPort(), 23 | $this->config->getLogger(), 24 | $this->config 25 | ); 26 | 27 | $transport = new TBufferedTransport( 28 | $udp, 29 | $this->config->getMaxBufferLength(), 30 | $this->config->getMaxBufferLength() 31 | ); 32 | 33 | try { 34 | $transport->open(); 35 | } catch (TTransportException $e) { 36 | $this->config->getLogger()->warning($e->getMessage()); 37 | } 38 | $protocol = $this->config->getDispatchMode() === Config::JAEGER_OVER_COMPACT_UDP ? 39 | new TCompactProtocol($transport) : new TBinaryProtocol($transport); 40 | $client = new AgentClient($protocol); 41 | $this->config->getLogger()->debug('Initializing UDP Jaeger Tracer with Jaeger.Thrift over Binary protocol'); 42 | $sender = new JaegerSender($client, $this->config->getLogger()); 43 | $sender->setMaxBufferLength($this->config->getMaxBufferLength()); 44 | return new JaegerReporter($sender); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Jaeger/ReporterFactory/ReporterFactoryInterface.php: -------------------------------------------------------------------------------- 1 | config->getLocalAgentReportingHost(), 24 | $this->config->getLocalAgentReportingPort(), 25 | $this->config->getLogger(), 26 | $this->config 27 | ); 28 | 29 | $transport = new TBufferedTransport( 30 | $udp, 31 | $this->config->getMaxBufferLength(), 32 | $this->config->getMaxBufferLength() 33 | ); 34 | 35 | try { 36 | $transport->open(); 37 | } catch (TTransportException $e) { 38 | $this->config->getLogger()->warning($e->getMessage()); 39 | } 40 | $protocol = new TCompactProtocol($transport); 41 | $client = new AgentClient($protocol); 42 | $this->config->getLogger()->debug('Initializing UDP Jaeger Tracer with Zipkin.Thrift over Compact protocol'); 43 | $sender = new UdpSender($client, $this->config->getMaxBufferLength(), $this->config->getLogger()); 44 | return new RemoteReporter($sender); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Jaeger/Sampler/ConstSampler.php: -------------------------------------------------------------------------------- 1 | tags = [ 38 | SAMPLER_TYPE_TAG_KEY => SAMPLER_TYPE_CONST, 39 | SAMPLER_PARAM_TAG_KEY => $decision, 40 | ]; 41 | 42 | $this->decision = $decision; 43 | } 44 | 45 | /** 46 | * {@inheritdoc} 47 | * 48 | * @param string $traceId The traceId on the span. 49 | * @param string $operation The operation name set on the span. 50 | * @return array 51 | */ 52 | public function isSampled(string $traceId, string $operation = ''): array 53 | { 54 | return [$this->decision, $this->tags]; 55 | } 56 | 57 | /** 58 | * {@inheritdoc} 59 | * 60 | * Only implemented to satisfy the sampler interface. 61 | * 62 | * @return void 63 | */ 64 | public function close() 65 | { 66 | // nothing to do 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/Jaeger/Sampler/ProbabilisticSampler.php: -------------------------------------------------------------------------------- 1 | tags = [ 48 | SAMPLER_TYPE_TAG_KEY => SAMPLER_TYPE_PROBABILISTIC, 49 | SAMPLER_PARAM_TAG_KEY => $rate, 50 | ]; 51 | 52 | if ($rate < 0.0 || $rate > 1.0) { 53 | throw new OutOfBoundsException('Sampling rate must be between 0.0 and 1.0.'); 54 | } 55 | 56 | $this->rate = $rate; 57 | if ($rate < 0.5) { 58 | $this->boundary = (int)($rate * PHP_INT_MAX); 59 | } else { 60 | // more precise calculation due to int and float having different precision near PHP_INT_MAX 61 | $this->boundary = PHP_INT_MAX - (int)((1 - $rate) * PHP_INT_MAX); 62 | } 63 | } 64 | 65 | /** 66 | * {@inheritdoc} 67 | * 68 | * @param string $traceId The traceId on the span. 69 | * @param string $operation The operation name set on the span. 70 | * @return array 71 | */ 72 | public function isSampled(string $traceId, string $operation = ''): array 73 | { 74 | return [($traceId < $this->boundary), $this->tags]; 75 | } 76 | 77 | /** 78 | * {@inheritdoc} 79 | * 80 | * Only implemented to satisfy the sampler interface. 81 | * 82 | * @return void 83 | */ 84 | public function close() 85 | { 86 | // nothing to do 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/Jaeger/Sampler/RateLimitingSampler.php: -------------------------------------------------------------------------------- 1 | tags = [ 28 | SAMPLER_TYPE_TAG_KEY => SAMPLER_TYPE_RATE_LIMITING, 29 | SAMPLER_PARAM_TAG_KEY => $maxTracesPerSecond, 30 | ]; 31 | 32 | $maxTracesPerNanosecond = $maxTracesPerSecond / 1000000000.0; 33 | $this->rateLimiter = $rateLimiter; 34 | $this->rateLimiter->initialize($maxTracesPerNanosecond, $maxTracesPerSecond > 1.0 ? 1.0 : $maxTracesPerSecond); 35 | } 36 | 37 | /** 38 | * Whether or not the new trace should be sampled. 39 | * 40 | * Implementations should return an array in the format [$decision, $tags]. 41 | * 42 | * @param string $traceId The traceId on the span. 43 | * @param string $operation The operation name set on the span. 44 | * @return array 45 | */ 46 | public function isSampled(string $traceId = '', string $operation = '') 47 | { 48 | return [$this->rateLimiter->checkCredit(1.0), $this->tags]; 49 | } 50 | 51 | /** 52 | * {@inheritdoc} 53 | * 54 | * Only implemented to satisfy the sampler interface. 55 | * 56 | * @return void 57 | */ 58 | public function close() 59 | { 60 | // nothing to do 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /src/Jaeger/Sampler/SamplerInterface.php: -------------------------------------------------------------------------------- 1 | scopeManager = $scopeManager; 42 | $this->wrapped = $wrapped; 43 | $this->finishSpanOnClose = $finishSpanOnClose; 44 | $this->toRestore = $scopeManager->getActive(); 45 | } 46 | 47 | /** 48 | * {@inheritdoc} 49 | */ 50 | public function close(): void 51 | { 52 | if ($this->scopeManager->getActive() !== $this) { 53 | // This shouldn't happen if users call methods in expected order 54 | return; 55 | } 56 | 57 | if ($this->finishSpanOnClose) { 58 | $this->wrapped->finish(); 59 | } 60 | 61 | $this->scopeManager->setActive($this->toRestore); 62 | } 63 | 64 | /** 65 | * {@inheritdoc} 66 | */ 67 | public function getSpan(): OTSpan 68 | { 69 | return $this->wrapped; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /src/Jaeger/ScopeManager.php: -------------------------------------------------------------------------------- 1 | active = new Scope($this, $span, $finishSpanOnClose); 25 | 26 | return $this->active; 27 | } 28 | 29 | /** 30 | * {@inheritdoc} 31 | */ 32 | public function getActive(): ?OTScope 33 | { 34 | return $this->active; 35 | } 36 | 37 | /** 38 | * Sets the scope as active. 39 | * @param OTScope|null $scope 40 | */ 41 | public function setActive(?OTScope $scope = null) 42 | { 43 | $this->active = $scope; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Jaeger/Sender/SenderInterface.php: -------------------------------------------------------------------------------- 1 | traceId = $traceId; 38 | $this->spanId = $spanId; 39 | $this->parentId = $parentId; 40 | $this->flags = $flags; 41 | $this->baggage = is_array($baggage) ? $baggage : []; 42 | $this->debugId = $debugId; 43 | } 44 | 45 | /** 46 | * {@inheritdoc} 47 | * @return ArrayIterator 48 | */ 49 | #[\ReturnTypeWillChange] 50 | public function getIterator() 51 | { 52 | return new ArrayIterator($this->baggage); 53 | } 54 | 55 | /** 56 | * {@inheritdoc} 57 | */ 58 | public function getBaggageItem(string $key): ?string 59 | { 60 | return array_key_exists($key, $this->baggage) ? $this->baggage[$key] : null; 61 | } 62 | 63 | /** 64 | * {@inheritdoc} 65 | * 66 | * @param string $key 67 | * @param string $value 68 | * @return SpanContext 69 | */ 70 | public function withBaggageItem(string $key, string $value): OTSpanContext 71 | { 72 | return new self( 73 | $this->traceId, 74 | $this->spanId, 75 | $this->parentId, 76 | $this->flags, 77 | [$key => $value] + $this->baggage 78 | ); 79 | } 80 | 81 | public function getTraceId() 82 | { 83 | return $this->traceId; 84 | } 85 | 86 | public function getParentId() 87 | { 88 | return $this->parentId; 89 | } 90 | 91 | public function getSpanId() 92 | { 93 | return $this->spanId; 94 | } 95 | 96 | /** 97 | * Get the span context flags. 98 | * 99 | * @return int|null 100 | */ 101 | public function getFlags() 102 | { 103 | return $this->flags; 104 | } 105 | 106 | public function getBaggage() 107 | { 108 | return $this->baggage; 109 | } 110 | 111 | public function getDebugId() 112 | { 113 | return $this->debugId; 114 | } 115 | 116 | public function isDebugIdContainerOnly(): bool 117 | { 118 | return ($this->traceId === null) && ($this->debugId !== null); 119 | } 120 | } 121 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Agent/AgentClient.php: -------------------------------------------------------------------------------- 1 | input_ = $input; 27 | $this->output_ = $output ? $output : $input; 28 | } 29 | 30 | public function emitZipkinBatch(array $spans) 31 | { 32 | $this->send_emitZipkinBatch($spans); 33 | } 34 | 35 | public function send_emitZipkinBatch(array $spans) 36 | { 37 | $args = new \Jaeger\Thrift\Agent\Agent_emitZipkinBatch_args(); 38 | $args->spans = $spans; 39 | $bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary'); 40 | if ($bin_accel) 41 | { 42 | thrift_protocol_write_binary($this->output_, 'emitZipkinBatch', TMessageType::ONEWAY, $args, $this->seqid_, $this->output_->isStrictWrite()); 43 | } 44 | else 45 | { 46 | $this->output_->writeMessageBegin('emitZipkinBatch', TMessageType::ONEWAY, $this->seqid_); 47 | $args->write($this->output_); 48 | $this->output_->writeMessageEnd(); 49 | $this->output_->getTransport()->flush(); 50 | } 51 | } 52 | public function emitBatch(\Jaeger\Thrift\Batch $batch) 53 | { 54 | $this->send_emitBatch($batch); 55 | } 56 | 57 | public function send_emitBatch(\Jaeger\Thrift\Batch $batch) 58 | { 59 | $args = new \Jaeger\Thrift\Agent\Agent_emitBatch_args(); 60 | $args->batch = $batch; 61 | $bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary'); 62 | if ($bin_accel) 63 | { 64 | thrift_protocol_write_binary($this->output_, 'emitBatch', TMessageType::ONEWAY, $args, $this->seqid_, $this->output_->isStrictWrite()); 65 | } 66 | else 67 | { 68 | $this->output_->writeMessageBegin('emitBatch', TMessageType::ONEWAY, $this->seqid_); 69 | $args->write($this->output_); 70 | $this->output_->writeMessageEnd(); 71 | $this->output_->getTransport()->flush(); 72 | } 73 | } 74 | } 75 | 76 | 77 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Agent/AgentIf.php: -------------------------------------------------------------------------------- 1 | array( 24 | 'var' => 'batch', 25 | 'isRequired' => false, 26 | 'type' => TType::STRUCT, 27 | 'class' => '\Jaeger\Thrift\Batch', 28 | ), 29 | ); 30 | 31 | /** 32 | * @var \Jaeger\Thrift\Batch 33 | */ 34 | public $batch = null; 35 | 36 | public function __construct($vals=null) { 37 | if (is_array($vals)) { 38 | parent::__construct(self::$_TSPEC, $vals); 39 | } 40 | } 41 | 42 | public function getName() { 43 | return 'Agent_emitBatch_args'; 44 | } 45 | 46 | public function read($input) 47 | { 48 | return $this->_read('Agent_emitBatch_args', self::$_TSPEC, $input); 49 | } 50 | 51 | public function write($output) { 52 | return $this->_write('Agent_emitBatch_args', self::$_TSPEC, $output); 53 | } 54 | 55 | } 56 | 57 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Agent/Agent_emitZipkinBatch_args.php: -------------------------------------------------------------------------------- 1 | array( 24 | 'var' => 'spans', 25 | 'isRequired' => false, 26 | 'type' => TType::LST, 27 | 'etype' => TType::STRUCT, 28 | 'elem' => array( 29 | 'type' => TType::STRUCT, 30 | 'class' => '\Jaeger\Thrift\Agent\Zipkin\Span', 31 | ), 32 | ), 33 | ); 34 | 35 | /** 36 | * @var \Jaeger\Thrift\Agent\Zipkin\Span[] 37 | */ 38 | public $spans = null; 39 | 40 | public function __construct($vals=null) { 41 | if (is_array($vals)) { 42 | parent::__construct(self::$_TSPEC, $vals); 43 | } 44 | } 45 | 46 | public function getName() { 47 | return 'Agent_emitZipkinBatch_args'; 48 | } 49 | 50 | public function read($input) 51 | { 52 | return $this->_read('Agent_emitZipkinBatch_args', self::$_TSPEC, $input); 53 | } 54 | 55 | public function write($output) { 56 | return $this->_write('Agent_emitZipkinBatch_args', self::$_TSPEC, $output); 57 | } 58 | 59 | } 60 | 61 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Agent/AggregationValidatorClient.php: -------------------------------------------------------------------------------- 1 | input_ = $input; 27 | $this->output_ = $output ? $output : $input; 28 | } 29 | 30 | public function validateTrace($traceId) 31 | { 32 | $this->send_validateTrace($traceId); 33 | return $this->recv_validateTrace(); 34 | } 35 | 36 | public function send_validateTrace($traceId) 37 | { 38 | $args = new \Jaeger\Thrift\Agent\AggregationValidator_validateTrace_args(); 39 | $args->traceId = $traceId; 40 | $bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary'); 41 | if ($bin_accel) 42 | { 43 | thrift_protocol_write_binary($this->output_, 'validateTrace', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite()); 44 | } 45 | else 46 | { 47 | $this->output_->writeMessageBegin('validateTrace', TMessageType::CALL, $this->seqid_); 48 | $args->write($this->output_); 49 | $this->output_->writeMessageEnd(); 50 | $this->output_->getTransport()->flush(); 51 | } 52 | } 53 | 54 | public function recv_validateTrace() 55 | { 56 | $bin_accel = ($this->input_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_read_binary'); 57 | if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, '\Jaeger\Thrift\Agent\AggregationValidator_validateTrace_result', $this->input_->isStrictRead()); 58 | else 59 | { 60 | $rseqid = 0; 61 | $fname = null; 62 | $mtype = 0; 63 | 64 | $this->input_->readMessageBegin($fname, $mtype, $rseqid); 65 | if ($mtype == TMessageType::EXCEPTION) { 66 | $x = new TApplicationException(); 67 | $x->read($this->input_); 68 | $this->input_->readMessageEnd(); 69 | throw $x; 70 | } 71 | $result = new \Jaeger\Thrift\Agent\AggregationValidator_validateTrace_result(); 72 | $result->read($this->input_); 73 | $this->input_->readMessageEnd(); 74 | } 75 | if ($result->success !== null) { 76 | return $result->success; 77 | } 78 | throw new \Exception("validateTrace failed: unknown result"); 79 | } 80 | 81 | } 82 | 83 | 84 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Agent/AggregationValidatorIf.php: -------------------------------------------------------------------------------- 1 | array( 24 | 'var' => 'traceId', 25 | 'isRequired' => true, 26 | 'type' => TType::STRING, 27 | ), 28 | ); 29 | 30 | /** 31 | * @var string 32 | */ 33 | public $traceId = null; 34 | 35 | public function __construct($vals=null) { 36 | if (is_array($vals)) { 37 | parent::__construct(self::$_TSPEC, $vals); 38 | } 39 | } 40 | 41 | public function getName() { 42 | return 'AggregationValidator_validateTrace_args'; 43 | } 44 | 45 | public function read($input) 46 | { 47 | return $this->_read('AggregationValidator_validateTrace_args', self::$_TSPEC, $input); 48 | } 49 | 50 | public function write($output) { 51 | return $this->_write('AggregationValidator_validateTrace_args', self::$_TSPEC, $output); 52 | } 53 | 54 | } 55 | 56 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Agent/AggregationValidator_validateTrace_result.php: -------------------------------------------------------------------------------- 1 | array( 24 | 'var' => 'success', 25 | 'isRequired' => false, 26 | 'type' => TType::STRUCT, 27 | 'class' => '\Jaeger\Thrift\Agent\ValidateTraceResponse', 28 | ), 29 | ); 30 | 31 | /** 32 | * @var \Jaeger\Thrift\Agent\ValidateTraceResponse 33 | */ 34 | public $success = null; 35 | 36 | public function __construct($vals=null) { 37 | if (is_array($vals)) { 38 | parent::__construct(self::$_TSPEC, $vals); 39 | } 40 | } 41 | 42 | public function getName() { 43 | return 'AggregationValidator_validateTrace_result'; 44 | } 45 | 46 | public function read($input) 47 | { 48 | return $this->_read('AggregationValidator_validateTrace_result', self::$_TSPEC, $input); 49 | } 50 | 51 | public function write($output) { 52 | return $this->_write('AggregationValidator_validateTrace_result', self::$_TSPEC, $output); 53 | } 54 | 55 | } 56 | 57 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Agent/BaggageRestriction.php: -------------------------------------------------------------------------------- 1 | array( 25 | 'var' => 'baggageKey', 26 | 'isRequired' => true, 27 | 'type' => TType::STRING, 28 | ), 29 | 2 => array( 30 | 'var' => 'maxValueLength', 31 | 'isRequired' => true, 32 | 'type' => TType::I32, 33 | ), 34 | ); 35 | 36 | /** 37 | * @var string 38 | */ 39 | public $baggageKey = null; 40 | /** 41 | * @var int 42 | */ 43 | public $maxValueLength = null; 44 | 45 | public function __construct($vals=null) { 46 | if (is_array($vals)) { 47 | parent::__construct(self::$_TSPEC, $vals); 48 | } 49 | } 50 | 51 | public function getName() { 52 | return 'BaggageRestriction'; 53 | } 54 | 55 | public function read($input) 56 | { 57 | return $this->_read('BaggageRestriction', self::$_TSPEC, $input); 58 | } 59 | 60 | public function write($output) { 61 | return $this->_write('BaggageRestriction', self::$_TSPEC, $output); 62 | } 63 | 64 | } 65 | 66 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Agent/BaggageRestrictionManagerClient.php: -------------------------------------------------------------------------------- 1 | input_ = $input; 27 | $this->output_ = $output ? $output : $input; 28 | } 29 | 30 | public function getBaggageRestrictions($serviceName) 31 | { 32 | $this->send_getBaggageRestrictions($serviceName); 33 | return $this->recv_getBaggageRestrictions(); 34 | } 35 | 36 | public function send_getBaggageRestrictions($serviceName) 37 | { 38 | $args = new \Jaeger\Thrift\Agent\BaggageRestrictionManager_getBaggageRestrictions_args(); 39 | $args->serviceName = $serviceName; 40 | $bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary'); 41 | if ($bin_accel) 42 | { 43 | thrift_protocol_write_binary($this->output_, 'getBaggageRestrictions', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite()); 44 | } 45 | else 46 | { 47 | $this->output_->writeMessageBegin('getBaggageRestrictions', TMessageType::CALL, $this->seqid_); 48 | $args->write($this->output_); 49 | $this->output_->writeMessageEnd(); 50 | $this->output_->getTransport()->flush(); 51 | } 52 | } 53 | 54 | public function recv_getBaggageRestrictions() 55 | { 56 | $bin_accel = ($this->input_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_read_binary'); 57 | if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, '\Jaeger\Thrift\Agent\BaggageRestrictionManager_getBaggageRestrictions_result', $this->input_->isStrictRead()); 58 | else 59 | { 60 | $rseqid = 0; 61 | $fname = null; 62 | $mtype = 0; 63 | 64 | $this->input_->readMessageBegin($fname, $mtype, $rseqid); 65 | if ($mtype == TMessageType::EXCEPTION) { 66 | $x = new TApplicationException(); 67 | $x->read($this->input_); 68 | $this->input_->readMessageEnd(); 69 | throw $x; 70 | } 71 | $result = new \Jaeger\Thrift\Agent\BaggageRestrictionManager_getBaggageRestrictions_result(); 72 | $result->read($this->input_); 73 | $this->input_->readMessageEnd(); 74 | } 75 | if ($result->success !== null) { 76 | return $result->success; 77 | } 78 | throw new \Exception("getBaggageRestrictions failed: unknown result"); 79 | } 80 | 81 | } 82 | 83 | 84 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Agent/BaggageRestrictionManagerIf.php: -------------------------------------------------------------------------------- 1 | array( 24 | 'var' => 'serviceName', 25 | 'isRequired' => false, 26 | 'type' => TType::STRING, 27 | ), 28 | ); 29 | 30 | /** 31 | * @var string 32 | */ 33 | public $serviceName = null; 34 | 35 | public function __construct($vals=null) { 36 | if (is_array($vals)) { 37 | parent::__construct(self::$_TSPEC, $vals); 38 | } 39 | } 40 | 41 | public function getName() { 42 | return 'BaggageRestrictionManager_getBaggageRestrictions_args'; 43 | } 44 | 45 | public function read($input) 46 | { 47 | return $this->_read('BaggageRestrictionManager_getBaggageRestrictions_args', self::$_TSPEC, $input); 48 | } 49 | 50 | public function write($output) { 51 | return $this->_write('BaggageRestrictionManager_getBaggageRestrictions_args', self::$_TSPEC, $output); 52 | } 53 | 54 | } 55 | 56 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Agent/BaggageRestrictionManager_getBaggageRestrictions_result.php: -------------------------------------------------------------------------------- 1 | array( 24 | 'var' => 'success', 25 | 'isRequired' => false, 26 | 'type' => TType::LST, 27 | 'etype' => TType::STRUCT, 28 | 'elem' => array( 29 | 'type' => TType::STRUCT, 30 | 'class' => '\Jaeger\Thrift\Agent\BaggageRestriction', 31 | ), 32 | ), 33 | ); 34 | 35 | /** 36 | * @var \Jaeger\Thrift\Agent\BaggageRestriction[] 37 | */ 38 | public $success = null; 39 | 40 | public function __construct($vals=null) { 41 | if (is_array($vals)) { 42 | parent::__construct(self::$_TSPEC, $vals); 43 | } 44 | } 45 | 46 | public function getName() { 47 | return 'BaggageRestrictionManager_getBaggageRestrictions_result'; 48 | } 49 | 50 | public function read($input) 51 | { 52 | return $this->_read('BaggageRestrictionManager_getBaggageRestrictions_result', self::$_TSPEC, $input); 53 | } 54 | 55 | public function write($output) { 56 | return $this->_write('BaggageRestrictionManager_getBaggageRestrictions_result', self::$_TSPEC, $output); 57 | } 58 | 59 | } 60 | 61 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Agent/Dependencies.php: -------------------------------------------------------------------------------- 1 | array( 25 | 'var' => 'links', 26 | 'isRequired' => true, 27 | 'type' => TType::LST, 28 | 'etype' => TType::STRUCT, 29 | 'elem' => array( 30 | 'type' => TType::STRUCT, 31 | 'class' => '\Jaeger\Thrift\Agent\DependencyLink', 32 | ), 33 | ), 34 | ); 35 | 36 | /** 37 | * @var \Jaeger\Thrift\Agent\DependencyLink[] 38 | */ 39 | public $links = null; 40 | 41 | public function __construct($vals=null) { 42 | if (is_array($vals)) { 43 | parent::__construct(self::$_TSPEC, $vals); 44 | } 45 | } 46 | 47 | public function getName() { 48 | return 'Dependencies'; 49 | } 50 | 51 | public function read($input) 52 | { 53 | return $this->_read('Dependencies', self::$_TSPEC, $input); 54 | } 55 | 56 | public function write($output) { 57 | return $this->_write('Dependencies', self::$_TSPEC, $output); 58 | } 59 | 60 | } 61 | 62 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Agent/DependencyClient.php: -------------------------------------------------------------------------------- 1 | input_ = $input; 27 | $this->output_ = $output ? $output : $input; 28 | } 29 | 30 | public function getDependenciesForTrace($traceId) 31 | { 32 | $this->send_getDependenciesForTrace($traceId); 33 | return $this->recv_getDependenciesForTrace(); 34 | } 35 | 36 | public function send_getDependenciesForTrace($traceId) 37 | { 38 | $args = new \Jaeger\Thrift\Agent\Dependency_getDependenciesForTrace_args(); 39 | $args->traceId = $traceId; 40 | $bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary'); 41 | if ($bin_accel) 42 | { 43 | thrift_protocol_write_binary($this->output_, 'getDependenciesForTrace', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite()); 44 | } 45 | else 46 | { 47 | $this->output_->writeMessageBegin('getDependenciesForTrace', TMessageType::CALL, $this->seqid_); 48 | $args->write($this->output_); 49 | $this->output_->writeMessageEnd(); 50 | $this->output_->getTransport()->flush(); 51 | } 52 | } 53 | 54 | public function recv_getDependenciesForTrace() 55 | { 56 | $bin_accel = ($this->input_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_read_binary'); 57 | if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, '\Jaeger\Thrift\Agent\Dependency_getDependenciesForTrace_result', $this->input_->isStrictRead()); 58 | else 59 | { 60 | $rseqid = 0; 61 | $fname = null; 62 | $mtype = 0; 63 | 64 | $this->input_->readMessageBegin($fname, $mtype, $rseqid); 65 | if ($mtype == TMessageType::EXCEPTION) { 66 | $x = new TApplicationException(); 67 | $x->read($this->input_); 68 | $this->input_->readMessageEnd(); 69 | throw $x; 70 | } 71 | $result = new \Jaeger\Thrift\Agent\Dependency_getDependenciesForTrace_result(); 72 | $result->read($this->input_); 73 | $this->input_->readMessageEnd(); 74 | } 75 | if ($result->success !== null) { 76 | return $result->success; 77 | } 78 | throw new \Exception("getDependenciesForTrace failed: unknown result"); 79 | } 80 | 81 | public function saveDependencies(\Jaeger\Thrift\Agent\Dependencies $dependencies) 82 | { 83 | $this->send_saveDependencies($dependencies); 84 | } 85 | 86 | public function send_saveDependencies(\Jaeger\Thrift\Agent\Dependencies $dependencies) 87 | { 88 | $args = new \Jaeger\Thrift\Agent\Dependency_saveDependencies_args(); 89 | $args->dependencies = $dependencies; 90 | $bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary'); 91 | if ($bin_accel) 92 | { 93 | thrift_protocol_write_binary($this->output_, 'saveDependencies', TMessageType::ONEWAY, $args, $this->seqid_, $this->output_->isStrictWrite()); 94 | } 95 | else 96 | { 97 | $this->output_->writeMessageBegin('saveDependencies', TMessageType::ONEWAY, $this->seqid_); 98 | $args->write($this->output_); 99 | $this->output_->writeMessageEnd(); 100 | $this->output_->getTransport()->flush(); 101 | } 102 | } 103 | } 104 | 105 | 106 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Agent/DependencyIf.php: -------------------------------------------------------------------------------- 1 | array( 25 | 'var' => 'parent', 26 | 'isRequired' => true, 27 | 'type' => TType::STRING, 28 | ), 29 | 2 => array( 30 | 'var' => 'child', 31 | 'isRequired' => true, 32 | 'type' => TType::STRING, 33 | ), 34 | 4 => array( 35 | 'var' => 'callCount', 36 | 'isRequired' => true, 37 | 'type' => TType::I64, 38 | ), 39 | ); 40 | 41 | /** 42 | * @var string 43 | */ 44 | public $parent = null; 45 | /** 46 | * @var string 47 | */ 48 | public $child = null; 49 | /** 50 | * @var int 51 | */ 52 | public $callCount = null; 53 | 54 | public function __construct($vals=null) { 55 | if (is_array($vals)) { 56 | parent::__construct(self::$_TSPEC, $vals); 57 | } 58 | } 59 | 60 | public function getName() { 61 | return 'DependencyLink'; 62 | } 63 | 64 | public function read($input) 65 | { 66 | return $this->_read('DependencyLink', self::$_TSPEC, $input); 67 | } 68 | 69 | public function write($output) { 70 | return $this->_write('DependencyLink', self::$_TSPEC, $output); 71 | } 72 | 73 | } 74 | 75 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Agent/Dependency_getDependenciesForTrace_args.php: -------------------------------------------------------------------------------- 1 | array( 24 | 'var' => 'traceId', 25 | 'isRequired' => true, 26 | 'type' => TType::STRING, 27 | ), 28 | ); 29 | 30 | /** 31 | * @var string 32 | */ 33 | public $traceId = null; 34 | 35 | public function __construct($vals=null) { 36 | if (is_array($vals)) { 37 | parent::__construct(self::$_TSPEC, $vals); 38 | } 39 | } 40 | 41 | public function getName() { 42 | return 'Dependency_getDependenciesForTrace_args'; 43 | } 44 | 45 | public function read($input) 46 | { 47 | return $this->_read('Dependency_getDependenciesForTrace_args', self::$_TSPEC, $input); 48 | } 49 | 50 | public function write($output) { 51 | return $this->_write('Dependency_getDependenciesForTrace_args', self::$_TSPEC, $output); 52 | } 53 | 54 | } 55 | 56 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Agent/Dependency_getDependenciesForTrace_result.php: -------------------------------------------------------------------------------- 1 | array( 24 | 'var' => 'success', 25 | 'isRequired' => false, 26 | 'type' => TType::STRUCT, 27 | 'class' => '\Jaeger\Thrift\Agent\Dependencies', 28 | ), 29 | ); 30 | 31 | /** 32 | * @var \Jaeger\Thrift\Agent\Dependencies 33 | */ 34 | public $success = null; 35 | 36 | public function __construct($vals=null) { 37 | if (is_array($vals)) { 38 | parent::__construct(self::$_TSPEC, $vals); 39 | } 40 | } 41 | 42 | public function getName() { 43 | return 'Dependency_getDependenciesForTrace_result'; 44 | } 45 | 46 | public function read($input) 47 | { 48 | return $this->_read('Dependency_getDependenciesForTrace_result', self::$_TSPEC, $input); 49 | } 50 | 51 | public function write($output) { 52 | return $this->_write('Dependency_getDependenciesForTrace_result', self::$_TSPEC, $output); 53 | } 54 | 55 | } 56 | 57 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Agent/Dependency_saveDependencies_args.php: -------------------------------------------------------------------------------- 1 | array( 24 | 'var' => 'dependencies', 25 | 'isRequired' => false, 26 | 'type' => TType::STRUCT, 27 | 'class' => '\Jaeger\Thrift\Agent\Dependencies', 28 | ), 29 | ); 30 | 31 | /** 32 | * @var \Jaeger\Thrift\Agent\Dependencies 33 | */ 34 | public $dependencies = null; 35 | 36 | public function __construct($vals=null) { 37 | if (is_array($vals)) { 38 | parent::__construct(self::$_TSPEC, $vals); 39 | } 40 | } 41 | 42 | public function getName() { 43 | return 'Dependency_saveDependencies_args'; 44 | } 45 | 46 | public function read($input) 47 | { 48 | return $this->_read('Dependency_saveDependencies_args', self::$_TSPEC, $input); 49 | } 50 | 51 | public function write($output) { 52 | return $this->_write('Dependency_saveDependencies_args', self::$_TSPEC, $output); 53 | } 54 | 55 | } 56 | 57 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Agent/OperationSamplingStrategy.php: -------------------------------------------------------------------------------- 1 | array( 25 | 'var' => 'operation', 26 | 'isRequired' => true, 27 | 'type' => TType::STRING, 28 | ), 29 | 2 => array( 30 | 'var' => 'probabilisticSampling', 31 | 'isRequired' => true, 32 | 'type' => TType::STRUCT, 33 | 'class' => '\Jaeger\Thrift\Agent\ProbabilisticSamplingStrategy', 34 | ), 35 | ); 36 | 37 | /** 38 | * @var string 39 | */ 40 | public $operation = null; 41 | /** 42 | * @var \Jaeger\Thrift\Agent\ProbabilisticSamplingStrategy 43 | */ 44 | public $probabilisticSampling = null; 45 | 46 | public function __construct($vals=null) { 47 | if (is_array($vals)) { 48 | parent::__construct(self::$_TSPEC, $vals); 49 | } 50 | } 51 | 52 | public function getName() { 53 | return 'OperationSamplingStrategy'; 54 | } 55 | 56 | public function read($input) 57 | { 58 | return $this->_read('OperationSamplingStrategy', self::$_TSPEC, $input); 59 | } 60 | 61 | public function write($output) { 62 | return $this->_write('OperationSamplingStrategy', self::$_TSPEC, $output); 63 | } 64 | 65 | } 66 | 67 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Agent/PerOperationSamplingStrategies.php: -------------------------------------------------------------------------------- 1 | array( 25 | 'var' => 'defaultSamplingProbability', 26 | 'isRequired' => true, 27 | 'type' => TType::DOUBLE, 28 | ), 29 | 2 => array( 30 | 'var' => 'defaultLowerBoundTracesPerSecond', 31 | 'isRequired' => true, 32 | 'type' => TType::DOUBLE, 33 | ), 34 | 3 => array( 35 | 'var' => 'perOperationStrategies', 36 | 'isRequired' => true, 37 | 'type' => TType::LST, 38 | 'etype' => TType::STRUCT, 39 | 'elem' => array( 40 | 'type' => TType::STRUCT, 41 | 'class' => '\Jaeger\Thrift\Agent\OperationSamplingStrategy', 42 | ), 43 | ), 44 | 4 => array( 45 | 'var' => 'defaultUpperBoundTracesPerSecond', 46 | 'isRequired' => false, 47 | 'type' => TType::DOUBLE, 48 | ), 49 | ); 50 | 51 | /** 52 | * @var double 53 | */ 54 | public $defaultSamplingProbability = null; 55 | /** 56 | * @var double 57 | */ 58 | public $defaultLowerBoundTracesPerSecond = null; 59 | /** 60 | * @var \Jaeger\Thrift\Agent\OperationSamplingStrategy[] 61 | */ 62 | public $perOperationStrategies = null; 63 | /** 64 | * @var double 65 | */ 66 | public $defaultUpperBoundTracesPerSecond = null; 67 | 68 | public function __construct($vals=null) { 69 | if (is_array($vals)) { 70 | parent::__construct(self::$_TSPEC, $vals); 71 | } 72 | } 73 | 74 | public function getName() { 75 | return 'PerOperationSamplingStrategies'; 76 | } 77 | 78 | public function read($input) 79 | { 80 | return $this->_read('PerOperationSamplingStrategies', self::$_TSPEC, $input); 81 | } 82 | 83 | public function write($output) { 84 | return $this->_write('PerOperationSamplingStrategies', self::$_TSPEC, $output); 85 | } 86 | 87 | } 88 | 89 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Agent/ProbabilisticSamplingStrategy.php: -------------------------------------------------------------------------------- 1 | array( 25 | 'var' => 'samplingRate', 26 | 'isRequired' => true, 27 | 'type' => TType::DOUBLE, 28 | ), 29 | ); 30 | 31 | /** 32 | * @var double 33 | */ 34 | public $samplingRate = null; 35 | 36 | public function __construct($vals=null) { 37 | if (is_array($vals)) { 38 | parent::__construct(self::$_TSPEC, $vals); 39 | } 40 | } 41 | 42 | public function getName() { 43 | return 'ProbabilisticSamplingStrategy'; 44 | } 45 | 46 | public function read($input) 47 | { 48 | return $this->_read('ProbabilisticSamplingStrategy', self::$_TSPEC, $input); 49 | } 50 | 51 | public function write($output) { 52 | return $this->_write('ProbabilisticSamplingStrategy', self::$_TSPEC, $output); 53 | } 54 | 55 | } 56 | 57 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Agent/RateLimitingSamplingStrategy.php: -------------------------------------------------------------------------------- 1 | array( 25 | 'var' => 'maxTracesPerSecond', 26 | 'isRequired' => true, 27 | 'type' => TType::I16, 28 | ), 29 | ); 30 | 31 | /** 32 | * @var int 33 | */ 34 | public $maxTracesPerSecond = null; 35 | 36 | public function __construct($vals=null) { 37 | if (is_array($vals)) { 38 | parent::__construct(self::$_TSPEC, $vals); 39 | } 40 | } 41 | 42 | public function getName() { 43 | return 'RateLimitingSamplingStrategy'; 44 | } 45 | 46 | public function read($input) 47 | { 48 | return $this->_read('RateLimitingSamplingStrategy', self::$_TSPEC, $input); 49 | } 50 | 51 | public function write($output) { 52 | return $this->_write('RateLimitingSamplingStrategy', self::$_TSPEC, $output); 53 | } 54 | 55 | } 56 | 57 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Agent/SamplingManagerClient.php: -------------------------------------------------------------------------------- 1 | input_ = $input; 27 | $this->output_ = $output ? $output : $input; 28 | } 29 | 30 | public function getSamplingStrategy($serviceName) 31 | { 32 | $this->send_getSamplingStrategy($serviceName); 33 | return $this->recv_getSamplingStrategy(); 34 | } 35 | 36 | public function send_getSamplingStrategy($serviceName) 37 | { 38 | $args = new \Jaeger\Thrift\Agent\SamplingManager_getSamplingStrategy_args(); 39 | $args->serviceName = $serviceName; 40 | $bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary'); 41 | if ($bin_accel) 42 | { 43 | thrift_protocol_write_binary($this->output_, 'getSamplingStrategy', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite()); 44 | } 45 | else 46 | { 47 | $this->output_->writeMessageBegin('getSamplingStrategy', TMessageType::CALL, $this->seqid_); 48 | $args->write($this->output_); 49 | $this->output_->writeMessageEnd(); 50 | $this->output_->getTransport()->flush(); 51 | } 52 | } 53 | 54 | public function recv_getSamplingStrategy() 55 | { 56 | $bin_accel = ($this->input_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_read_binary'); 57 | if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, '\Jaeger\Thrift\Agent\SamplingManager_getSamplingStrategy_result', $this->input_->isStrictRead()); 58 | else 59 | { 60 | $rseqid = 0; 61 | $fname = null; 62 | $mtype = 0; 63 | 64 | $this->input_->readMessageBegin($fname, $mtype, $rseqid); 65 | if ($mtype == TMessageType::EXCEPTION) { 66 | $x = new TApplicationException(); 67 | $x->read($this->input_); 68 | $this->input_->readMessageEnd(); 69 | throw $x; 70 | } 71 | $result = new \Jaeger\Thrift\Agent\SamplingManager_getSamplingStrategy_result(); 72 | $result->read($this->input_); 73 | $this->input_->readMessageEnd(); 74 | } 75 | if ($result->success !== null) { 76 | return $result->success; 77 | } 78 | throw new \Exception("getSamplingStrategy failed: unknown result"); 79 | } 80 | 81 | } 82 | 83 | 84 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Agent/SamplingManagerIf.php: -------------------------------------------------------------------------------- 1 | array( 24 | 'var' => 'serviceName', 25 | 'isRequired' => false, 26 | 'type' => TType::STRING, 27 | ), 28 | ); 29 | 30 | /** 31 | * @var string 32 | */ 33 | public $serviceName = null; 34 | 35 | public function __construct($vals=null) { 36 | if (is_array($vals)) { 37 | parent::__construct(self::$_TSPEC, $vals); 38 | } 39 | } 40 | 41 | public function getName() { 42 | return 'SamplingManager_getSamplingStrategy_args'; 43 | } 44 | 45 | public function read($input) 46 | { 47 | return $this->_read('SamplingManager_getSamplingStrategy_args', self::$_TSPEC, $input); 48 | } 49 | 50 | public function write($output) { 51 | return $this->_write('SamplingManager_getSamplingStrategy_args', self::$_TSPEC, $output); 52 | } 53 | 54 | } 55 | 56 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Agent/SamplingManager_getSamplingStrategy_result.php: -------------------------------------------------------------------------------- 1 | array( 24 | 'var' => 'success', 25 | 'isRequired' => false, 26 | 'type' => TType::STRUCT, 27 | 'class' => '\Jaeger\Thrift\Agent\SamplingStrategyResponse', 28 | ), 29 | ); 30 | 31 | /** 32 | * @var \Jaeger\Thrift\Agent\SamplingStrategyResponse 33 | */ 34 | public $success = null; 35 | 36 | public function __construct($vals=null) { 37 | if (is_array($vals)) { 38 | parent::__construct(self::$_TSPEC, $vals); 39 | } 40 | } 41 | 42 | public function getName() { 43 | return 'SamplingManager_getSamplingStrategy_result'; 44 | } 45 | 46 | public function read($input) 47 | { 48 | return $this->_read('SamplingManager_getSamplingStrategy_result', self::$_TSPEC, $input); 49 | } 50 | 51 | public function write($output) { 52 | return $this->_write('SamplingManager_getSamplingStrategy_result', self::$_TSPEC, $output); 53 | } 54 | 55 | } 56 | 57 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Agent/SamplingStrategyResponse.php: -------------------------------------------------------------------------------- 1 | array( 25 | 'var' => 'strategyType', 26 | 'isRequired' => true, 27 | 'type' => TType::I32, 28 | ), 29 | 2 => array( 30 | 'var' => 'probabilisticSampling', 31 | 'isRequired' => false, 32 | 'type' => TType::STRUCT, 33 | 'class' => '\Jaeger\Thrift\Agent\ProbabilisticSamplingStrategy', 34 | ), 35 | 3 => array( 36 | 'var' => 'rateLimitingSampling', 37 | 'isRequired' => false, 38 | 'type' => TType::STRUCT, 39 | 'class' => '\Jaeger\Thrift\Agent\RateLimitingSamplingStrategy', 40 | ), 41 | 4 => array( 42 | 'var' => 'operationSampling', 43 | 'isRequired' => false, 44 | 'type' => TType::STRUCT, 45 | 'class' => '\Jaeger\Thrift\Agent\PerOperationSamplingStrategies', 46 | ), 47 | ); 48 | 49 | /** 50 | * @var int 51 | */ 52 | public $strategyType = null; 53 | /** 54 | * @var \Jaeger\Thrift\Agent\ProbabilisticSamplingStrategy 55 | */ 56 | public $probabilisticSampling = null; 57 | /** 58 | * @var \Jaeger\Thrift\Agent\RateLimitingSamplingStrategy 59 | */ 60 | public $rateLimitingSampling = null; 61 | /** 62 | * @var \Jaeger\Thrift\Agent\PerOperationSamplingStrategies 63 | */ 64 | public $operationSampling = null; 65 | 66 | public function __construct($vals=null) { 67 | if (is_array($vals)) { 68 | parent::__construct(self::$_TSPEC, $vals); 69 | } 70 | } 71 | 72 | public function getName() { 73 | return 'SamplingStrategyResponse'; 74 | } 75 | 76 | public function read($input) 77 | { 78 | return $this->_read('SamplingStrategyResponse', self::$_TSPEC, $input); 79 | } 80 | 81 | public function write($output) { 82 | return $this->_write('SamplingStrategyResponse', self::$_TSPEC, $output); 83 | } 84 | 85 | } 86 | 87 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Agent/SamplingStrategyType.php: -------------------------------------------------------------------------------- 1 | 'PROBABILISTIC', 25 | 1 => 'RATE_LIMITING', 26 | ); 27 | } 28 | 29 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Agent/ValidateTraceResponse.php: -------------------------------------------------------------------------------- 1 | array( 25 | 'var' => 'ok', 26 | 'isRequired' => true, 27 | 'type' => TType::BOOL, 28 | ), 29 | 2 => array( 30 | 'var' => 'traceCount', 31 | 'isRequired' => true, 32 | 'type' => TType::I64, 33 | ), 34 | ); 35 | 36 | /** 37 | * @var bool 38 | */ 39 | public $ok = null; 40 | /** 41 | * @var int 42 | */ 43 | public $traceCount = null; 44 | 45 | public function __construct($vals=null) { 46 | if (is_array($vals)) { 47 | parent::__construct(self::$_TSPEC, $vals); 48 | } 49 | } 50 | 51 | public function getName() { 52 | return 'ValidateTraceResponse'; 53 | } 54 | 55 | public function read($input) 56 | { 57 | return $this->_read('ValidateTraceResponse', self::$_TSPEC, $input); 58 | } 59 | 60 | public function write($output) { 61 | return $this->_write('ValidateTraceResponse', self::$_TSPEC, $output); 62 | } 63 | 64 | } 65 | 66 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Agent/Zipkin/Annotation.php: -------------------------------------------------------------------------------- 1 | array( 29 | 'var' => 'timestamp', 30 | 'isRequired' => false, 31 | 'type' => TType::I64, 32 | ), 33 | 2 => array( 34 | 'var' => 'value', 35 | 'isRequired' => false, 36 | 'type' => TType::STRING, 37 | ), 38 | 3 => array( 39 | 'var' => 'host', 40 | 'isRequired' => false, 41 | 'type' => TType::STRUCT, 42 | 'class' => '\Jaeger\Thrift\Agent\Zipkin\Endpoint', 43 | ), 44 | ); 45 | 46 | /** 47 | * Microseconds from epoch. 48 | * 49 | * This value should use the most precise value possible. For example, 50 | * gettimeofday or syncing nanoTime against a tick of currentTimeMillis. 51 | * 52 | * @var int 53 | */ 54 | public $timestamp = null; 55 | /** 56 | * @var string 57 | */ 58 | public $value = null; 59 | /** 60 | * Always the host that recorded the event. By specifying the host you allow 61 | * rollup of all events (such as client requests to a service) by IP address. 62 | * 63 | * @var \Jaeger\Thrift\Agent\Zipkin\Endpoint 64 | */ 65 | public $host = null; 66 | 67 | public function __construct($vals=null) { 68 | if (is_array($vals)) { 69 | parent::__construct(self::$_TSPEC, $vals); 70 | } 71 | } 72 | 73 | public function getName() { 74 | return 'Annotation'; 75 | } 76 | 77 | public function read($input) 78 | { 79 | return $this->_read('Annotation', self::$_TSPEC, $input); 80 | } 81 | 82 | public function write($output) { 83 | return $this->_write('Annotation', self::$_TSPEC, $output); 84 | } 85 | 86 | } 87 | 88 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Agent/Zipkin/AnnotationType.php: -------------------------------------------------------------------------------- 1 | 'BOOL', 30 | 1 => 'BYTES', 31 | 2 => 'I16', 32 | 3 => 'I32', 33 | 4 => 'I64', 34 | 5 => 'DOUBLE', 35 | 6 => 'STRING', 36 | ); 37 | } 38 | 39 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Agent/Zipkin/BinaryAnnotation.php: -------------------------------------------------------------------------------- 1 | array( 40 | 'var' => 'key', 41 | 'isRequired' => false, 42 | 'type' => TType::STRING, 43 | ), 44 | 2 => array( 45 | 'var' => 'value', 46 | 'isRequired' => false, 47 | 'type' => TType::STRING, 48 | ), 49 | 3 => array( 50 | 'var' => 'annotation_type', 51 | 'isRequired' => false, 52 | 'type' => TType::I32, 53 | ), 54 | 4 => array( 55 | 'var' => 'host', 56 | 'isRequired' => false, 57 | 'type' => TType::STRUCT, 58 | 'class' => '\Jaeger\Thrift\Agent\Zipkin\Endpoint', 59 | ), 60 | ); 61 | 62 | /** 63 | * @var string 64 | */ 65 | public $key = null; 66 | /** 67 | * @var string 68 | */ 69 | public $value = null; 70 | /** 71 | * @var int 72 | */ 73 | public $annotation_type = null; 74 | /** 75 | * The host that recorded tag, which allows you to differentiate between 76 | * multiple tags with the same key. There are two exceptions to this. 77 | * 78 | * When the key is CLIENT_ADDR or SERVER_ADDR, host indicates the source or 79 | * destination of an RPC. This exception allows zipkin to display network 80 | * context of uninstrumented services, or clients such as web browsers. 81 | * 82 | * @var \Jaeger\Thrift\Agent\Zipkin\Endpoint 83 | */ 84 | public $host = null; 85 | 86 | public function __construct($vals=null) { 87 | if (is_array($vals)) { 88 | parent::__construct(self::$_TSPEC, $vals); 89 | } 90 | } 91 | 92 | public function getName() { 93 | return 'BinaryAnnotation'; 94 | } 95 | 96 | public function read($input) 97 | { 98 | return $this->_read('BinaryAnnotation', self::$_TSPEC, $input); 99 | } 100 | 101 | public function write($output) { 102 | return $this->_write('BinaryAnnotation', self::$_TSPEC, $output); 103 | } 104 | 105 | } 106 | 107 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Agent/Zipkin/Endpoint.php: -------------------------------------------------------------------------------- 1 | array( 34 | 'var' => 'ipv4', 35 | 'isRequired' => false, 36 | 'type' => TType::I32, 37 | ), 38 | 2 => array( 39 | 'var' => 'port', 40 | 'isRequired' => false, 41 | 'type' => TType::I16, 42 | ), 43 | 3 => array( 44 | 'var' => 'service_name', 45 | 'isRequired' => false, 46 | 'type' => TType::STRING, 47 | ), 48 | 4 => array( 49 | 'var' => 'ipv6', 50 | 'isRequired' => false, 51 | 'type' => TType::STRING, 52 | ), 53 | ); 54 | 55 | /** 56 | * IPv4 host address packed into 4 bytes. 57 | * 58 | * Ex for the ip 1.2.3.4, it would be (1 << 24) | (2 << 16) | (3 << 8) | 4 59 | * 60 | * @var int 61 | */ 62 | public $ipv4 = null; 63 | /** 64 | * IPv4 port 65 | * 66 | * Note: this is to be treated as an unsigned integer, so watch for negatives. 67 | * 68 | * Conventionally, when the port isn't known, port = 0. 69 | * 70 | * @var int 71 | */ 72 | public $port = null; 73 | /** 74 | * Service name in lowercase, such as "memcache" or "zipkin-web" 75 | * 76 | * Conventionally, when the service name isn't known, service_name = "unknown". 77 | * 78 | * @var string 79 | */ 80 | public $service_name = null; 81 | /** 82 | * IPv6 host address packed into 16 bytes. Ex Inet6Address.getBytes() 83 | * 84 | * @var string 85 | */ 86 | public $ipv6 = null; 87 | 88 | public function __construct($vals=null) { 89 | if (is_array($vals)) { 90 | parent::__construct(self::$_TSPEC, $vals); 91 | } 92 | } 93 | 94 | public function getName() { 95 | return 'Endpoint'; 96 | } 97 | 98 | public function read($input) 99 | { 100 | return $this->_read('Endpoint', self::$_TSPEC, $input); 101 | } 102 | 103 | public function write($output) { 104 | return $this->_write('Endpoint', self::$_TSPEC, $output); 105 | } 106 | 107 | } 108 | 109 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Agent/Zipkin/Response.php: -------------------------------------------------------------------------------- 1 | array( 25 | 'var' => 'ok', 26 | 'isRequired' => true, 27 | 'type' => TType::BOOL, 28 | ), 29 | ); 30 | 31 | /** 32 | * @var bool 33 | */ 34 | public $ok = null; 35 | 36 | public function __construct($vals=null) { 37 | if (is_array($vals)) { 38 | parent::__construct(self::$_TSPEC, $vals); 39 | } 40 | } 41 | 42 | public function getName() { 43 | return 'Response'; 44 | } 45 | 46 | public function read($input) 47 | { 48 | return $this->_read('Response', self::$_TSPEC, $input); 49 | } 50 | 51 | public function write($output) { 52 | return $this->_write('Response', self::$_TSPEC, $output); 53 | } 54 | 55 | } 56 | 57 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Agent/Zipkin/Span.php: -------------------------------------------------------------------------------- 1 | array( 32 | 'var' => 'trace_id', 33 | 'isRequired' => false, 34 | 'type' => TType::I64, 35 | ), 36 | 3 => array( 37 | 'var' => 'name', 38 | 'isRequired' => false, 39 | 'type' => TType::STRING, 40 | ), 41 | 4 => array( 42 | 'var' => 'id', 43 | 'isRequired' => false, 44 | 'type' => TType::I64, 45 | ), 46 | 5 => array( 47 | 'var' => 'parent_id', 48 | 'isRequired' => false, 49 | 'type' => TType::I64, 50 | ), 51 | 6 => array( 52 | 'var' => 'annotations', 53 | 'isRequired' => false, 54 | 'type' => TType::LST, 55 | 'etype' => TType::STRUCT, 56 | 'elem' => array( 57 | 'type' => TType::STRUCT, 58 | 'class' => '\Jaeger\Thrift\Agent\Zipkin\Annotation', 59 | ), 60 | ), 61 | 8 => array( 62 | 'var' => 'binary_annotations', 63 | 'isRequired' => false, 64 | 'type' => TType::LST, 65 | 'etype' => TType::STRUCT, 66 | 'elem' => array( 67 | 'type' => TType::STRUCT, 68 | 'class' => '\Jaeger\Thrift\Agent\Zipkin\BinaryAnnotation', 69 | ), 70 | ), 71 | 9 => array( 72 | 'var' => 'debug', 73 | 'isRequired' => false, 74 | 'type' => TType::BOOL, 75 | ), 76 | 10 => array( 77 | 'var' => 'timestamp', 78 | 'isRequired' => false, 79 | 'type' => TType::I64, 80 | ), 81 | 11 => array( 82 | 'var' => 'duration', 83 | 'isRequired' => false, 84 | 'type' => TType::I64, 85 | ), 86 | 12 => array( 87 | 'var' => 'trace_id_high', 88 | 'isRequired' => false, 89 | 'type' => TType::I64, 90 | ), 91 | ); 92 | 93 | /** 94 | * @var int 95 | */ 96 | public $trace_id = null; 97 | /** 98 | * Span name in lowercase, rpc method for example 99 | * 100 | * Conventionally, when the span name isn't known, name = "unknown". 101 | * 102 | * @var string 103 | */ 104 | public $name = null; 105 | /** 106 | * @var int 107 | */ 108 | public $id = null; 109 | /** 110 | * @var int 111 | */ 112 | public $parent_id = null; 113 | /** 114 | * @var \Jaeger\Thrift\Agent\Zipkin\Annotation[] 115 | */ 116 | public $annotations = null; 117 | /** 118 | * @var \Jaeger\Thrift\Agent\Zipkin\BinaryAnnotation[] 119 | */ 120 | public $binary_annotations = null; 121 | /** 122 | * @var bool 123 | */ 124 | public $debug = false; 125 | /** 126 | * Microseconds from epoch of the creation of this span. 127 | * 128 | * This value should be set directly by instrumentation, using the most 129 | * precise value possible. For example, gettimeofday or syncing nanoTime 130 | * against a tick of currentTimeMillis. 131 | * 132 | * For compatibilty with instrumentation that precede this field, collectors 133 | * or span stores can derive this via Annotation.timestamp. 134 | * For example, SERVER_RECV.timestamp or CLIENT_SEND.timestamp. 135 | * 136 | * This field is optional for compatibility with old data: first-party span 137 | * stores are expected to support this at time of introduction. 138 | * 139 | * @var int 140 | */ 141 | public $timestamp = null; 142 | /** 143 | * Measurement of duration in microseconds, used to support queries. 144 | * 145 | * This value should be set directly, where possible. Doing so encourages 146 | * precise measurement decoupled from problems of clocks, such as skew or NTP 147 | * updates causing time to move backwards. 148 | * 149 | * For compatibilty with instrumentation that precede this field, collectors 150 | * or span stores can derive this by subtracting Annotation.timestamp. 151 | * For example, SERVER_SEND.timestamp - SERVER_RECV.timestamp. 152 | * 153 | * If this field is persisted as unset, zipkin will continue to work, except 154 | * duration query support will be implementation-specific. Similarly, setting 155 | * this field non-atomically is implementation-specific. 156 | * 157 | * This field is i64 vs i32 to support spans longer than 35 minutes. 158 | * 159 | * @var int 160 | */ 161 | public $duration = null; 162 | /** 163 | * Optional unique 8-byte additional identifier for a trace. If non zero, this 164 | * means the trace uses 128 bit traceIds instead of 64 bit. 165 | * 166 | * @var int 167 | */ 168 | public $trace_id_high = null; 169 | 170 | public function __construct($vals=null) { 171 | if (is_array($vals)) { 172 | parent::__construct(self::$_TSPEC, $vals); 173 | } 174 | } 175 | 176 | public function getName() { 177 | return 'Span'; 178 | } 179 | 180 | public function read($input) 181 | { 182 | return $this->_read('Span', self::$_TSPEC, $input); 183 | } 184 | 185 | public function write($output) { 186 | return $this->_write('Span', self::$_TSPEC, $output); 187 | } 188 | 189 | } 190 | 191 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Agent/Zipkin/ZipkinCollectorClient.php: -------------------------------------------------------------------------------- 1 | input_ = $input; 27 | $this->output_ = $output ? $output : $input; 28 | } 29 | 30 | public function submitZipkinBatch(array $spans) 31 | { 32 | $this->send_submitZipkinBatch($spans); 33 | return $this->recv_submitZipkinBatch(); 34 | } 35 | 36 | public function send_submitZipkinBatch(array $spans) 37 | { 38 | $args = new \Jaeger\Thrift\Agent\Zipkin\ZipkinCollector_submitZipkinBatch_args(); 39 | $args->spans = $spans; 40 | $bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary'); 41 | if ($bin_accel) 42 | { 43 | thrift_protocol_write_binary($this->output_, 'submitZipkinBatch', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite()); 44 | } 45 | else 46 | { 47 | $this->output_->writeMessageBegin('submitZipkinBatch', TMessageType::CALL, $this->seqid_); 48 | $args->write($this->output_); 49 | $this->output_->writeMessageEnd(); 50 | $this->output_->getTransport()->flush(); 51 | } 52 | } 53 | 54 | public function recv_submitZipkinBatch() 55 | { 56 | $bin_accel = ($this->input_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_read_binary'); 57 | if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, '\Jaeger\Thrift\Agent\Zipkin\ZipkinCollector_submitZipkinBatch_result', $this->input_->isStrictRead()); 58 | else 59 | { 60 | $rseqid = 0; 61 | $fname = null; 62 | $mtype = 0; 63 | 64 | $this->input_->readMessageBegin($fname, $mtype, $rseqid); 65 | if ($mtype == TMessageType::EXCEPTION) { 66 | $x = new TApplicationException(); 67 | $x->read($this->input_); 68 | $this->input_->readMessageEnd(); 69 | throw $x; 70 | } 71 | $result = new \Jaeger\Thrift\Agent\Zipkin\ZipkinCollector_submitZipkinBatch_result(); 72 | $result->read($this->input_); 73 | $this->input_->readMessageEnd(); 74 | } 75 | if ($result->success !== null) { 76 | return $result->success; 77 | } 78 | throw new \Exception("submitZipkinBatch failed: unknown result"); 79 | } 80 | 81 | } 82 | 83 | 84 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Agent/Zipkin/ZipkinCollectorIf.php: -------------------------------------------------------------------------------- 1 | array( 24 | 'var' => 'spans', 25 | 'isRequired' => false, 26 | 'type' => TType::LST, 27 | 'etype' => TType::STRUCT, 28 | 'elem' => array( 29 | 'type' => TType::STRUCT, 30 | 'class' => '\Jaeger\Thrift\Agent\Zipkin\Span', 31 | ), 32 | ), 33 | ); 34 | 35 | /** 36 | * @var \Jaeger\Thrift\Agent\Zipkin\Span[] 37 | */ 38 | public $spans = null; 39 | 40 | public function __construct($vals=null) { 41 | if (is_array($vals)) { 42 | parent::__construct(self::$_TSPEC, $vals); 43 | } 44 | } 45 | 46 | public function getName() { 47 | return 'ZipkinCollector_submitZipkinBatch_args'; 48 | } 49 | 50 | public function read($input) 51 | { 52 | return $this->_read('ZipkinCollector_submitZipkinBatch_args', self::$_TSPEC, $input); 53 | } 54 | 55 | public function write($output) { 56 | return $this->_write('ZipkinCollector_submitZipkinBatch_args', self::$_TSPEC, $output); 57 | } 58 | 59 | } 60 | 61 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Agent/Zipkin/ZipkinCollector_submitZipkinBatch_result.php: -------------------------------------------------------------------------------- 1 | array( 24 | 'var' => 'success', 25 | 'isRequired' => false, 26 | 'type' => TType::LST, 27 | 'etype' => TType::STRUCT, 28 | 'elem' => array( 29 | 'type' => TType::STRUCT, 30 | 'class' => '\Jaeger\Thrift\Agent\Zipkin\Response', 31 | ), 32 | ), 33 | ); 34 | 35 | /** 36 | * @var \Jaeger\Thrift\Agent\Zipkin\Response[] 37 | */ 38 | public $success = null; 39 | 40 | public function __construct($vals=null) { 41 | if (is_array($vals)) { 42 | parent::__construct(self::$_TSPEC, $vals); 43 | } 44 | } 45 | 46 | public function getName() { 47 | return 'ZipkinCollector_submitZipkinBatch_result'; 48 | } 49 | 50 | public function read($input) 51 | { 52 | return $this->_read('ZipkinCollector_submitZipkinBatch_result', self::$_TSPEC, $input); 53 | } 54 | 55 | public function write($output) { 56 | return $this->_write('ZipkinCollector_submitZipkinBatch_result', self::$_TSPEC, $output); 57 | } 58 | 59 | } 60 | 61 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Batch.php: -------------------------------------------------------------------------------- 1 | array( 25 | 'var' => 'process', 26 | 'isRequired' => true, 27 | 'type' => TType::STRUCT, 28 | 'class' => '\Jaeger\Thrift\Process', 29 | ), 30 | 2 => array( 31 | 'var' => 'spans', 32 | 'isRequired' => true, 33 | 'type' => TType::LST, 34 | 'etype' => TType::STRUCT, 35 | 'elem' => array( 36 | 'type' => TType::STRUCT, 37 | 'class' => '\Jaeger\Thrift\Span', 38 | ), 39 | ), 40 | ); 41 | 42 | /** 43 | * @var \Jaeger\Thrift\Process 44 | */ 45 | public $process = null; 46 | /** 47 | * @var \Jaeger\Thrift\Span[] 48 | */ 49 | public $spans = null; 50 | 51 | public function __construct($vals=null) { 52 | if (is_array($vals)) { 53 | parent::__construct(self::$_TSPEC, $vals); 54 | } 55 | } 56 | 57 | public function getName() { 58 | return 'Batch'; 59 | } 60 | 61 | public function read($input) 62 | { 63 | return $this->_read('Batch', self::$_TSPEC, $input); 64 | } 65 | 66 | public function write($output) { 67 | return $this->_write('Batch', self::$_TSPEC, $output); 68 | } 69 | 70 | } 71 | 72 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/BatchSubmitResponse.php: -------------------------------------------------------------------------------- 1 | array( 25 | 'var' => 'ok', 26 | 'isRequired' => true, 27 | 'type' => TType::BOOL, 28 | ), 29 | ); 30 | 31 | /** 32 | * @var bool 33 | */ 34 | public $ok = null; 35 | 36 | public function __construct($vals=null) { 37 | if (is_array($vals)) { 38 | parent::__construct(self::$_TSPEC, $vals); 39 | } 40 | } 41 | 42 | public function getName() { 43 | return 'BatchSubmitResponse'; 44 | } 45 | 46 | public function read($input) 47 | { 48 | return $this->_read('BatchSubmitResponse', self::$_TSPEC, $input); 49 | } 50 | 51 | public function write($output) { 52 | return $this->_write('BatchSubmitResponse', self::$_TSPEC, $output); 53 | } 54 | 55 | } 56 | 57 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/CollectorClient.php: -------------------------------------------------------------------------------- 1 | input_ = $input; 27 | $this->output_ = $output ? $output : $input; 28 | } 29 | 30 | public function submitBatches(array $batches) 31 | { 32 | $this->send_submitBatches($batches); 33 | return $this->recv_submitBatches(); 34 | } 35 | 36 | public function send_submitBatches(array $batches) 37 | { 38 | $args = new \Jaeger\Thrift\Collector_submitBatches_args(); 39 | $args->batches = $batches; 40 | $bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary'); 41 | if ($bin_accel) 42 | { 43 | thrift_protocol_write_binary($this->output_, 'submitBatches', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite()); 44 | } 45 | else 46 | { 47 | $this->output_->writeMessageBegin('submitBatches', TMessageType::CALL, $this->seqid_); 48 | $args->write($this->output_); 49 | $this->output_->writeMessageEnd(); 50 | $this->output_->getTransport()->flush(); 51 | } 52 | } 53 | 54 | public function recv_submitBatches() 55 | { 56 | $bin_accel = ($this->input_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_read_binary'); 57 | if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, '\Jaeger\Thrift\Collector_submitBatches_result', $this->input_->isStrictRead()); 58 | else 59 | { 60 | $rseqid = 0; 61 | $fname = null; 62 | $mtype = 0; 63 | 64 | $this->input_->readMessageBegin($fname, $mtype, $rseqid); 65 | if ($mtype == TMessageType::EXCEPTION) { 66 | $x = new TApplicationException(); 67 | $x->read($this->input_); 68 | $this->input_->readMessageEnd(); 69 | throw $x; 70 | } 71 | $result = new \Jaeger\Thrift\Collector_submitBatches_result(); 72 | $result->read($this->input_); 73 | $this->input_->readMessageEnd(); 74 | } 75 | if ($result->success !== null) { 76 | return $result->success; 77 | } 78 | throw new \Exception("submitBatches failed: unknown result"); 79 | } 80 | 81 | } 82 | 83 | 84 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/CollectorIf.php: -------------------------------------------------------------------------------- 1 | array( 24 | 'var' => 'batches', 25 | 'isRequired' => false, 26 | 'type' => TType::LST, 27 | 'etype' => TType::STRUCT, 28 | 'elem' => array( 29 | 'type' => TType::STRUCT, 30 | 'class' => '\Jaeger\Thrift\Batch', 31 | ), 32 | ), 33 | ); 34 | 35 | /** 36 | * @var \Jaeger\Thrift\Batch[] 37 | */ 38 | public $batches = null; 39 | 40 | public function __construct($vals=null) { 41 | if (is_array($vals)) { 42 | parent::__construct(self::$_TSPEC, $vals); 43 | } 44 | } 45 | 46 | public function getName() { 47 | return 'Collector_submitBatches_args'; 48 | } 49 | 50 | public function read($input) 51 | { 52 | return $this->_read('Collector_submitBatches_args', self::$_TSPEC, $input); 53 | } 54 | 55 | public function write($output) { 56 | return $this->_write('Collector_submitBatches_args', self::$_TSPEC, $output); 57 | } 58 | 59 | } 60 | 61 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Collector_submitBatches_result.php: -------------------------------------------------------------------------------- 1 | array( 24 | 'var' => 'success', 25 | 'isRequired' => false, 26 | 'type' => TType::LST, 27 | 'etype' => TType::STRUCT, 28 | 'elem' => array( 29 | 'type' => TType::STRUCT, 30 | 'class' => '\Jaeger\Thrift\BatchSubmitResponse', 31 | ), 32 | ), 33 | ); 34 | 35 | /** 36 | * @var \Jaeger\Thrift\BatchSubmitResponse[] 37 | */ 38 | public $success = null; 39 | 40 | public function __construct($vals=null) { 41 | if (is_array($vals)) { 42 | parent::__construct(self::$_TSPEC, $vals); 43 | } 44 | } 45 | 46 | public function getName() { 47 | return 'Collector_submitBatches_result'; 48 | } 49 | 50 | public function read($input) 51 | { 52 | return $this->_read('Collector_submitBatches_result', self::$_TSPEC, $input); 53 | } 54 | 55 | public function write($output) { 56 | return $this->_write('Collector_submitBatches_result', self::$_TSPEC, $output); 57 | } 58 | 59 | } 60 | 61 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Crossdock/Downstream.php: -------------------------------------------------------------------------------- 1 | array( 25 | 'var' => 'serviceName', 26 | 'isRequired' => true, 27 | 'type' => TType::STRING, 28 | ), 29 | 2 => array( 30 | 'var' => 'serverRole', 31 | 'isRequired' => true, 32 | 'type' => TType::STRING, 33 | ), 34 | 3 => array( 35 | 'var' => 'host', 36 | 'isRequired' => true, 37 | 'type' => TType::STRING, 38 | ), 39 | 4 => array( 40 | 'var' => 'port', 41 | 'isRequired' => true, 42 | 'type' => TType::STRING, 43 | ), 44 | 5 => array( 45 | 'var' => 'transport', 46 | 'isRequired' => true, 47 | 'type' => TType::I32, 48 | ), 49 | 6 => array( 50 | 'var' => 'downstream', 51 | 'isRequired' => false, 52 | 'type' => TType::STRUCT, 53 | 'class' => '\Jaeger\Thrift\Crossdock\Downstream', 54 | ), 55 | ); 56 | 57 | /** 58 | * @var string 59 | */ 60 | public $serviceName = null; 61 | /** 62 | * @var string 63 | */ 64 | public $serverRole = null; 65 | /** 66 | * @var string 67 | */ 68 | public $host = null; 69 | /** 70 | * @var string 71 | */ 72 | public $port = null; 73 | /** 74 | * @var int 75 | */ 76 | public $transport = null; 77 | /** 78 | * @var \Jaeger\Thrift\Crossdock\Downstream 79 | */ 80 | public $downstream = null; 81 | 82 | public function __construct($vals=null) { 83 | if (is_array($vals)) { 84 | parent::__construct(self::$_TSPEC, $vals); 85 | } 86 | } 87 | 88 | public function getName() { 89 | return 'Downstream'; 90 | } 91 | 92 | public function read($input) 93 | { 94 | return $this->_read('Downstream', self::$_TSPEC, $input); 95 | } 96 | 97 | public function write($output) { 98 | return $this->_write('Downstream', self::$_TSPEC, $output); 99 | } 100 | 101 | } 102 | 103 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Crossdock/JoinTraceRequest.php: -------------------------------------------------------------------------------- 1 | array( 25 | 'var' => 'serverRole', 26 | 'isRequired' => true, 27 | 'type' => TType::STRING, 28 | ), 29 | 2 => array( 30 | 'var' => 'downstream', 31 | 'isRequired' => false, 32 | 'type' => TType::STRUCT, 33 | 'class' => '\Jaeger\Thrift\Crossdock\Downstream', 34 | ), 35 | ); 36 | 37 | /** 38 | * @var string 39 | */ 40 | public $serverRole = null; 41 | /** 42 | * @var \Jaeger\Thrift\Crossdock\Downstream 43 | */ 44 | public $downstream = null; 45 | 46 | public function __construct($vals=null) { 47 | if (is_array($vals)) { 48 | parent::__construct(self::$_TSPEC, $vals); 49 | } 50 | } 51 | 52 | public function getName() { 53 | return 'JoinTraceRequest'; 54 | } 55 | 56 | public function read($input) 57 | { 58 | return $this->_read('JoinTraceRequest', self::$_TSPEC, $input); 59 | } 60 | 61 | public function write($output) { 62 | return $this->_write('JoinTraceRequest', self::$_TSPEC, $output); 63 | } 64 | 65 | } 66 | 67 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Crossdock/ObservedSpan.php: -------------------------------------------------------------------------------- 1 | array( 25 | 'var' => 'traceId', 26 | 'isRequired' => true, 27 | 'type' => TType::STRING, 28 | ), 29 | 2 => array( 30 | 'var' => 'sampled', 31 | 'isRequired' => true, 32 | 'type' => TType::BOOL, 33 | ), 34 | 3 => array( 35 | 'var' => 'baggage', 36 | 'isRequired' => true, 37 | 'type' => TType::STRING, 38 | ), 39 | ); 40 | 41 | /** 42 | * @var string 43 | */ 44 | public $traceId = null; 45 | /** 46 | * @var bool 47 | */ 48 | public $sampled = null; 49 | /** 50 | * @var string 51 | */ 52 | public $baggage = null; 53 | 54 | public function __construct($vals=null) { 55 | if (is_array($vals)) { 56 | parent::__construct(self::$_TSPEC, $vals); 57 | } 58 | } 59 | 60 | public function getName() { 61 | return 'ObservedSpan'; 62 | } 63 | 64 | public function read($input) 65 | { 66 | return $this->_read('ObservedSpan', self::$_TSPEC, $input); 67 | } 68 | 69 | public function write($output) { 70 | return $this->_write('ObservedSpan', self::$_TSPEC, $output); 71 | } 72 | 73 | } 74 | 75 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Crossdock/StartTraceRequest.php: -------------------------------------------------------------------------------- 1 | array( 25 | 'var' => 'serverRole', 26 | 'isRequired' => true, 27 | 'type' => TType::STRING, 28 | ), 29 | 2 => array( 30 | 'var' => 'sampled', 31 | 'isRequired' => true, 32 | 'type' => TType::BOOL, 33 | ), 34 | 3 => array( 35 | 'var' => 'baggage', 36 | 'isRequired' => true, 37 | 'type' => TType::STRING, 38 | ), 39 | 4 => array( 40 | 'var' => 'downstream', 41 | 'isRequired' => true, 42 | 'type' => TType::STRUCT, 43 | 'class' => '\Jaeger\Thrift\Crossdock\Downstream', 44 | ), 45 | ); 46 | 47 | /** 48 | * @var string 49 | */ 50 | public $serverRole = null; 51 | /** 52 | * @var bool 53 | */ 54 | public $sampled = null; 55 | /** 56 | * @var string 57 | */ 58 | public $baggage = null; 59 | /** 60 | * @var \Jaeger\Thrift\Crossdock\Downstream 61 | */ 62 | public $downstream = null; 63 | 64 | public function __construct($vals=null) { 65 | if (is_array($vals)) { 66 | parent::__construct(self::$_TSPEC, $vals); 67 | } 68 | } 69 | 70 | public function getName() { 71 | return 'StartTraceRequest'; 72 | } 73 | 74 | public function read($input) 75 | { 76 | return $this->_read('StartTraceRequest', self::$_TSPEC, $input); 77 | } 78 | 79 | public function write($output) { 80 | return $this->_write('StartTraceRequest', self::$_TSPEC, $output); 81 | } 82 | 83 | } 84 | 85 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Crossdock/TraceResponse.php: -------------------------------------------------------------------------------- 1 | array( 31 | 'var' => 'span', 32 | 'isRequired' => false, 33 | 'type' => TType::STRUCT, 34 | 'class' => '\Jaeger\Thrift\Crossdock\ObservedSpan', 35 | ), 36 | 2 => array( 37 | 'var' => 'downstream', 38 | 'isRequired' => false, 39 | 'type' => TType::STRUCT, 40 | 'class' => '\Jaeger\Thrift\Crossdock\TraceResponse', 41 | ), 42 | 3 => array( 43 | 'var' => 'notImplementedError', 44 | 'isRequired' => true, 45 | 'type' => TType::STRING, 46 | ), 47 | ); 48 | 49 | /** 50 | * @var \Jaeger\Thrift\Crossdock\ObservedSpan 51 | */ 52 | public $span = null; 53 | /** 54 | * @var \Jaeger\Thrift\Crossdock\TraceResponse 55 | */ 56 | public $downstream = null; 57 | /** 58 | * @var string 59 | */ 60 | public $notImplementedError = null; 61 | 62 | public function __construct($vals=null) { 63 | if (is_array($vals)) { 64 | parent::__construct(self::$_TSPEC, $vals); 65 | } 66 | } 67 | 68 | public function getName() { 69 | return 'TraceResponse'; 70 | } 71 | 72 | public function read($input) 73 | { 74 | return $this->_read('TraceResponse', self::$_TSPEC, $input); 75 | } 76 | 77 | public function write($output) { 78 | return $this->_write('TraceResponse', self::$_TSPEC, $output); 79 | } 80 | 81 | } 82 | 83 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Crossdock/TracedServiceClient.php: -------------------------------------------------------------------------------- 1 | input_ = $input; 27 | $this->output_ = $output ? $output : $input; 28 | } 29 | 30 | public function startTrace(\Jaeger\Thrift\Crossdock\StartTraceRequest $request) 31 | { 32 | $this->send_startTrace($request); 33 | return $this->recv_startTrace(); 34 | } 35 | 36 | public function send_startTrace(\Jaeger\Thrift\Crossdock\StartTraceRequest $request) 37 | { 38 | $args = new \Jaeger\Thrift\Crossdock\TracedService_startTrace_args(); 39 | $args->request = $request; 40 | $bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary'); 41 | if ($bin_accel) 42 | { 43 | thrift_protocol_write_binary($this->output_, 'startTrace', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite()); 44 | } 45 | else 46 | { 47 | $this->output_->writeMessageBegin('startTrace', TMessageType::CALL, $this->seqid_); 48 | $args->write($this->output_); 49 | $this->output_->writeMessageEnd(); 50 | $this->output_->getTransport()->flush(); 51 | } 52 | } 53 | 54 | public function recv_startTrace() 55 | { 56 | $bin_accel = ($this->input_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_read_binary'); 57 | if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, '\Jaeger\Thrift\Crossdock\TracedService_startTrace_result', $this->input_->isStrictRead()); 58 | else 59 | { 60 | $rseqid = 0; 61 | $fname = null; 62 | $mtype = 0; 63 | 64 | $this->input_->readMessageBegin($fname, $mtype, $rseqid); 65 | if ($mtype == TMessageType::EXCEPTION) { 66 | $x = new TApplicationException(); 67 | $x->read($this->input_); 68 | $this->input_->readMessageEnd(); 69 | throw $x; 70 | } 71 | $result = new \Jaeger\Thrift\Crossdock\TracedService_startTrace_result(); 72 | $result->read($this->input_); 73 | $this->input_->readMessageEnd(); 74 | } 75 | if ($result->success !== null) { 76 | return $result->success; 77 | } 78 | throw new \Exception("startTrace failed: unknown result"); 79 | } 80 | 81 | public function joinTrace(\Jaeger\Thrift\Crossdock\JoinTraceRequest $request) 82 | { 83 | $this->send_joinTrace($request); 84 | return $this->recv_joinTrace(); 85 | } 86 | 87 | public function send_joinTrace(\Jaeger\Thrift\Crossdock\JoinTraceRequest $request) 88 | { 89 | $args = new \Jaeger\Thrift\Crossdock\TracedService_joinTrace_args(); 90 | $args->request = $request; 91 | $bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary'); 92 | if ($bin_accel) 93 | { 94 | thrift_protocol_write_binary($this->output_, 'joinTrace', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite()); 95 | } 96 | else 97 | { 98 | $this->output_->writeMessageBegin('joinTrace', TMessageType::CALL, $this->seqid_); 99 | $args->write($this->output_); 100 | $this->output_->writeMessageEnd(); 101 | $this->output_->getTransport()->flush(); 102 | } 103 | } 104 | 105 | public function recv_joinTrace() 106 | { 107 | $bin_accel = ($this->input_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_read_binary'); 108 | if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, '\Jaeger\Thrift\Crossdock\TracedService_joinTrace_result', $this->input_->isStrictRead()); 109 | else 110 | { 111 | $rseqid = 0; 112 | $fname = null; 113 | $mtype = 0; 114 | 115 | $this->input_->readMessageBegin($fname, $mtype, $rseqid); 116 | if ($mtype == TMessageType::EXCEPTION) { 117 | $x = new TApplicationException(); 118 | $x->read($this->input_); 119 | $this->input_->readMessageEnd(); 120 | throw $x; 121 | } 122 | $result = new \Jaeger\Thrift\Crossdock\TracedService_joinTrace_result(); 123 | $result->read($this->input_); 124 | $this->input_->readMessageEnd(); 125 | } 126 | if ($result->success !== null) { 127 | return $result->success; 128 | } 129 | throw new \Exception("joinTrace failed: unknown result"); 130 | } 131 | 132 | } 133 | 134 | 135 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Crossdock/TracedServiceIf.php: -------------------------------------------------------------------------------- 1 | array( 24 | 'var' => 'request', 25 | 'isRequired' => false, 26 | 'type' => TType::STRUCT, 27 | 'class' => '\Jaeger\Thrift\Crossdock\JoinTraceRequest', 28 | ), 29 | ); 30 | 31 | /** 32 | * @var \Jaeger\Thrift\Crossdock\JoinTraceRequest 33 | */ 34 | public $request = null; 35 | 36 | public function __construct($vals=null) { 37 | if (is_array($vals)) { 38 | parent::__construct(self::$_TSPEC, $vals); 39 | } 40 | } 41 | 42 | public function getName() { 43 | return 'TracedService_joinTrace_args'; 44 | } 45 | 46 | public function read($input) 47 | { 48 | return $this->_read('TracedService_joinTrace_args', self::$_TSPEC, $input); 49 | } 50 | 51 | public function write($output) { 52 | return $this->_write('TracedService_joinTrace_args', self::$_TSPEC, $output); 53 | } 54 | 55 | } 56 | 57 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Crossdock/TracedService_joinTrace_result.php: -------------------------------------------------------------------------------- 1 | array( 24 | 'var' => 'success', 25 | 'isRequired' => false, 26 | 'type' => TType::STRUCT, 27 | 'class' => '\Jaeger\Thrift\Crossdock\TraceResponse', 28 | ), 29 | ); 30 | 31 | /** 32 | * @var \Jaeger\Thrift\Crossdock\TraceResponse 33 | */ 34 | public $success = null; 35 | 36 | public function __construct($vals=null) { 37 | if (is_array($vals)) { 38 | parent::__construct(self::$_TSPEC, $vals); 39 | } 40 | } 41 | 42 | public function getName() { 43 | return 'TracedService_joinTrace_result'; 44 | } 45 | 46 | public function read($input) 47 | { 48 | return $this->_read('TracedService_joinTrace_result', self::$_TSPEC, $input); 49 | } 50 | 51 | public function write($output) { 52 | return $this->_write('TracedService_joinTrace_result', self::$_TSPEC, $output); 53 | } 54 | 55 | } 56 | 57 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Crossdock/TracedService_startTrace_args.php: -------------------------------------------------------------------------------- 1 | array( 24 | 'var' => 'request', 25 | 'isRequired' => false, 26 | 'type' => TType::STRUCT, 27 | 'class' => '\Jaeger\Thrift\Crossdock\StartTraceRequest', 28 | ), 29 | ); 30 | 31 | /** 32 | * @var \Jaeger\Thrift\Crossdock\StartTraceRequest 33 | */ 34 | public $request = null; 35 | 36 | public function __construct($vals=null) { 37 | if (is_array($vals)) { 38 | parent::__construct(self::$_TSPEC, $vals); 39 | } 40 | } 41 | 42 | public function getName() { 43 | return 'TracedService_startTrace_args'; 44 | } 45 | 46 | public function read($input) 47 | { 48 | return $this->_read('TracedService_startTrace_args', self::$_TSPEC, $input); 49 | } 50 | 51 | public function write($output) { 52 | return $this->_write('TracedService_startTrace_args', self::$_TSPEC, $output); 53 | } 54 | 55 | } 56 | 57 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Crossdock/TracedService_startTrace_result.php: -------------------------------------------------------------------------------- 1 | array( 24 | 'var' => 'success', 25 | 'isRequired' => false, 26 | 'type' => TType::STRUCT, 27 | 'class' => '\Jaeger\Thrift\Crossdock\TraceResponse', 28 | ), 29 | ); 30 | 31 | /** 32 | * @var \Jaeger\Thrift\Crossdock\TraceResponse 33 | */ 34 | public $success = null; 35 | 36 | public function __construct($vals=null) { 37 | if (is_array($vals)) { 38 | parent::__construct(self::$_TSPEC, $vals); 39 | } 40 | } 41 | 42 | public function getName() { 43 | return 'TracedService_startTrace_result'; 44 | } 45 | 46 | public function read($input) 47 | { 48 | return $this->_read('TracedService_startTrace_result', self::$_TSPEC, $input); 49 | } 50 | 51 | public function write($output) { 52 | return $this->_write('TracedService_startTrace_result', self::$_TSPEC, $output); 53 | } 54 | 55 | } 56 | 57 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Crossdock/Transport.php: -------------------------------------------------------------------------------- 1 | 'HTTP', 26 | 1 => 'TCHANNEL', 27 | 2 => 'DUMMY', 28 | ); 29 | } 30 | 31 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Log.php: -------------------------------------------------------------------------------- 1 | array( 25 | 'var' => 'timestamp', 26 | 'isRequired' => true, 27 | 'type' => TType::I64, 28 | ), 29 | 2 => array( 30 | 'var' => 'fields', 31 | 'isRequired' => true, 32 | 'type' => TType::LST, 33 | 'etype' => TType::STRUCT, 34 | 'elem' => array( 35 | 'type' => TType::STRUCT, 36 | 'class' => '\Jaeger\Thrift\Tag', 37 | ), 38 | ), 39 | ); 40 | 41 | /** 42 | * @var int 43 | */ 44 | public $timestamp = null; 45 | /** 46 | * @var \Jaeger\Thrift\Tag[] 47 | */ 48 | public $fields = null; 49 | 50 | public function __construct($vals=null) { 51 | if (is_array($vals)) { 52 | parent::__construct(self::$_TSPEC, $vals); 53 | } 54 | } 55 | 56 | public function getName() { 57 | return 'Log'; 58 | } 59 | 60 | public function read($input) 61 | { 62 | return $this->_read('Log', self::$_TSPEC, $input); 63 | } 64 | 65 | public function write($output) { 66 | return $this->_write('Log', self::$_TSPEC, $output); 67 | } 68 | 69 | } 70 | 71 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Process.php: -------------------------------------------------------------------------------- 1 | array( 25 | 'var' => 'serviceName', 26 | 'isRequired' => true, 27 | 'type' => TType::STRING, 28 | ), 29 | 2 => array( 30 | 'var' => 'tags', 31 | 'isRequired' => false, 32 | 'type' => TType::LST, 33 | 'etype' => TType::STRUCT, 34 | 'elem' => array( 35 | 'type' => TType::STRUCT, 36 | 'class' => '\Jaeger\Thrift\Tag', 37 | ), 38 | ), 39 | ); 40 | 41 | /** 42 | * @var string 43 | */ 44 | public $serviceName = null; 45 | /** 46 | * @var \Jaeger\Thrift\Tag[] 47 | */ 48 | public $tags = null; 49 | 50 | public function __construct($vals=null) { 51 | if (is_array($vals)) { 52 | parent::__construct(self::$_TSPEC, $vals); 53 | } 54 | } 55 | 56 | public function getName() { 57 | return 'Process'; 58 | } 59 | 60 | public function read($input) 61 | { 62 | return $this->_read('Process', self::$_TSPEC, $input); 63 | } 64 | 65 | public function write($output) { 66 | return $this->_write('Process', self::$_TSPEC, $output); 67 | } 68 | 69 | } 70 | 71 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Span.php: -------------------------------------------------------------------------------- 1 | array( 25 | 'var' => 'traceIdLow', 26 | 'isRequired' => true, 27 | 'type' => TType::I64, 28 | ), 29 | 2 => array( 30 | 'var' => 'traceIdHigh', 31 | 'isRequired' => true, 32 | 'type' => TType::I64, 33 | ), 34 | 3 => array( 35 | 'var' => 'spanId', 36 | 'isRequired' => true, 37 | 'type' => TType::I64, 38 | ), 39 | 4 => array( 40 | 'var' => 'parentSpanId', 41 | 'isRequired' => true, 42 | 'type' => TType::I64, 43 | ), 44 | 5 => array( 45 | 'var' => 'operationName', 46 | 'isRequired' => true, 47 | 'type' => TType::STRING, 48 | ), 49 | 6 => array( 50 | 'var' => 'references', 51 | 'isRequired' => false, 52 | 'type' => TType::LST, 53 | 'etype' => TType::STRUCT, 54 | 'elem' => array( 55 | 'type' => TType::STRUCT, 56 | 'class' => '\Jaeger\Thrift\SpanRef', 57 | ), 58 | ), 59 | 7 => array( 60 | 'var' => 'flags', 61 | 'isRequired' => true, 62 | 'type' => TType::I32, 63 | ), 64 | 8 => array( 65 | 'var' => 'startTime', 66 | 'isRequired' => true, 67 | 'type' => TType::I64, 68 | ), 69 | 9 => array( 70 | 'var' => 'duration', 71 | 'isRequired' => true, 72 | 'type' => TType::I64, 73 | ), 74 | 10 => array( 75 | 'var' => 'tags', 76 | 'isRequired' => false, 77 | 'type' => TType::LST, 78 | 'etype' => TType::STRUCT, 79 | 'elem' => array( 80 | 'type' => TType::STRUCT, 81 | 'class' => '\Jaeger\Thrift\Tag', 82 | ), 83 | ), 84 | 11 => array( 85 | 'var' => 'logs', 86 | 'isRequired' => false, 87 | 'type' => TType::LST, 88 | 'etype' => TType::STRUCT, 89 | 'elem' => array( 90 | 'type' => TType::STRUCT, 91 | 'class' => '\Jaeger\Thrift\Log', 92 | ), 93 | ), 94 | ); 95 | 96 | /** 97 | * @var int 98 | */ 99 | public $traceIdLow = null; 100 | /** 101 | * @var int 102 | */ 103 | public $traceIdHigh = null; 104 | /** 105 | * @var int 106 | */ 107 | public $spanId = null; 108 | /** 109 | * @var int 110 | */ 111 | public $parentSpanId = null; 112 | /** 113 | * @var string 114 | */ 115 | public $operationName = null; 116 | /** 117 | * @var \Jaeger\Thrift\SpanRef[] 118 | */ 119 | public $references = null; 120 | /** 121 | * @var int 122 | */ 123 | public $flags = null; 124 | /** 125 | * @var int 126 | */ 127 | public $startTime = null; 128 | /** 129 | * @var int 130 | */ 131 | public $duration = null; 132 | /** 133 | * @var \Jaeger\Thrift\Tag[] 134 | */ 135 | public $tags = null; 136 | /** 137 | * @var \Jaeger\Thrift\Log[] 138 | */ 139 | public $logs = null; 140 | 141 | public function __construct($vals=null) { 142 | if (is_array($vals)) { 143 | parent::__construct(self::$_TSPEC, $vals); 144 | } 145 | } 146 | 147 | public function getName() { 148 | return 'Span'; 149 | } 150 | 151 | public function read($input) 152 | { 153 | return $this->_read('Span', self::$_TSPEC, $input); 154 | } 155 | 156 | public function write($output) { 157 | return $this->_write('Span', self::$_TSPEC, $output); 158 | } 159 | 160 | } 161 | 162 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/SpanRef.php: -------------------------------------------------------------------------------- 1 | array( 25 | 'var' => 'refType', 26 | 'isRequired' => true, 27 | 'type' => TType::I32, 28 | ), 29 | 2 => array( 30 | 'var' => 'traceIdLow', 31 | 'isRequired' => true, 32 | 'type' => TType::I64, 33 | ), 34 | 3 => array( 35 | 'var' => 'traceIdHigh', 36 | 'isRequired' => true, 37 | 'type' => TType::I64, 38 | ), 39 | 4 => array( 40 | 'var' => 'spanId', 41 | 'isRequired' => true, 42 | 'type' => TType::I64, 43 | ), 44 | ); 45 | 46 | /** 47 | * @var int 48 | */ 49 | public $refType = null; 50 | /** 51 | * @var int 52 | */ 53 | public $traceIdLow = null; 54 | /** 55 | * @var int 56 | */ 57 | public $traceIdHigh = null; 58 | /** 59 | * @var int 60 | */ 61 | public $spanId = null; 62 | 63 | public function __construct($vals=null) { 64 | if (is_array($vals)) { 65 | parent::__construct(self::$_TSPEC, $vals); 66 | } 67 | } 68 | 69 | public function getName() { 70 | return 'SpanRef'; 71 | } 72 | 73 | public function read($input) 74 | { 75 | return $this->_read('SpanRef', self::$_TSPEC, $input); 76 | } 77 | 78 | public function write($output) { 79 | return $this->_write('SpanRef', self::$_TSPEC, $output); 80 | } 81 | 82 | } 83 | 84 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/SpanRefType.php: -------------------------------------------------------------------------------- 1 | 'CHILD_OF', 25 | 1 => 'FOLLOWS_FROM', 26 | ); 27 | } 28 | 29 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/Tag.php: -------------------------------------------------------------------------------- 1 | array( 25 | 'var' => 'key', 26 | 'isRequired' => true, 27 | 'type' => TType::STRING, 28 | ), 29 | 2 => array( 30 | 'var' => 'vType', 31 | 'isRequired' => true, 32 | 'type' => TType::I32, 33 | ), 34 | 3 => array( 35 | 'var' => 'vStr', 36 | 'isRequired' => false, 37 | 'type' => TType::STRING, 38 | ), 39 | 4 => array( 40 | 'var' => 'vDouble', 41 | 'isRequired' => false, 42 | 'type' => TType::DOUBLE, 43 | ), 44 | 5 => array( 45 | 'var' => 'vBool', 46 | 'isRequired' => false, 47 | 'type' => TType::BOOL, 48 | ), 49 | 6 => array( 50 | 'var' => 'vLong', 51 | 'isRequired' => false, 52 | 'type' => TType::I64, 53 | ), 54 | 7 => array( 55 | 'var' => 'vBinary', 56 | 'isRequired' => false, 57 | 'type' => TType::STRING, 58 | ), 59 | ); 60 | 61 | /** 62 | * @var string 63 | */ 64 | public $key = null; 65 | /** 66 | * @var int 67 | */ 68 | public $vType = null; 69 | /** 70 | * @var string 71 | */ 72 | public $vStr = null; 73 | /** 74 | * @var double 75 | */ 76 | public $vDouble = null; 77 | /** 78 | * @var bool 79 | */ 80 | public $vBool = null; 81 | /** 82 | * @var int 83 | */ 84 | public $vLong = null; 85 | /** 86 | * @var string 87 | */ 88 | public $vBinary = null; 89 | 90 | public function __construct($vals=null) { 91 | if (is_array($vals)) { 92 | parent::__construct(self::$_TSPEC, $vals); 93 | } 94 | } 95 | 96 | public function getName() { 97 | return 'Tag'; 98 | } 99 | 100 | public function read($input) 101 | { 102 | return $this->_read('Tag', self::$_TSPEC, $input); 103 | } 104 | 105 | public function write($output) { 106 | return $this->_write('Tag', self::$_TSPEC, $output); 107 | } 108 | 109 | } 110 | 111 | -------------------------------------------------------------------------------- /src/Jaeger/Thrift/TagType.php: -------------------------------------------------------------------------------- 1 | 'STRING', 28 | 1 => 'DOUBLE', 29 | 2 => 'BOOL', 30 | 3 => 'LONG', 31 | 4 => 'BINARY', 32 | ); 33 | } 34 | 35 | -------------------------------------------------------------------------------- /src/Jaeger/ThriftUdpTransport.php: -------------------------------------------------------------------------------- 1 | setLogger($logger); 42 | 43 | $this->config = $config; 44 | 45 | $ipProtocol = $this->ipProtocolVersion(); 46 | $this->socket = $this->createSocket($ipProtocol); 47 | 48 | $this->host = $host; 49 | $this->port = $port; 50 | } 51 | 52 | protected function setLogger($logger) 53 | { 54 | $this->logger = $logger ?? new NullLogger(); 55 | } 56 | 57 | protected function createSocket(string $ipProtocol) 58 | { 59 | $socketDomain = AF_INET; 60 | if ($ipProtocol === Config::IPV6) { 61 | $socketDomain = AF_INET6; 62 | } 63 | 64 | $socket = @socket_create($socketDomain, SOCK_DGRAM, SOL_UDP); 65 | if ($socket === false) { 66 | $this->handleSocketError("socket_create failed"); 67 | } 68 | return $socket; 69 | } 70 | 71 | protected function ipProtocolVersion() 72 | { 73 | if (!empty($this->config)) { 74 | return $this->config->ipProtocolVersion(); 75 | } 76 | return ""; 77 | } 78 | 79 | /** 80 | * Whether this transport is open. 81 | * 82 | * @return boolean true if open 83 | */ 84 | public function isOpen() 85 | { 86 | return $this->socket !== null; 87 | } 88 | 89 | /** 90 | * Open the transport for reading/writing 91 | */ 92 | public function open() 93 | { 94 | $ok = @socket_connect($this->socket, $this->host, $this->port); 95 | if ($ok === false) { 96 | $this->handleSocketError('socket_connect failed'); 97 | } 98 | } 99 | 100 | /** 101 | * Close the transport. 102 | */ 103 | public function close() 104 | { 105 | if (is_null($this->socket)) { 106 | $this->logger->warning("can't close empty socket"); 107 | return ; 108 | } 109 | 110 | @socket_close($this->socket); 111 | $this->socket = null; 112 | } 113 | 114 | /** 115 | * Read some data into the array. 116 | * 117 | * @todo 118 | * 119 | * @param int $len How much to read 120 | * @return string The data that has been read 121 | */ 122 | public function read($len) 123 | { 124 | } 125 | 126 | /** 127 | * Writes the given data out. 128 | * 129 | * @param string $buf The data to write 130 | */ 131 | public function write($buf) 132 | { 133 | if (!$this->isOpen()) { 134 | $this->logger->warning('transport is closed'); 135 | return ; 136 | } 137 | 138 | $ok = @socket_write($this->socket, $buf); 139 | if ($ok === false) { 140 | $this->handleSocketError("socket_write failed"); 141 | } 142 | } 143 | 144 | public function handleSocketError($msg) 145 | { 146 | $errorCode = socket_last_error($this->socket); 147 | $errorMsg = socket_strerror($errorCode); 148 | 149 | $this->logger->warning(sprintf('%s: [code - %d] %s', $msg, $errorCode, $errorMsg)); 150 | } 151 | } 152 | -------------------------------------------------------------------------------- /src/Jaeger/Util/RateLimiter.php: -------------------------------------------------------------------------------- 1 | cache = $cache; 49 | $this->balance = $this->cache->getItem($currentBalanceKey); 50 | $this->lastTick = $this->cache->getItem($lastTickKey); 51 | } 52 | 53 | /** 54 | * @param $itemCost 55 | * @return bool 56 | */ 57 | public function checkCredit($itemCost) 58 | { 59 | if (!$this->creditsPerNanosecond) { 60 | return false; 61 | } 62 | 63 | list($lastTick, $balance) = $this->getState(); 64 | 65 | if (!$lastTick) { 66 | $this->saveState(hrtime(true), 0); 67 | return true; 68 | } 69 | 70 | $currentTick = hrtime(true); 71 | $elapsedTime = $currentTick - $lastTick; 72 | $balance += $elapsedTime * $this->creditsPerNanosecond; 73 | if ($balance > $this->maxBalance) { 74 | $balance = $this->maxBalance; 75 | } 76 | 77 | $result = false; 78 | if ($balance >= $itemCost) { 79 | $balance -= $itemCost; 80 | $result = true; 81 | } 82 | 83 | $this->saveState($currentTick, $balance); 84 | 85 | return $result; 86 | } 87 | 88 | 89 | /** 90 | * Initializes limiter costs and boundaries 91 | * 92 | * @param float $creditsPerNanosecond 93 | * @param float $maxBalance 94 | */ 95 | public function initialize(float $creditsPerNanosecond, float $maxBalance) 96 | { 97 | $this->creditsPerNanosecond = $creditsPerNanosecond; 98 | $this->maxBalance = $maxBalance; 99 | } 100 | 101 | /** 102 | * Method loads last tick and current balance from cache 103 | * 104 | * @return array [$lastTick, $balance] 105 | */ 106 | private function getState() : array 107 | { 108 | return [ 109 | $this->lastTick->get(), 110 | $this->balance->get() 111 | ]; 112 | } 113 | 114 | /** 115 | * Method saves last tick and current balance into cache 116 | * 117 | * @param integer $lastTick 118 | * @param float $balance 119 | */ 120 | private function saveState($lastTick, $balance) 121 | { 122 | $this->lastTick->set($lastTick); 123 | $this->balance->set($balance); 124 | $this->cache->saveDeferred($this->lastTick); 125 | $this->cache->saveDeferred($this->balance); 126 | $this->cache->commit(); 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /tests/Jaeger/Codec/ZipkinCodecTest.php: -------------------------------------------------------------------------------- 1 | codec = new ZipkinCodec; 19 | } 20 | 21 | function testInject() 22 | { 23 | // Given 24 | $traceId = 123; 25 | $spanId = 456; 26 | $parentId = 789; 27 | 28 | $spanContext = new SpanContext( 29 | $traceId, 30 | $spanId, 31 | $parentId, 32 | SAMPLED_FLAG 33 | ); 34 | $carrier = []; 35 | 36 | // When 37 | $this->codec->inject($spanContext, $carrier); 38 | 39 | // Then 40 | $this->assertEquals('7b', $carrier['X-B3-TraceId']); 41 | $this->assertEquals('1c8', $carrier['X-B3-SpanId']); 42 | $this->assertEquals('315', $carrier['X-B3-ParentSpanId']); 43 | $this->assertSame(1, $carrier['X-B3-Flags']); 44 | } 45 | 46 | function testExtract() 47 | { 48 | // Given 49 | $carrier = [ 50 | 'x-b3-traceid' => 'a53bf337d7e455e1', 51 | 'x-b3-spanid' => '153bf227d1f455a1', 52 | 'x-b3-parentspanid' => 'a53bf337d7e455e1', 53 | 'x-b3-flags' => '1', 54 | ]; 55 | 56 | // When 57 | $spanContext = $this->codec->extract($carrier); 58 | 59 | // Then 60 | $this->assertEquals(new SpanContext( 61 | '-6540366612654696991', 62 | '1530082751262512545', 63 | '-6540366612654696991', 64 | DEBUG_FLAG 65 | ), $spanContext); 66 | } 67 | 68 | function testExtractWithoutParentSpanId() 69 | { 70 | // Given 71 | $carrier = [ 72 | 'x-b3-traceid' => '8d824d69da5f50d9', 73 | 'x-b3-spanid' => '8d824d69da5f50d9', 74 | 'x-b3-flags' => '1', 75 | ]; 76 | 77 | // When 78 | $spanContext = $this->codec->extract($carrier); 79 | 80 | // Then 81 | $this->assertEquals(new SpanContext( 82 | '-8249946450358742823', 83 | '-8249946450358742823', 84 | '0', 85 | DEBUG_FLAG 86 | ), $spanContext); 87 | } 88 | 89 | function testExtractInvalidHeader() 90 | { 91 | // Given 92 | $carrier = [ 93 | 'x-b3-traceid' => 'zzzz', 94 | 'x-b3-spanid' => '463ac35c9f6413ad48485a3953bb6124', 95 | 'x-b3-flags' => '1', 96 | ]; 97 | 98 | // When 99 | $spanContext = $this->codec->extract($carrier); 100 | 101 | // Then 102 | $this->assertEquals(null, $spanContext); 103 | } 104 | } 105 | -------------------------------------------------------------------------------- /tests/Jaeger/Logger/StackLogger.php: -------------------------------------------------------------------------------- 1 | messagesStack[] = $message; 17 | } 18 | 19 | public function getLastMessage() { 20 | return array_pop($this->messagesStack); 21 | } 22 | 23 | public function getMessagesCount() { 24 | return count($this->messagesStack); 25 | } 26 | 27 | public function clear() { 28 | $this->messagesStack = []; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /tests/Jaeger/Reporter/CompositeReporterTest.php: -------------------------------------------------------------------------------- 1 | childReporter1 = $this->createMock(ReporterInterface::class); 27 | $this->childReporter2 = $this->createMock(ReporterInterface::class); 28 | 29 | $this->reporter = new CompositeReporter($this->childReporter1, $this->childReporter2); 30 | } 31 | 32 | /** @test */ 33 | public function shouldReportSpan() 34 | { 35 | /** @var \Jaeger\Span|\PHPUnit\Framework\MockObject\MockObject $span */ 36 | $span = $this->createMock(Span::class); 37 | 38 | $this->childReporter1->expects($this->once())->method('reportSpan')->with($span); 39 | $this->childReporter2->expects($this->once())->method('reportSpan')->with($span); 40 | 41 | $this->reporter->reportSpan($span); 42 | } 43 | 44 | /** @test */ 45 | public function shouldCloseReporter() 46 | { 47 | $this->childReporter1->expects($this->once())->method('close'); 48 | $this->childReporter2->expects($this->once())->method('close'); 49 | 50 | $this->reporter->close(); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /tests/Jaeger/Reporter/InMemoryReporterTest.php: -------------------------------------------------------------------------------- 1 | createMock(Span::class); 16 | $reporter = new InMemoryReporter(); 17 | 18 | $reporter->reportSpan($span); 19 | $reporter->close(); 20 | 21 | $spans = $reporter->getSpans(); 22 | $this->assertEquals([$span], $spans); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /tests/Jaeger/Reporter/LoggingReporterTest.php: -------------------------------------------------------------------------------- 1 | createMock(NullLogger::class); 20 | $span = $this->createMock(Span::class); 21 | 22 | $reporter = new LoggingReporter($logger); 23 | 24 | $logger->expects($this->once()) 25 | ->method('debug') 26 | ->with($this->stringStartsWith('Reporting span')); 27 | 28 | $reporter->reportSpan($span); 29 | $reporter->close(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /tests/Jaeger/Reporter/NullReporterTest.php: -------------------------------------------------------------------------------- 1 | createMock(Span::class); 20 | 21 | $reporter = new NullReporter(); 22 | 23 | $reporter->reportSpan($span); 24 | $reporter->close(); 25 | 26 | // Only needed to avoid PhpUnit message: "This test did not perform any assertions" 27 | $this->assertTrue(true); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /tests/Jaeger/Reporter/RemoteReporterTest.php: -------------------------------------------------------------------------------- 1 | transport = $this->createMock(UdpSender::class); 24 | $this->reporter = new RemoteReporter($this->transport); 25 | } 26 | 27 | /** @test */ 28 | public function shouldReportSpan() 29 | { 30 | /** @var Span|\PHPUnit\Framework\MockObject\MockObject $span */ 31 | $span = $this->createMock(Span::class); 32 | 33 | $this->transport->expects($this->once())->method('append')->with($span); 34 | 35 | $this->reporter->reportSpan($span); 36 | } 37 | 38 | /** @test */ 39 | public function shouldCloseReporter() 40 | { 41 | $this->transport->expects($this->once())->method('flush'); 42 | $this->transport->expects($this->once())->method('close'); 43 | 44 | $this->reporter->close(); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /tests/Jaeger/Sampler/ConstSamplerTest.php: -------------------------------------------------------------------------------- 1 | isSampled($traceId); 24 | 25 | $this->assertEquals($decision, $sampled); 26 | $this->assertEquals([ 27 | SAMPLER_TYPE_TAG_KEY => SAMPLER_TYPE_CONST, 28 | SAMPLER_PARAM_TAG_KEY => $decision, 29 | ], $tags); 30 | 31 | $sampler->close(); 32 | } 33 | 34 | public function samplerProvider() 35 | { 36 | return [ 37 | [true, 1], 38 | [true, PHP_INT_MAX], 39 | [false, 1], 40 | [false, PHP_INT_MAX], 41 | ]; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /tests/Jaeger/Sampler/ProbablisticSamplerTest.php: -------------------------------------------------------------------------------- 1 | isSampled($traceId); 26 | 27 | $this->assertEquals($decision, $sampled); 28 | $this->assertEquals([ 29 | SAMPLER_TYPE_TAG_KEY => SAMPLER_TYPE_PROBABILISTIC, 30 | SAMPLER_PARAM_TAG_KEY => $rate, 31 | ], $tags); 32 | 33 | $sampler->close(); 34 | } 35 | 36 | public function samplerProvider() 37 | { 38 | return [ 39 | [1.0, PHP_INT_MAX-1, true], 40 | [0, 0, false], 41 | [0.5, PHP_INT_MIN + 10, true], 42 | [0.5, PHP_INT_MAX - 10, false], 43 | ]; 44 | } 45 | 46 | /** 47 | * @test 48 | * @dataProvider rateProvider 49 | * @param mixed $rate 50 | */ 51 | public function shouldThrowOutOfBoundsExceptionInCaseOfInvalidRate($rate) 52 | { 53 | $this->expectException(OutOfBoundsException::class); 54 | $this->expectExceptionMessage('Sampling rate must be between 0.0 and 1.0.'); 55 | 56 | new ProbabilisticSampler($rate); 57 | } 58 | 59 | public function rateProvider() 60 | { 61 | return [ 62 | [1.1], 63 | [-0.1], 64 | [PHP_INT_MAX], 65 | [PHP_INT_MIN], 66 | ]; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /tests/Jaeger/Sampler/RateLimitSamplerTest.php: -------------------------------------------------------------------------------- 1 | isSampled(); 30 | list($sampled, $tags) = $sampler->isSampled(); 31 | $this->assertEquals($decision, $sampled); 32 | $this->assertEquals([ 33 | SAMPLER_TYPE_TAG_KEY => SAMPLER_TYPE_RATE_LIMITING, 34 | SAMPLER_PARAM_TAG_KEY => $maxTracesPerSecond, 35 | ], $tags); 36 | 37 | $sampler->close(); 38 | } 39 | 40 | public function maxRateProvider() 41 | { 42 | return [ 43 | [1000000, true], 44 | [1, false], 45 | [0, false], 46 | ]; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /tests/Jaeger/ScopeManagerTest.php: -------------------------------------------------------------------------------- 1 | scopeManager = new ScopeManager(); 19 | } 20 | 21 | function testActivate() 22 | { 23 | $span = $this->createMock(Span::class); 24 | 25 | $scope = $this->scopeManager->activate($span, true); 26 | 27 | $this->assertEquals($scope->getSpan(), $span); 28 | } 29 | 30 | function testAbleGetActiveScope() 31 | { 32 | $span = $this->createMock(Span::class); 33 | 34 | $this->assertNull($this->scopeManager->getActive()); 35 | $scope = $this->scopeManager->activate($span, false); 36 | 37 | $this->assertEquals($scope, $this->scopeManager->getActive()); 38 | } 39 | 40 | function testScopeClosingDeactivates() 41 | { 42 | $span = $this->createMock(Span::class); 43 | 44 | $scope = $this->scopeManager->activate($span, false); 45 | $scope->close(); 46 | 47 | $this->assertNull($this->scopeManager->getActive()); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /tests/Jaeger/ScopeTest.php: -------------------------------------------------------------------------------- 1 | scopeManager = $this->createMock(ScopeManager::class); 25 | $this->span = $this->createMock(Span::class); 26 | } 27 | 28 | function testCloseDoNotFinishSpanOnClose() 29 | { 30 | $scope = new Scope($this->scopeManager, $this->span, false); 31 | 32 | $this->scopeManager->method('getActive')->willReturn($scope); 33 | $this->scopeManager->expects($this->once())->method('getActive'); 34 | $this->span->expects($this->never())->method('finish'); 35 | $this->scopeManager->expects($this->once())->method('setActive'); 36 | 37 | $scope->close(); 38 | } 39 | 40 | function testCloseFinishSpanOnClose() 41 | { 42 | $scope = new Scope($this->scopeManager, $this->span, true); 43 | 44 | $this->scopeManager->method('getActive')->willReturn($scope); 45 | $this->scopeManager->expects($this->once())->method('getActive'); 46 | $this->span->expects($this->once())->method('finish'); 47 | $this->scopeManager->expects($this->once())->method('setActive'); 48 | 49 | $scope->close(); 50 | } 51 | 52 | function testGetSpan() 53 | { 54 | $scope = new Scope($this->scopeManager, $this->span, false); 55 | 56 | $this->assertEquals($this->span, $scope->getSpan()); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /tests/Jaeger/Sender/JaegerThriftSenderTest.php: -------------------------------------------------------------------------------- 1 | createMock(Tracer::class); 26 | $tracer->method('getIpAddress')->willReturn(''); 27 | $tracer->method('getServiceName')->willReturn(''); 28 | 29 | $this->tracer = $tracer; 30 | 31 | $context = $this->createMock(SpanContext::class); 32 | $this->context = $context; 33 | } 34 | 35 | public function testFlush(): void 36 | { 37 | 38 | $span = $this->createMock(Span::class); 39 | $span->method('getOperationName')->willReturn('dummy-operation'); 40 | $span->method('getTracer')->willReturn($this->tracer); 41 | $span->method('getContext')->willReturn($this->context); 42 | 43 | $client = $this->createMock(AgentClient::class); 44 | $sender = new JaegerSender($client); 45 | $sender->setMaxBufferLength(64000); 46 | 47 | $client 48 | ->expects(self::exactly(1)) 49 | ->method('emitBatch'); 50 | 51 | $sender->append($span); 52 | $sender->append($span); 53 | $sender->append($span); 54 | 55 | self::assertEquals(3, $sender->flush()); 56 | } 57 | 58 | public function testEmitBatch() { 59 | $client = $this->createMock(AgentClient::class); 60 | $sender = new JaegerSender($client); 61 | $sender->setMaxBufferLength(64000); 62 | 63 | $span = $this->createMock(Span::class); 64 | $span->method('getOperationName')->willReturn('dummy-operation'); 65 | $span->method('getTracer')->willReturn($this->tracer); 66 | $span->method('getContext')->willReturn($this->context); 67 | 68 | $client 69 | ->expects($this->once()) 70 | ->method('emitBatch') 71 | ->with($this->callback(function ($batch) { 72 | /** @var Batch $batch */ 73 | $this->assertInstanceOf(Batch::class, $batch); 74 | $this->assertCount(1, $batch->spans); 75 | 76 | /** @var \Jaeger\Thrift\Span $span */ 77 | $span = $batch->spans[0]; 78 | $this->assertInstanceOf(\Jaeger\Thrift\Span::class, $span); 79 | $this->assertSame("dummy-operation", $span->operationName); 80 | 81 | return true; 82 | 83 | })); 84 | 85 | $sender->append($span); 86 | $this->assertEquals(1, $sender->flush()); 87 | } 88 | 89 | public function testMaxBufferLength() { 90 | $tracer = $this->createMock(Tracer::class); 91 | $tracer->method('getIpAddress')->willReturn(''); 92 | $tracer->method('getServiceName')->willReturn(''); 93 | 94 | $context = $this->createMock(SpanContext::class); 95 | 96 | $span = $this->createMock(Span::class); 97 | $span->method('getOperationName')->willReturn('dummy-operation'); 98 | $span->method('getTracer')->willReturn($tracer); 99 | $span->method('getContext')->willReturn($context); 100 | 101 | $client = $this->createMock(AgentClient::class); 102 | 103 | $mockBuilder = $this->getMockBuilder(JaegerSender::class); 104 | $mockMethods = ['emitJaegerBatch']; 105 | if (method_exists($mockBuilder, "onlyMethods")) { 106 | $mockBuilder = $mockBuilder->onlyMethods($mockMethods); 107 | } else { 108 | $mockBuilder = $mockBuilder->setMethods($mockMethods); 109 | } 110 | $sender = $mockBuilder->setConstructorArgs([$client])->getMock(); 111 | $sender->setMaxBufferLength(800); 112 | $sender->expects(self::exactly(2)) 113 | ->method('emitJaegerBatch') 114 | ->withConsecutive( 115 | [self::countOf(2)], 116 | [self::countOf(1)] 117 | ); 118 | 119 | // jaeger batch overhead parameter = 512 120 | $sender->append($span); // 512 + 143 < 800 - chunk 1 121 | $sender->append($span); // 512 + 143*2 => 798 < 800 - chunk 1 122 | $sender->append($span); // 512 + 143*3 > 800 - chunk 2 123 | 124 | self::assertEquals(3, $sender->flush()); 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /tests/Jaeger/Sender/UdpSenderTest.php: -------------------------------------------------------------------------------- 1 | client = $this->createMock(AgentClient::class); 29 | $this->sender = new UdpSender($this->client, 64000); 30 | } 31 | 32 | public function testMaxBufferLength(): void 33 | { 34 | $tracer = $this->createMock(Tracer::class); 35 | $tracer->method('getIpAddress')->willReturn(''); 36 | $tracer->method('getServiceName')->willReturn(''); 37 | 38 | $context = $this->createMock(SpanContext::class); 39 | 40 | $span = $this->createMock(Span::class); 41 | $span->method('getOperationName')->willReturn('dummy-operation'); 42 | $span->method('getTracer')->willReturn($tracer); 43 | $span->method('getContext')->willReturn($context); 44 | 45 | $sender = new UdpSender($this->client, 100); 46 | 47 | $this->client 48 | ->expects(self::exactly(2)) 49 | ->method('emitZipkinBatch') 50 | ->withConsecutive( 51 | [self::countOf(2)], 52 | [self::countOf(1)] 53 | ); 54 | 55 | // one span has a length of ~25 56 | $sender->append($span); // 30 + 25 < 100 - chunk 1 57 | $sender->append($span); // 30 + 25 * 2 < 100 - chunk 1 58 | $sender->append($span); // 30 + 25 * 3 > 100 - chunk 2 59 | 60 | self::assertEquals(3, $sender->flush()); 61 | } 62 | 63 | public function testFlush(): void 64 | { 65 | $this->assertEquals(0, $this->sender->flush()); 66 | 67 | $logTimeStamp = (int) (microtime(true) * 1000000); 68 | 69 | $tracer = $this->createMock(Tracer::class); 70 | $tracer->method('getIpAddress')->willReturn(''); 71 | $tracer->method('getServiceName')->willReturn(''); 72 | $context = $this->createMock(SpanContext::class); 73 | $span = $this->createMock(Span::class); 74 | $span->method('getTracer')->willReturn($tracer); 75 | $span->method('getContext')->willReturn($context); 76 | $span 77 | ->expects($this->atLeastOnce()) 78 | ->method('getLogs') 79 | ->willReturn([ 80 | [ 81 | 'timestamp' => $logTimeStamp, 82 | 'fields' => [ 83 | 'foo' => 'bar', 84 | ], 85 | ], 86 | ]); 87 | 88 | $this->client 89 | ->expects($this->once()) 90 | ->method('emitZipkinBatch') 91 | ->with($this->callback(function ($spans) use ($logTimeStamp) { 92 | $this->assertCount(1, $spans); 93 | 94 | /* @var $annotation ZipkinSpan */ 95 | $span = $spans[0]; 96 | $this->assertInstanceOf(ZipkinSpan::class, $span); 97 | $this->assertCount(1, $span->annotations); 98 | 99 | /* @var $annotation ZipkinAnnotation */ 100 | $annotation = $span->annotations[0]; 101 | $this->assertInstanceOf(ZipkinAnnotation::class, $annotation); 102 | $this->assertSame($logTimeStamp, $annotation->timestamp); 103 | $this->assertSame( 104 | json_encode([ 105 | 'foo' => 'bar', 106 | ]), 107 | $annotation->value 108 | ); 109 | 110 | return true; 111 | })); 112 | 113 | $this->sender->append($span); 114 | $this->assertEquals(1, $this->sender->flush()); 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /tests/Jaeger/SpanContextTest.php: -------------------------------------------------------------------------------- 1 | assertTrue($ctx->isDebugIdContainerOnly()); 14 | $this->assertEquals($ctx->getDebugId(), 'value1'); 15 | 16 | $ctx = new SpanContext(1, 2, 3, 1); 17 | $this->assertFalse($ctx->isDebugIdContainerOnly()); 18 | } 19 | 20 | /** 21 | * @dataProvider contextDataProvider 22 | */ 23 | public function testBaggageInit($traceId, $spanId, $parentId, $flags, $baggage, $expected) 24 | { 25 | $ctx = new SpanContext($traceId, $spanId, $parentId, $flags, $baggage); 26 | $this->assertEquals($expected, $ctx->getBaggage()); 27 | } 28 | 29 | public function contextDataProvider() 30 | { 31 | return [ 32 | [null, null, null, null, [], []], 33 | [null, null, null, null, null, []], 34 | [null, null, null, null, ['key' => 'val'], ['key' => 'val']], 35 | ]; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /tests/README.md: -------------------------------------------------------------------------------- 1 | # Jaeger Bindings for PHP OpenTracing API: Unit Tests 2 | 3 | Welcome to the Jaeger Testing Suite. 4 | 5 | This folder includes all the unit tests that test Jaeger components, ensuring that you enjoy a bug free library. 6 | 7 | ## Current PHP Support 8 | 9 | | version | status | 10 | |---------|--------| 11 | | 7.0 | ✔ | 12 | | 7.1 | ✔ | 13 | | 7.2 | ✔ | 14 | 15 | 16 | ## Getting Started 17 | 18 | This testing suite uses [Travis CI](https://travis-ci.org/) for each run. 19 | Every commit pushed to this repository will queue a build into the continuous integration service and will run all tests 20 | to ensure that everything is going well and the project is stable. 21 | 22 | The testing suite can be run on your own machine. The main dependency is [PHPUnit](https://phpunit.de/) 23 | which can be installed using [Composer](https://getcomposer.org/): 24 | 25 | ```bash 26 | # run this command from project root 27 | $ composer install 28 | ``` 29 | 30 | Then run the tests by calling command from the terminal as follows: 31 | 32 | ```bash 33 | $ composer test 34 | ``` 35 | 36 | ## Run Tests for Supported Versions 37 | 38 | There is also an ability to run tests for different PHP versions. To achieve this we offer use 39 | [docker](https://docs.docker.com/install/)-based approach: 40 | 41 | ```bash 42 | 43 | $ docker run --rm -it -v $(pwd):/usr/app php:7.0 ./usr/app/tests/php-test.sh 44 | 45 | $ docker run --rm -it -v $(pwd):/usr/app php:7.1 ./usr/app/tests/php-test.sh 46 | 47 | $ docker run --rm -it -v $(pwd):/usr/app php:7.2 ./usr/app/tests/php-test.sh 48 | ``` 49 | -------------------------------------------------------------------------------- /tests/php-test.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # trace ERR through pipes 4 | set -o pipefail 5 | 6 | # trace ERR through 'time command' and other functions 7 | set -o errtrace 8 | 9 | # set -u : exit the script if you try to use an uninitialised variable 10 | set -o nounset 11 | 12 | # set -e : exit the script if any statement returns a non-true return value 13 | set -o errexit 14 | 15 | # to avoid message: 16 | # "Do not run Composer as root/super user! See https://getcomposer.org/root for details" 17 | export COMPOSER_ALLOW_SUPERUSER=1 18 | 19 | export TERM=xterm-256color 20 | 21 | echo "[INFO]: Install OS dependencies..." 22 | apt-get update -yq > /dev/null 2>&1 23 | apt-get install -yq git wget unzip zip > /dev/null 2>&1 24 | 25 | echo "[INFO]: Install PHP extensions..." 26 | docker-php-ext-install bcmath sockets > /dev/null 2>&1 27 | pecl install hrtime > /dev/null 2>&1 28 | docker-php-ext-enable hrtime > /dev/null 2>&1 29 | 30 | echo "[INFO]: Install Xdebug to enable code coverage..." 31 | pecl install xdebug > /dev/null 2>&1 32 | docker-php-ext-enable xdebug > /dev/null 2>&1 33 | 34 | cd /tmp 35 | 36 | echo "[INFO]: Install Composer..." 37 | EXPECTED_SIGNATURE="$(wget -q -O - https://composer.github.io/installer.sig)" 38 | php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" 39 | ACTUAL_SIGNATURE="$(php -r "echo hash_file('SHA384', 'composer-setup.php');")" 40 | 41 | if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]; then 42 | >&2 echo '[ERROR]: Invalid installer signature' 43 | rm composer-setup.php 44 | exit 1 45 | fi 46 | 47 | php composer-setup.php --quiet 48 | rm composer-setup.php 49 | 50 | # this step is required to be able to overwrite composer.lock 51 | cp -R /usr/app /usr/tests 52 | 53 | cd /usr/tests 54 | rm -f composer.lock 55 | 56 | echo "[INFO]: Install library dependencies..." 57 | php /tmp/composer.phar install \ 58 | --no-interaction \ 59 | --no-ansi \ 60 | --no-progress \ 61 | --no-suggest 62 | 63 | echo -e "[INFO]: Run tests...\n" 64 | /tmp/composer.phar test 65 | --------------------------------------------------------------------------------