From 8f3646a9c93a06f76f6abb31020fdb74b4b1fc59 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 9 Apr 2023 20:50:33 +0300 Subject: [PATCH] exp: jaeger tracing --- backend.php | 33 +- classes/counters.php | 11 + classes/feeds.php | 8 + classes/pref/feeds.php | 4 + classes/rpc.php | 3 + classes/tracer.php | 49 + composer.json | 3 +- composer.lock | 259 +++++- vendor/autoload.php | 18 - vendor/composer/ClassLoader.php | 158 +--- vendor/composer/InstalledVersions.php | 564 +++++++++--- vendor/composer/LICENSE | 2 - vendor/composer/autoload_classmap.php | 2 +- vendor/composer/autoload_files.php | 9 +- vendor/composer/autoload_namespaces.php | 2 +- vendor/composer/autoload_psr4.php | 7 +- vendor/composer/autoload_real.php | 51 +- vendor/composer/autoload_static.php | 38 +- vendor/composer/installed.json | 270 ++++++ vendor/composer/installed.php | 845 +++++++++--------- .../jaeger-client-php/.editorconfig | 16 + .../.github/workflows/main.yaml | 44 + .../jonahgeorge/jaeger-client-php/.gitignore | 17 + .../jaeger-client-php/CONTRIBUTING.md | 3 + vendor/jonahgeorge/jaeger-client-php/LICENSE | 21 + .../jonahgeorge/jaeger-client-php/README.md | 219 +++++ .../jaeger-client-php/build/.gitignore | 2 + .../jaeger-client-php/composer.json | 62 ++ .../jaeger-client-php/examples/config.php | 26 + .../jaeger-client-php/examples/jaeger.php | 51 ++ .../jaeger-client-php/phpcs.xml.dist | 37 + .../jaeger-client-php/phpunit.xml.dist | 47 + .../jaeger-client-php/scripts/thrift-gen.sh | 27 + .../Jaeger/AgentClient/HttpAgentClient.php | 27 + .../src/Jaeger/Codec/BinaryCodec.php | 39 + .../src/Jaeger/Codec/CodecInterface.php | 36 + .../src/Jaeger/Codec/CodecUtility.php | 41 + .../src/Jaeger/Codec/TextCodec.php | 184 ++++ .../src/Jaeger/Codec/ZipkinCodec.php | 85 ++ .../jaeger-client-php/src/Jaeger/Config.php | 390 ++++++++ .../src/Jaeger/Constants.php | 100 +++ .../src/Jaeger/Mapper/SpanToJaegerMapper.php | 171 ++++ .../src/Jaeger/Reporter/CompositeReporter.php | 51 ++ .../src/Jaeger/Reporter/InMemoryReporter.php | 47 + .../src/Jaeger/Reporter/JaegerReporter.php | 35 + .../src/Jaeger/Reporter/LoggingReporter.php | 51 ++ .../src/Jaeger/Reporter/NullReporter.php | 32 + .../src/Jaeger/Reporter/RemoteReporter.php | 46 + .../src/Jaeger/Reporter/ReporterInterface.php | 28 + .../AbstractReporterFactory.php | 23 + .../JaegerHttpReporterFactory.php | 35 + .../ReporterFactory/JaegerReporterFactory.php | 44 + .../ReporterFactoryInterface.php | 10 + .../ReporterFactory/ZipkinReporterFactory.php | 46 + .../src/Jaeger/Sampler/ConstSampler.php | 68 ++ .../Jaeger/Sampler/ProbabilisticSampler.php | 88 ++ .../Jaeger/Sampler/RateLimitingSampler.php | 62 ++ .../src/Jaeger/Sampler/SamplerInterface.php | 29 + .../jaeger-client-php/src/Jaeger/Scope.php | 71 ++ .../src/Jaeger/ScopeManager.php | 45 + .../src/Jaeger/Sender/JaegerSender.php | 236 +++++ .../src/Jaeger/Sender/SenderInterface.php | 12 + .../src/Jaeger/Sender/UdpSender.php | 305 +++++++ .../jaeger-client-php/src/Jaeger/Span.php | 476 ++++++++++ .../src/Jaeger/SpanContext.php | 120 +++ .../src/Jaeger/Thrift/Agent/AgentClient.php | 76 ++ .../src/Jaeger/Thrift/Agent/AgentIf.php | 30 + .../Thrift/Agent/Agent_emitBatch_args.php | 56 ++ .../Agent/Agent_emitZipkinBatch_args.php | 60 ++ .../Agent/AggregationValidatorClient.php | 83 ++ .../Thrift/Agent/AggregationValidatorIf.php | 27 + ...ggregationValidator_validateTrace_args.php | 55 ++ ...regationValidator_validateTrace_result.php | 56 ++ .../Thrift/Agent/BaggageRestriction.php | 65 ++ .../Agent/BaggageRestrictionManagerClient.php | 83 ++ .../Agent/BaggageRestrictionManagerIf.php | 31 + ...ionManager_getBaggageRestrictions_args.php | 55 ++ ...nManager_getBaggageRestrictions_result.php | 60 ++ .../src/Jaeger/Thrift/Agent/Dependencies.php | 61 ++ .../Jaeger/Thrift/Agent/DependencyClient.php | 105 +++ .../src/Jaeger/Thrift/Agent/DependencyIf.php | 31 + .../Jaeger/Thrift/Agent/DependencyLink.php | 74 ++ ...ependency_getDependenciesForTrace_args.php | 55 ++ ...endency_getDependenciesForTrace_result.php | 56 ++ .../Dependency_saveDependencies_args.php | 56 ++ .../Agent/OperationSamplingStrategy.php | 66 ++ .../Agent/PerOperationSamplingStrategies.php | 88 ++ .../Agent/ProbabilisticSamplingStrategy.php | 56 ++ .../Agent/RateLimitingSamplingStrategy.php | 56 ++ .../Thrift/Agent/SamplingManagerClient.php | 83 ++ .../Jaeger/Thrift/Agent/SamplingManagerIf.php | 27 + ...mplingManager_getSamplingStrategy_args.php | 55 ++ ...lingManager_getSamplingStrategy_result.php | 56 ++ .../Thrift/Agent/SamplingStrategyResponse.php | 86 ++ .../Thrift/Agent/SamplingStrategyType.php | 28 + .../Thrift/Agent/ValidateTraceResponse.php | 65 ++ .../Jaeger/Thrift/Agent/Zipkin/Annotation.php | 87 ++ .../Thrift/Agent/Zipkin/AnnotationType.php | 38 + .../Thrift/Agent/Zipkin/BinaryAnnotation.php | 106 +++ .../Jaeger/Thrift/Agent/Zipkin/Constant.php | 246 +++++ .../Jaeger/Thrift/Agent/Zipkin/Endpoint.php | 108 +++ .../Jaeger/Thrift/Agent/Zipkin/Response.php | 56 ++ .../src/Jaeger/Thrift/Agent/Zipkin/Span.php | 190 ++++ .../Agent/Zipkin/ZipkinCollectorClient.php | 83 ++ .../Thrift/Agent/Zipkin/ZipkinCollectorIf.php | 27 + ...ZipkinCollector_submitZipkinBatch_args.php | 60 ++ ...pkinCollector_submitZipkinBatch_result.php | 60 ++ .../src/Jaeger/Thrift/Batch.php | 71 ++ .../src/Jaeger/Thrift/BatchSubmitResponse.php | 56 ++ .../src/Jaeger/Thrift/CollectorClient.php | 83 ++ .../src/Jaeger/Thrift/CollectorIf.php | 27 + .../Thrift/Collector_submitBatches_args.php | 60 ++ .../Thrift/Collector_submitBatches_result.php | 60 ++ .../Jaeger/Thrift/Crossdock/Downstream.php | 102 +++ .../Thrift/Crossdock/JoinTraceRequest.php | 66 ++ .../Jaeger/Thrift/Crossdock/ObservedSpan.php | 74 ++ .../Thrift/Crossdock/StartTraceRequest.php | 84 ++ .../Jaeger/Thrift/Crossdock/TraceResponse.php | 82 ++ .../Thrift/Crossdock/TracedServiceClient.php | 134 +++ .../Thrift/Crossdock/TracedServiceIf.php | 40 + .../TracedService_joinTrace_args.php | 56 ++ .../TracedService_joinTrace_result.php | 56 ++ .../TracedService_startTrace_args.php | 56 ++ .../TracedService_startTrace_result.php | 56 ++ .../src/Jaeger/Thrift/Crossdock/Transport.php | 30 + .../src/Jaeger/Thrift/Log.php | 70 ++ .../src/Jaeger/Thrift/Process.php | 70 ++ .../src/Jaeger/Thrift/Span.php | 161 ++++ .../src/Jaeger/Thrift/SpanRef.php | 83 ++ .../src/Jaeger/Thrift/SpanRefType.php | 28 + .../src/Jaeger/Thrift/Tag.php | 110 +++ .../src/Jaeger/Thrift/TagType.php | 34 + .../src/Jaeger/ThriftUdpTransport.php | 151 ++++ .../jaeger-client-php/src/Jaeger/Tracer.php | 420 +++++++++ .../src/Jaeger/Util/RateLimiter.php | 128 +++ .../tests/Jaeger/Codec/TextCodecTest.php | 170 ++++ .../tests/Jaeger/Codec/ZipkinCodecTest.php | 104 +++ .../tests/Jaeger/ConfigTest.php | 257 ++++++ .../tests/Jaeger/Logger/StackLogger.php | 30 + .../Jaeger/Mapper/SpanToJaegerMapperTest.php | 169 ++++ .../Jaeger/Reporter/CompositeReporterTest.php | 52 ++ .../Jaeger/Reporter/InMemoryReporterTest.php | 24 + .../Jaeger/Reporter/LoggingReporterTest.php | 31 + .../Jaeger/Reporter/NullReporterTest.php | 29 + .../Jaeger/Reporter/RemoteReporterTest.php | 46 + .../tests/Jaeger/Sampler/ConstSamplerTest.php | 43 + .../Sampler/ProbablisticSamplerTest.php | 68 ++ .../Jaeger/Sampler/RateLimitSamplerTest.php | 48 + .../tests/Jaeger/ScopeManagerTest.php | 49 + .../tests/Jaeger/ScopeTest.php | 58 ++ .../Jaeger/Sender/JaegerThriftSenderTest.php | 126 +++ .../tests/Jaeger/Sender/UdpSenderTest.php | 116 +++ .../tests/Jaeger/SpanContextTest.php | 37 + .../tests/Jaeger/SpanTest.php | 293 ++++++ .../tests/Jaeger/ThriftUdpTransportTest.php | 166 ++++ .../tests/Jaeger/TracerTest.php | 262 ++++++ .../jaeger-client-php/tests/README.md | 48 + .../jaeger-client-php/tests/php-test.sh | 64 ++ .../opentracing/.github/ISSUE_TEMPLATE.md | 21 + .../.github/PULL_REQUEST_TEMPLATE.md | 24 + .../opentracing/.github/workflows/ci.yml | 44 + vendor/opentracing/opentracing/.gitignore | 4 + .../opentracing/opentracing/CONTRIBUTING.md | 75 ++ vendor/opentracing/opentracing/LICENSE | 201 +++++ vendor/opentracing/opentracing/README.md | 306 +++++++ vendor/opentracing/opentracing/composer.json | 44 + vendor/opentracing/opentracing/phpstan.neon | 5 + vendor/opentracing/opentracing/phpunit.xml | 27 + .../opentracing/src/OpenTracing/Formats.php | 49 + .../src/OpenTracing/GlobalTracer.php | 60 ++ .../InvalidReferenceArgumentException.php | 33 + .../InvalidReferencesSetException.php | 30 + .../InvalidSpanOptionException.php | 131 +++ .../src/OpenTracing/Mock/MockScope.php | 62 ++ .../src/OpenTracing/Mock/MockScopeManager.php | 49 + .../src/OpenTracing/Mock/MockSpan.php | 145 +++ .../src/OpenTracing/Mock/MockSpanContext.php | 100 +++ .../src/OpenTracing/Mock/MockTracer.php | 152 ++++ .../opentracing/src/OpenTracing/NoopScope.php | 23 + .../src/OpenTracing/NoopScopeManager.php | 24 + .../opentracing/src/OpenTracing/NoopSpan.php | 67 ++ .../src/OpenTracing/NoopSpanContext.php | 35 + .../src/OpenTracing/NoopTracer.php | 62 ++ .../opentracing/src/OpenTracing/Reference.php | 77 ++ .../opentracing/src/OpenTracing/Scope.php | 32 + .../src/OpenTracing/ScopeManager.php | 40 + .../opentracing/src/OpenTracing/Span.php | 95 ++ .../src/OpenTracing/SpanContext.php | 37 + .../src/OpenTracing/StartSpanOptions.php | 206 +++++ .../opentracing/src/OpenTracing/Tags.php | 124 +++ .../opentracing/src/OpenTracing/Tracer.php | 119 +++ .../UnsupportedFormatException.php | 22 + .../OpenTracing/Mock/MockScopeManagerTest.php | 63 ++ .../OpenTracing/Mock/MockSpanContextTest.php | 54 ++ .../tests/OpenTracing/Mock/MockSpanTest.php | 52 ++ .../tests/OpenTracing/Mock/MockTracerTest.php | 139 +++ .../tests/OpenTracing/ReferenceTest.php | 45 + .../OpenTracing/StartSpanOptionsTest.php | 129 +++ vendor/packaged/thrift/.gitignore | 2 + vendor/packaged/thrift/README.md | 44 + vendor/packaged/thrift/composer.json | 16 + vendor/packaged/thrift/src/Base/TBase.php | 382 ++++++++ .../src/ClassLoader/ThriftClassLoader.php | 206 +++++ .../src/Exception/TApplicationException.php | 76 ++ .../thrift/src/Exception/TException.php | 384 ++++++++ .../src/Exception/TProtocolException.php | 50 ++ .../src/Exception/TTransportException.php | 40 + .../src/Factory/TBinaryProtocolFactory.php | 45 + .../src/Factory/TCompactProtocolFactory.php | 40 + .../src/Factory/TJSONProtocolFactory.php | 40 + .../thrift/src/Factory/TProtocolFactory.php | 36 + .../thrift/src/Factory/TStringFuncFactory.php | 66 ++ .../thrift/src/Factory/TTransportFactory.php | 18 + .../thrift/src/Protocol/JSON/BaseContext.php | 39 + .../thrift/src/Protocol/JSON/ListContext.php | 54 ++ .../src/Protocol/JSON/LookaheadReader.php | 57 ++ .../thrift/src/Protocol/JSON/PairContext.php | 64 ++ .../SimpleJSON/CollectionMapKeyException.php | 33 + .../src/Protocol/SimpleJSON/Context.php | 35 + .../src/Protocol/SimpleJSON/ListContext.php | 45 + .../src/Protocol/SimpleJSON/MapContext.php | 47 + .../src/Protocol/SimpleJSON/StructContext.php | 52 ++ .../thrift/src/Protocol/TBinaryProtocol.php | 453 ++++++++++ .../Protocol/TBinaryProtocolAccelerated.php | 67 ++ .../thrift/src/Protocol/TCompactProtocol.php | 739 +++++++++++++++ .../thrift/src/Protocol/TJSONProtocol.php | 815 +++++++++++++++++ .../src/Protocol/TMultiplexedProtocol.php | 85 ++ .../thrift/src/Protocol/TProtocol.php | 352 ++++++++ .../src/Protocol/TProtocolDecorator.php | 285 ++++++ .../src/Protocol/TSimpleJSONProtocol.php | 374 ++++++++ .../src/Serializer/TBinarySerializer.php | 87 ++ .../thrift/src/Server/TForkingServer.php | 125 +++ .../thrift/src/Server/TSSLServerSocket.php | 97 ++ vendor/packaged/thrift/src/Server/TServer.php | 102 +++ .../thrift/src/Server/TServerSocket.php | 124 +++ .../thrift/src/Server/TServerTransport.php | 56 ++ .../thrift/src/Server/TSimpleServer.php | 60 ++ .../thrift/src/StoredMessageProtocol.php | 53 ++ .../packaged/thrift/src/StringFunc/Core.php | 40 + .../thrift/src/StringFunc/Mbstring.php | 46 + .../thrift/src/StringFunc/TStringFunc.php | 28 + .../thrift/src/TMultiplexedProcessor.php | 118 +++ .../src/Transport/TBufferedTransport.php | 206 +++++ .../thrift/src/Transport/TCurlClient.php | 281 ++++++ .../thrift/src/Transport/TFramedTransport.php | 192 ++++ .../thrift/src/Transport/THttpClient.php | 258 ++++++ .../thrift/src/Transport/TMemoryBuffer.php | 106 +++ .../thrift/src/Transport/TNullTransport.php | 56 ++ .../thrift/src/Transport/TPhpStream.php | 124 +++ .../thrift/src/Transport/TSSLSocket.php | 117 +++ .../packaged/thrift/src/Transport/TSocket.php | 366 ++++++++ .../thrift/src/Transport/TSocketPool.php | 310 +++++++ .../thrift/src/Transport/TTransport.php | 98 ++ vendor/packaged/thrift/src/Type/TConstant.php | 52 ++ .../packaged/thrift/src/Type/TMessageType.php | 34 + vendor/packaged/thrift/src/Type/TType.php | 47 + vendor/packaged/thrift/update.sh | 22 + vendor/psr/cache/CHANGELOG.md | 16 + vendor/psr/cache/LICENSE.txt | 19 + vendor/psr/cache/README.md | 12 + vendor/psr/cache/composer.json | 25 + vendor/psr/cache/src/CacheException.php | 10 + vendor/psr/cache/src/CacheItemInterface.php | 105 +++ .../psr/cache/src/CacheItemPoolInterface.php | 138 +++ .../cache/src/InvalidArgumentException.php | 13 + vendor/psr/log/LICENSE | 19 + vendor/psr/log/README.md | 58 ++ vendor/psr/log/composer.json | 26 + vendor/psr/log/src/AbstractLogger.php | 15 + .../psr/log/src/InvalidArgumentException.php | 7 + vendor/psr/log/src/LogLevel.php | 18 + vendor/psr/log/src/LoggerAwareInterface.php | 18 + vendor/psr/log/src/LoggerAwareTrait.php | 26 + vendor/psr/log/src/LoggerInterface.php | 125 +++ vendor/psr/log/src/LoggerTrait.php | 142 +++ vendor/psr/log/src/NullLogger.php | 30 + 276 files changed, 24972 insertions(+), 684 deletions(-) create mode 100644 classes/tracer.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/.editorconfig create mode 100644 vendor/jonahgeorge/jaeger-client-php/.github/workflows/main.yaml create mode 100644 vendor/jonahgeorge/jaeger-client-php/.gitignore create mode 100644 vendor/jonahgeorge/jaeger-client-php/CONTRIBUTING.md create mode 100644 vendor/jonahgeorge/jaeger-client-php/LICENSE create mode 100644 vendor/jonahgeorge/jaeger-client-php/README.md create mode 100644 vendor/jonahgeorge/jaeger-client-php/build/.gitignore create mode 100644 vendor/jonahgeorge/jaeger-client-php/composer.json create mode 100644 vendor/jonahgeorge/jaeger-client-php/examples/config.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/examples/jaeger.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/phpcs.xml.dist create mode 100644 vendor/jonahgeorge/jaeger-client-php/phpunit.xml.dist create mode 100644 vendor/jonahgeorge/jaeger-client-php/scripts/thrift-gen.sh create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/AgentClient/HttpAgentClient.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Codec/BinaryCodec.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Codec/CodecInterface.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Codec/CodecUtility.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Codec/TextCodec.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Codec/ZipkinCodec.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Config.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Constants.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Mapper/SpanToJaegerMapper.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Reporter/CompositeReporter.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Reporter/InMemoryReporter.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Reporter/JaegerReporter.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Reporter/LoggingReporter.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Reporter/NullReporter.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Reporter/RemoteReporter.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Reporter/ReporterInterface.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/ReporterFactory/AbstractReporterFactory.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/ReporterFactory/JaegerHttpReporterFactory.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/ReporterFactory/JaegerReporterFactory.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/ReporterFactory/ReporterFactoryInterface.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/ReporterFactory/ZipkinReporterFactory.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Sampler/ConstSampler.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Sampler/ProbabilisticSampler.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Sampler/RateLimitingSampler.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Sampler/SamplerInterface.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Scope.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/ScopeManager.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Sender/JaegerSender.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Sender/SenderInterface.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Sender/UdpSender.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Span.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/SpanContext.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/AgentClient.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/AgentIf.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Agent_emitBatch_args.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Agent_emitZipkinBatch_args.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/AggregationValidatorClient.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/AggregationValidatorIf.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/AggregationValidator_validateTrace_args.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/AggregationValidator_validateTrace_result.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/BaggageRestriction.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/BaggageRestrictionManagerClient.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/BaggageRestrictionManagerIf.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/BaggageRestrictionManager_getBaggageRestrictions_args.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/BaggageRestrictionManager_getBaggageRestrictions_result.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Dependencies.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/DependencyClient.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/DependencyIf.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/DependencyLink.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Dependency_getDependenciesForTrace_args.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Dependency_getDependenciesForTrace_result.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Dependency_saveDependencies_args.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/OperationSamplingStrategy.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/PerOperationSamplingStrategies.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/ProbabilisticSamplingStrategy.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/RateLimitingSamplingStrategy.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/SamplingManagerClient.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/SamplingManagerIf.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/SamplingManager_getSamplingStrategy_args.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/SamplingManager_getSamplingStrategy_result.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/SamplingStrategyResponse.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/SamplingStrategyType.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/ValidateTraceResponse.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Zipkin/Annotation.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Zipkin/AnnotationType.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Zipkin/BinaryAnnotation.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Zipkin/Constant.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Zipkin/Endpoint.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Zipkin/Response.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Zipkin/Span.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Zipkin/ZipkinCollectorClient.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Zipkin/ZipkinCollectorIf.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Zipkin/ZipkinCollector_submitZipkinBatch_args.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Zipkin/ZipkinCollector_submitZipkinBatch_result.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Batch.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/BatchSubmitResponse.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/CollectorClient.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/CollectorIf.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Collector_submitBatches_args.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Collector_submitBatches_result.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/Downstream.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/JoinTraceRequest.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/ObservedSpan.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/StartTraceRequest.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/TraceResponse.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/TracedServiceClient.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/TracedServiceIf.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/TracedService_joinTrace_args.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/TracedService_joinTrace_result.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/TracedService_startTrace_args.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/TracedService_startTrace_result.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/Transport.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Log.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Process.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Span.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/SpanRef.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/SpanRefType.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Tag.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/TagType.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/ThriftUdpTransport.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Tracer.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Util/RateLimiter.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Codec/TextCodecTest.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Codec/ZipkinCodecTest.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/ConfigTest.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Logger/StackLogger.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Mapper/SpanToJaegerMapperTest.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Reporter/CompositeReporterTest.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Reporter/InMemoryReporterTest.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Reporter/LoggingReporterTest.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Reporter/NullReporterTest.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Reporter/RemoteReporterTest.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Sampler/ConstSamplerTest.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Sampler/ProbablisticSamplerTest.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Sampler/RateLimitSamplerTest.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/ScopeManagerTest.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/ScopeTest.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Sender/JaegerThriftSenderTest.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Sender/UdpSenderTest.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/SpanContextTest.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/SpanTest.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/ThriftUdpTransportTest.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/TracerTest.php create mode 100644 vendor/jonahgeorge/jaeger-client-php/tests/README.md create mode 100644 vendor/jonahgeorge/jaeger-client-php/tests/php-test.sh create mode 100644 vendor/opentracing/opentracing/.github/ISSUE_TEMPLATE.md create mode 100644 vendor/opentracing/opentracing/.github/PULL_REQUEST_TEMPLATE.md create mode 100644 vendor/opentracing/opentracing/.github/workflows/ci.yml create mode 100644 vendor/opentracing/opentracing/.gitignore create mode 100644 vendor/opentracing/opentracing/CONTRIBUTING.md create mode 100644 vendor/opentracing/opentracing/LICENSE create mode 100644 vendor/opentracing/opentracing/README.md create mode 100644 vendor/opentracing/opentracing/composer.json create mode 100644 vendor/opentracing/opentracing/phpstan.neon create mode 100644 vendor/opentracing/opentracing/phpunit.xml create mode 100644 vendor/opentracing/opentracing/src/OpenTracing/Formats.php create mode 100644 vendor/opentracing/opentracing/src/OpenTracing/GlobalTracer.php create mode 100644 vendor/opentracing/opentracing/src/OpenTracing/InvalidReferenceArgumentException.php create mode 100644 vendor/opentracing/opentracing/src/OpenTracing/InvalidReferencesSetException.php create mode 100644 vendor/opentracing/opentracing/src/OpenTracing/InvalidSpanOptionException.php create mode 100644 vendor/opentracing/opentracing/src/OpenTracing/Mock/MockScope.php create mode 100644 vendor/opentracing/opentracing/src/OpenTracing/Mock/MockScopeManager.php create mode 100644 vendor/opentracing/opentracing/src/OpenTracing/Mock/MockSpan.php create mode 100644 vendor/opentracing/opentracing/src/OpenTracing/Mock/MockSpanContext.php create mode 100644 vendor/opentracing/opentracing/src/OpenTracing/Mock/MockTracer.php create mode 100644 vendor/opentracing/opentracing/src/OpenTracing/NoopScope.php create mode 100644 vendor/opentracing/opentracing/src/OpenTracing/NoopScopeManager.php create mode 100644 vendor/opentracing/opentracing/src/OpenTracing/NoopSpan.php create mode 100644 vendor/opentracing/opentracing/src/OpenTracing/NoopSpanContext.php create mode 100644 vendor/opentracing/opentracing/src/OpenTracing/NoopTracer.php create mode 100644 vendor/opentracing/opentracing/src/OpenTracing/Reference.php create mode 100644 vendor/opentracing/opentracing/src/OpenTracing/Scope.php create mode 100644 vendor/opentracing/opentracing/src/OpenTracing/ScopeManager.php create mode 100644 vendor/opentracing/opentracing/src/OpenTracing/Span.php create mode 100644 vendor/opentracing/opentracing/src/OpenTracing/SpanContext.php create mode 100644 vendor/opentracing/opentracing/src/OpenTracing/StartSpanOptions.php create mode 100644 vendor/opentracing/opentracing/src/OpenTracing/Tags.php create mode 100644 vendor/opentracing/opentracing/src/OpenTracing/Tracer.php create mode 100644 vendor/opentracing/opentracing/src/OpenTracing/UnsupportedFormatException.php create mode 100644 vendor/opentracing/opentracing/tests/OpenTracing/Mock/MockScopeManagerTest.php create mode 100644 vendor/opentracing/opentracing/tests/OpenTracing/Mock/MockSpanContextTest.php create mode 100644 vendor/opentracing/opentracing/tests/OpenTracing/Mock/MockSpanTest.php create mode 100644 vendor/opentracing/opentracing/tests/OpenTracing/Mock/MockTracerTest.php create mode 100644 vendor/opentracing/opentracing/tests/OpenTracing/ReferenceTest.php create mode 100644 vendor/opentracing/opentracing/tests/OpenTracing/StartSpanOptionsTest.php create mode 100644 vendor/packaged/thrift/.gitignore create mode 100644 vendor/packaged/thrift/README.md create mode 100644 vendor/packaged/thrift/composer.json create mode 100644 vendor/packaged/thrift/src/Base/TBase.php create mode 100644 vendor/packaged/thrift/src/ClassLoader/ThriftClassLoader.php create mode 100644 vendor/packaged/thrift/src/Exception/TApplicationException.php create mode 100644 vendor/packaged/thrift/src/Exception/TException.php create mode 100644 vendor/packaged/thrift/src/Exception/TProtocolException.php create mode 100644 vendor/packaged/thrift/src/Exception/TTransportException.php create mode 100644 vendor/packaged/thrift/src/Factory/TBinaryProtocolFactory.php create mode 100644 vendor/packaged/thrift/src/Factory/TCompactProtocolFactory.php create mode 100644 vendor/packaged/thrift/src/Factory/TJSONProtocolFactory.php create mode 100644 vendor/packaged/thrift/src/Factory/TProtocolFactory.php create mode 100644 vendor/packaged/thrift/src/Factory/TStringFuncFactory.php create mode 100644 vendor/packaged/thrift/src/Factory/TTransportFactory.php create mode 100644 vendor/packaged/thrift/src/Protocol/JSON/BaseContext.php create mode 100644 vendor/packaged/thrift/src/Protocol/JSON/ListContext.php create mode 100644 vendor/packaged/thrift/src/Protocol/JSON/LookaheadReader.php create mode 100644 vendor/packaged/thrift/src/Protocol/JSON/PairContext.php create mode 100644 vendor/packaged/thrift/src/Protocol/SimpleJSON/CollectionMapKeyException.php create mode 100644 vendor/packaged/thrift/src/Protocol/SimpleJSON/Context.php create mode 100644 vendor/packaged/thrift/src/Protocol/SimpleJSON/ListContext.php create mode 100644 vendor/packaged/thrift/src/Protocol/SimpleJSON/MapContext.php create mode 100644 vendor/packaged/thrift/src/Protocol/SimpleJSON/StructContext.php create mode 100644 vendor/packaged/thrift/src/Protocol/TBinaryProtocol.php create mode 100644 vendor/packaged/thrift/src/Protocol/TBinaryProtocolAccelerated.php create mode 100644 vendor/packaged/thrift/src/Protocol/TCompactProtocol.php create mode 100644 vendor/packaged/thrift/src/Protocol/TJSONProtocol.php create mode 100644 vendor/packaged/thrift/src/Protocol/TMultiplexedProtocol.php create mode 100644 vendor/packaged/thrift/src/Protocol/TProtocol.php create mode 100644 vendor/packaged/thrift/src/Protocol/TProtocolDecorator.php create mode 100644 vendor/packaged/thrift/src/Protocol/TSimpleJSONProtocol.php create mode 100644 vendor/packaged/thrift/src/Serializer/TBinarySerializer.php create mode 100644 vendor/packaged/thrift/src/Server/TForkingServer.php create mode 100644 vendor/packaged/thrift/src/Server/TSSLServerSocket.php create mode 100644 vendor/packaged/thrift/src/Server/TServer.php create mode 100644 vendor/packaged/thrift/src/Server/TServerSocket.php create mode 100644 vendor/packaged/thrift/src/Server/TServerTransport.php create mode 100644 vendor/packaged/thrift/src/Server/TSimpleServer.php create mode 100644 vendor/packaged/thrift/src/StoredMessageProtocol.php create mode 100644 vendor/packaged/thrift/src/StringFunc/Core.php create mode 100644 vendor/packaged/thrift/src/StringFunc/Mbstring.php create mode 100644 vendor/packaged/thrift/src/StringFunc/TStringFunc.php create mode 100644 vendor/packaged/thrift/src/TMultiplexedProcessor.php create mode 100644 vendor/packaged/thrift/src/Transport/TBufferedTransport.php create mode 100644 vendor/packaged/thrift/src/Transport/TCurlClient.php create mode 100644 vendor/packaged/thrift/src/Transport/TFramedTransport.php create mode 100644 vendor/packaged/thrift/src/Transport/THttpClient.php create mode 100644 vendor/packaged/thrift/src/Transport/TMemoryBuffer.php create mode 100644 vendor/packaged/thrift/src/Transport/TNullTransport.php create mode 100644 vendor/packaged/thrift/src/Transport/TPhpStream.php create mode 100644 vendor/packaged/thrift/src/Transport/TSSLSocket.php create mode 100644 vendor/packaged/thrift/src/Transport/TSocket.php create mode 100644 vendor/packaged/thrift/src/Transport/TSocketPool.php create mode 100644 vendor/packaged/thrift/src/Transport/TTransport.php create mode 100644 vendor/packaged/thrift/src/Type/TConstant.php create mode 100644 vendor/packaged/thrift/src/Type/TMessageType.php create mode 100644 vendor/packaged/thrift/src/Type/TType.php create mode 100644 vendor/packaged/thrift/update.sh create mode 100644 vendor/psr/cache/CHANGELOG.md create mode 100644 vendor/psr/cache/LICENSE.txt create mode 100644 vendor/psr/cache/README.md create mode 100644 vendor/psr/cache/composer.json create mode 100644 vendor/psr/cache/src/CacheException.php create mode 100644 vendor/psr/cache/src/CacheItemInterface.php create mode 100644 vendor/psr/cache/src/CacheItemPoolInterface.php create mode 100644 vendor/psr/cache/src/InvalidArgumentException.php create mode 100644 vendor/psr/log/LICENSE create mode 100644 vendor/psr/log/README.md create mode 100644 vendor/psr/log/composer.json create mode 100644 vendor/psr/log/src/AbstractLogger.php create mode 100644 vendor/psr/log/src/InvalidArgumentException.php create mode 100644 vendor/psr/log/src/LogLevel.php create mode 100644 vendor/psr/log/src/LoggerAwareInterface.php create mode 100644 vendor/psr/log/src/LoggerAwareTrait.php create mode 100644 vendor/psr/log/src/LoggerInterface.php create mode 100644 vendor/psr/log/src/LoggerTrait.php create mode 100644 vendor/psr/log/src/NullLogger.php diff --git a/backend.php b/backend.php index e246ea088..5b1587741 100644 --- a/backend.php +++ b/backend.php @@ -30,11 +30,16 @@ $op = (string)clean($op); $method = (string)clean($method); + $scope = Tracer::start(__FILE__, ['tags' => $_REQUEST]); + startup_gettext(); $script_started = microtime(true); - if (!init_plugins()) return; + if (!init_plugins()) { + $scope->close(); + return; + } header("Content-Type: text/json; charset=utf-8"); @@ -46,6 +51,8 @@ if (!\Sessions\validate_session()) { header("Content-Type: text/json"); print Errors::to_json(Errors::E_UNAUTHORIZED); + + $scope->close(); return; } UserHelper::load_user_plugins($_SESSION["uid"]); @@ -53,6 +60,7 @@ if (Config::is_migration_needed()) { print Errors::to_json(Errors::E_SCHEMA_MISMATCH); + $scope->close(); return; } @@ -114,6 +122,7 @@ user_error("Refusing to invoke method $method of handler $op which starts with underscore.", E_USER_WARNING); header("Content-Type: text/json"); print Errors::to_json(Errors::E_UNAUTHORIZED); + $scope->close(); return; } @@ -125,11 +134,19 @@ } if (implements_interface($handler, 'IHandler')) { + $h_scope = Tracer::start("construct/$op"); $handler->__construct($_REQUEST); + $h_scope->close(); if (validate_csrf($csrf_token) || $handler->csrf_ignore($method)) { - if ($handler->before($method)) { + + $b_scope = Tracer::start("before/$method"); + $before = $handler->before($method); + $b_scope->close(); + + if ($before) { if ($method && method_exists($handler, $method)) { + $m_scope = Tracer::start("method/$method"); $reflection = new ReflectionMethod($handler, $method); if ($reflection->getNumberOfRequiredParameters() == 0) { @@ -139,6 +156,7 @@ header("Content-Type: text/json"); print Errors::to_json(Errors::E_UNAUTHORIZED); } + $m_scope->close(); } else { if (method_exists($handler, "catchall")) { $handler->catchall($method); @@ -147,17 +165,26 @@ print Errors::to_json(Errors::E_UNKNOWN_METHOD, ["info" => get_class($handler) . "->$method"]); } } + + $a_scope = Tracer::start("after/$method"); $handler->after(); + $a_scope->close(); + + $scope->close(); return; } else { header("Content-Type: text/json"); print Errors::to_json(Errors::E_UNAUTHORIZED); + + $scope->close(); return; } } else { user_error("Refusing to invoke method $method of handler $op with invalid CSRF token.", E_USER_WARNING); header("Content-Type: text/json"); print Errors::to_json(Errors::E_UNAUTHORIZED); + + $scope->close(); return; } } @@ -166,4 +193,4 @@ header("Content-Type: text/json"); print Errors::to_json(Errors::E_UNKNOWN_METHOD, [ "info" => (isset($handler) ? get_class($handler) : "UNKNOWN:".$op) . "->$method"]); -?> + $scope->close(); diff --git a/classes/counters.php b/classes/counters.php index 41bb1b9ae..378abac89 100644 --- a/classes/counters.php +++ b/classes/counters.php @@ -145,6 +145,7 @@ class Counters { * @return array> */ private static function get_feeds(array $feed_ids = null): array { + $scope = Tracer::start(__FUNCTION__); $ret = []; @@ -211,6 +212,8 @@ class Counters { } + $scope->close(); + return $ret; } @@ -218,6 +221,8 @@ class Counters { * @return array> */ private static function get_global(): array { + $scope = Tracer::start(__FUNCTION__); + $ret = [ [ "id" => "global-unread", @@ -234,6 +239,8 @@ class Counters { "counter" => $subcribed_feeds ]); + $scope->close(); + return $ret; } @@ -241,6 +248,7 @@ class Counters { * @return array> */ private static function get_virt(): array { + $scope = Tracer::start(__FUNCTION__); $ret = []; @@ -287,6 +295,7 @@ class Counters { } } + $scope->close(); return $ret; } @@ -295,6 +304,7 @@ class Counters { * @return array> */ static function get_labels(array $label_ids = null): array { + $scope = Tracer::start(__FUNCTION__); $ret = []; @@ -346,6 +356,7 @@ class Counters { array_push($ret, $cv); } + $scope->close(); return $ret; } } diff --git a/classes/feeds.php b/classes/feeds.php index 002a9eae7..1ce19b098 100755 --- a/classes/feeds.php +++ b/classes/feeds.php @@ -987,6 +987,7 @@ class Feeds extends Handler_Protected { * @throws PDOException */ static function _get_counters($feed, bool $is_cat = false, bool $unread_only = false, ?int $owner_uid = null): int { + $scope = Tracer::start(__FUNCTION__, ['tags' => ['args' => json_encode(func_get_args())]]); $n_feed = (int) $feed; $need_entries = false; @@ -1010,11 +1011,14 @@ class Feeds extends Handler_Protected { $handler = PluginHost::getInstance()->get_feed_handler($feed_id); if (implements_interface($handler, 'IVirtualFeed')) { /** @var IVirtualFeed $handler */ + $scope->close(); return $handler->get_unread($feed_id); } else { + $scope->close(); return 0; } } else if ($n_feed == Feeds::FEED_RECENTLY_READ) { + $scope->close(); return 0; // tags } else if ($feed != "0" && $n_feed == 0) { @@ -1028,6 +1032,7 @@ class Feeds extends Handler_Protected { $row = $sth->fetch(); // Handle 'SUM()' returning null if there are no results + $scope->close(); return $row["count"] ?? 0; } else if ($n_feed == Feeds::FEED_STARRED) { @@ -1061,6 +1066,7 @@ class Feeds extends Handler_Protected { $label_id = Labels::feed_to_label_id($feed); + $scope->close(); return self::_get_label_unread($label_id, $owner_uid); } @@ -1080,6 +1086,7 @@ class Feeds extends Handler_Protected { $sth->execute([$owner_uid]); $row = $sth->fetch(); + $scope->close(); return $row["unread"]; } else { @@ -1092,6 +1099,7 @@ class Feeds extends Handler_Protected { $sth->execute([$feed, $owner_uid]); $row = $sth->fetch(); + $scope->close(); return $row["unread"]; } } diff --git a/classes/pref/feeds.php b/classes/pref/feeds.php index ed6560fd3..00d26d4f6 100755 --- a/classes/pref/feeds.php +++ b/classes/pref/feeds.php @@ -1104,12 +1104,16 @@ class Pref_Feeds extends Handler_Protected { * @return array */ private function feedlist_init_feed(int $feed_id, ?string $title = null, bool $unread = false, string $error = '', string $updated = ''): array { + $scope = Tracer::start(__FUNCTION__, ['tags' => ['args' => json_encode(func_get_args())]]); + if (!$title) $title = Feeds::_get_title($feed_id, false); if ($unread === false) $unread = Feeds::_get_counters($feed_id, false, true); + $scope->close(); + return [ 'id' => 'FEED:' . $feed_id, 'name' => $title, diff --git a/classes/rpc.php b/classes/rpc.php index 204b002d5..977b88d46 100755 --- a/classes/rpc.php +++ b/classes/rpc.php @@ -106,6 +106,8 @@ class RPC extends Handler_Protected { } function getAllCounters(): void { + $scope = Tracer::start(__FUNCTION__); + @$seq = (int) $_REQUEST['seq']; $feed_id_count = (int) ($_REQUEST["feed_id_count"] ?? -1); @@ -132,6 +134,7 @@ class RPC extends Handler_Protected { 'seq' => $seq ]; + $scope->close(); print json_encode($reply); } diff --git a/classes/tracer.php b/classes/tracer.php new file mode 100644 index 000000000..fde99927d --- /dev/null +++ b/classes/tracer.php @@ -0,0 +1,49 @@ + [ + 'type' => \Jaeger\SAMPLER_TYPE_CONST, + 'param' => true, + ], + 'logging' => true, + "local_agent" => [ + "reporting_host" => "172.17.172.39", + "reporting_port" => 6832 + ], + 'dispatch_mode' => \Jaeger\Config::JAEGER_OVER_BINARY_UDP, + ], + 'tt-rss' + ); + + $config->initializeTracer(); + + register_shutdown_function(function() { + $tracer = GlobalTracer::get(); + $tracer->flush(); + }); + } + + private function _start(string $name, array $options = []) { + $tracer = GlobalTracer::get(); + return $tracer->startActiveSpan($name, $options); + } + + public static function start(string $name, array $options = []) : Scope { + return self::get_instance()->_start($name, $options); + } + + public static function get_instance() : Tracer { + if (self::$instance == null) + self::$instance = new self(); + + return self::$instance; + } + +} diff --git a/composer.json b/composer.json index be5dbc3c4..68076f778 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,8 @@ "spomky-labs/otphp": "^10.0", "chillerlan/php-qrcode": "^4.3.3", "mervick/material-design-icons": "^2.2", - "j4mie/idiorm": "dev-master" + "j4mie/idiorm": "dev-master", + "jonahgeorge/jaeger-client-php": "^1.4" }, "require-dev": { "phpstan/phpstan": "1.10.3", diff --git a/composer.lock b/composer.lock index f704f1075..3793968c9 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "d2be3e2749aff1bebf6257ecbfd6dcb3", + "content-hash": "de4af0d5d452fc73fe4f5d584163af9a", "packages": [ { "name": "beberlei/assert", @@ -280,6 +280,74 @@ }, "time": "2022-03-26T15:19:01+00:00" }, + { + "name": "jonahgeorge/jaeger-client-php", + "version": "v1.4.4", + "source": { + "type": "git", + "url": "https://github.com/jonahgeorge/jaeger-client-php.git", + "reference": "3173d9c68ad8cea16058f25337982b00cc3d1c2b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/jonahgeorge/jaeger-client-php/zipball/3173d9c68ad8cea16058f25337982b00cc3d1c2b", + "reference": "3173d9c68ad8cea16058f25337982b00cc3d1c2b", + "shasum": "" + }, + "require": { + "ext-sockets": "*", + "opentracing/opentracing": "^1.0", + "packaged/thrift": "^0.13", + "php": "^7.1 || ^8.0 || ^8.1", + "psr/cache": "^1.0 || ^2.0 || ^3.0", + "psr/log": "^1.0 || ^2.0 || ^3.0" + }, + "require-dev": { + "cache/array-adapter": "^1.0", + "phpunit/phpunit": "^7 || ^8 || ^9", + "squizlabs/php_codesniffer": "3.*", + "symfony/polyfill-php73": "^1.10" + }, + "type": "library", + "autoload": { + "files": [ + "./src/Jaeger/Constants.php" + ], + "psr-4": { + "Jaeger\\": "src/Jaeger/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jonah George", + "homepage": "http://twitter.com/jonahgeorge" + }, + { + "name": "José Carlos Chávez", + "email": "jcchavezs@gmail.com" + }, + { + "name": "Contributors", + "homepage": "https://github.com/jonahgeorge/jaeger-client-php/graphs/contributors" + } + ], + "description": "Jaeger Bindings for PHP OpenTracing API", + "keywords": [ + "jaeger", + "opentracing", + "trace", + "tracing" + ], + "support": { + "issues": "https://github.com/jonahgeorge/jaeger-client-php/issues", + "source": "https://github.com/jonahgeorge/jaeger-client-php/tree/v1.4.4" + }, + "time": "2023-01-31T13:40:20+00:00" + }, { "name": "mervick/material-design-icons", "version": "2.2.0", @@ -323,6 +391,94 @@ }, "time": "2016-02-22T01:05:40+00:00" }, + { + "name": "opentracing/opentracing", + "version": "1.0.2", + "source": { + "type": "git", + "url": "https://github.com/opentracing/opentracing-php.git", + "reference": "cd60bd1fb2a25280600bc74c7f9e0c13881a9116" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/opentracing/opentracing-php/zipball/cd60bd1fb2a25280600bc74c7f9e0c13881a9116", + "reference": "cd60bd1fb2a25280600bc74c7f9e0c13881a9116", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "phpstan/phpstan": "~0.12", + "phpunit/phpunit": "^7.0 || ^9.0", + "squizlabs/php_codesniffer": "3.*" + }, + "type": "library", + "autoload": { + "files": [ + "src/OpenTracing/Tags.php", + "src/OpenTracing/Formats.php" + ], + "psr-4": { + "OpenTracing\\": "src/OpenTracing/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "José Carlos Chávez", + "email": "jcchavezs@gmail.com" + } + ], + "description": "OpenTracing API for PHP", + "support": { + "issues": "https://github.com/opentracing/opentracing-php/issues", + "source": "https://github.com/opentracing/opentracing-php/tree/1.0.2" + }, + "time": "2022-01-27T19:59:21+00:00" + }, + { + "name": "packaged/thrift", + "version": "0.13.01", + "source": { + "type": "git", + "url": "https://github.com/packaged/thrift.git", + "reference": "e3dbcfb79e319971d64264ffe9c340590cc8a228" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/packaged/thrift/zipball/e3dbcfb79e319971d64264ffe9c340590cc8a228", + "reference": "e3dbcfb79e319971d64264ffe9c340590cc8a228", + "shasum": "" + }, + "require": { + "php": "^5.5 || ^7.0 || ^8.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Thrift\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "description": "Apache Thrift", + "homepage": "http://thrift.apache.org/", + "keywords": [ + "apache", + "thrift" + ], + "support": { + "issues": "https://github.com/packaged/thrift/issues", + "source": "https://github.com/packaged/thrift/tree/0.13.01" + }, + "time": "2021-01-25T13:32:28+00:00" + }, { "name": "paragonie/constant_time_encoding", "version": "v2.6.3", @@ -390,6 +546,105 @@ }, "time": "2022-06-14T06:56:20+00:00" }, + { + "name": "psr/cache", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/cache.git", + "reference": "aa5030cfa5405eccfdcb1083ce040c2cb8d253bf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/cache/zipball/aa5030cfa5405eccfdcb1083ce040c2cb8d253bf", + "reference": "aa5030cfa5405eccfdcb1083ce040c2cb8d253bf", + "shasum": "" + }, + "require": { + "php": ">=8.0.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Cache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for caching libraries", + "keywords": [ + "cache", + "psr", + "psr-6" + ], + "support": { + "source": "https://github.com/php-fig/cache/tree/3.0.0" + }, + "time": "2021-02-03T23:26:27+00:00" + }, + { + "name": "psr/log", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/fe5ea303b0887d5caefd3d431c3e61ad47037001", + "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001", + "shasum": "" + }, + "require": { + "php": ">=8.0.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "support": { + "source": "https://github.com/php-fig/log/tree/3.0.0" + }, + "time": "2021-07-14T16:46:02+00:00" + }, { "name": "spomky-labs/otphp", "version": "v10.0.3", @@ -2690,5 +2945,5 @@ "prefer-lowest": false, "platform": [], "platform-dev": [], - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.0.0" } diff --git a/vendor/autoload.php b/vendor/autoload.php index 8235051f8..e6e3ad736 100644 --- a/vendor/autoload.php +++ b/vendor/autoload.php @@ -2,24 +2,6 @@ // autoload.php @generated by Composer -if (PHP_VERSION_ID < 50600) { - if (!headers_sent()) { - header('HTTP/1.1 500 Internal Server Error'); - } - $err = 'Composer 2.3.0 dropped support for autoloading on PHP <5.6 and you are running '.PHP_VERSION.', please upgrade PHP or use Composer 2.2 LTS via "composer self-update --2.2". Aborting.'.PHP_EOL; - if (!ini_get('display_errors')) { - if (PHP_SAPI === 'cli' || PHP_SAPI === 'phpdbg') { - fwrite(STDERR, $err); - } elseif (!headers_sent()) { - echo $err; - } - } - trigger_error( - $err, - E_USER_ERROR - ); -} - require_once __DIR__ . '/composer/autoload_real.php'; return ComposerAutoloaderInit19fc2ff1c0f9a92279c7979386bb2056::getLoader(); diff --git a/vendor/composer/ClassLoader.php b/vendor/composer/ClassLoader.php index a72151c77..4d989a212 100644 --- a/vendor/composer/ClassLoader.php +++ b/vendor/composer/ClassLoader.php @@ -42,79 +42,30 @@ namespace Composer\Autoload; */ class ClassLoader { - /** @var \Closure(string):void */ - private static $includeFile; - - /** @var ?string */ private $vendorDir; // PSR-4 - /** - * @var array[] - * @psalm-var array> - */ private $prefixLengthsPsr4 = array(); - /** - * @var array[] - * @psalm-var array> - */ private $prefixDirsPsr4 = array(); - /** - * @var array[] - * @psalm-var array - */ private $fallbackDirsPsr4 = array(); // PSR-0 - /** - * @var array[] - * @psalm-var array> - */ private $prefixesPsr0 = array(); - /** - * @var array[] - * @psalm-var array - */ private $fallbackDirsPsr0 = array(); - /** @var bool */ private $useIncludePath = false; - - /** - * @var string[] - * @psalm-var array - */ private $classMap = array(); - - /** @var bool */ private $classMapAuthoritative = false; - - /** - * @var bool[] - * @psalm-var array - */ private $missingClasses = array(); - - /** @var ?string */ private $apcuPrefix; - /** - * @var self[] - */ private static $registeredLoaders = array(); - /** - * @param ?string $vendorDir - */ public function __construct($vendorDir = null) { $this->vendorDir = $vendorDir; - self::initializeIncludeClosure(); } - /** - * @return string[] - */ public function getPrefixes() { if (!empty($this->prefixesPsr0)) { @@ -124,47 +75,28 @@ class ClassLoader return array(); } - /** - * @return array[] - * @psalm-return array> - */ public function getPrefixesPsr4() { return $this->prefixDirsPsr4; } - /** - * @return array[] - * @psalm-return array - */ public function getFallbackDirs() { return $this->fallbackDirsPsr0; } - /** - * @return array[] - * @psalm-return array - */ public function getFallbackDirsPsr4() { return $this->fallbackDirsPsr4; } - /** - * @return string[] Array of classname => path - * @psalm-return array - */ public function getClassMap() { return $this->classMap; } /** - * @param string[] $classMap Class to filename map - * @psalm-param array $classMap - * - * @return void + * @param array $classMap Class to filename map */ public function addClassMap(array $classMap) { @@ -179,11 +111,9 @@ class ClassLoader * Registers a set of PSR-0 directories for a given prefix, either * appending or prepending to the ones previously set for this prefix. * - * @param string $prefix The prefix - * @param string[]|string $paths The PSR-0 root directories - * @param bool $prepend Whether to prepend the directories - * - * @return void + * @param string $prefix The prefix + * @param array|string $paths The PSR-0 root directories + * @param bool $prepend Whether to prepend the directories */ public function add($prefix, $paths, $prepend = false) { @@ -226,13 +156,11 @@ class ClassLoader * Registers a set of PSR-4 directories for a given namespace, either * appending or prepending to the ones previously set for this namespace. * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param string[]|string $paths The PSR-4 base directories - * @param bool $prepend Whether to prepend the directories + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param array|string $paths The PSR-4 base directories + * @param bool $prepend Whether to prepend the directories * * @throws \InvalidArgumentException - * - * @return void */ public function addPsr4($prefix, $paths, $prepend = false) { @@ -276,10 +204,8 @@ class ClassLoader * Registers a set of PSR-0 directories for a given prefix, * replacing any others previously set for this prefix. * - * @param string $prefix The prefix - * @param string[]|string $paths The PSR-0 base directories - * - * @return void + * @param string $prefix The prefix + * @param array|string $paths The PSR-0 base directories */ public function set($prefix, $paths) { @@ -294,12 +220,10 @@ class ClassLoader * Registers a set of PSR-4 directories for a given namespace, * replacing any others previously set for this namespace. * - * @param string $prefix The prefix/namespace, with trailing '\\' - * @param string[]|string $paths The PSR-4 base directories + * @param string $prefix The prefix/namespace, with trailing '\\' + * @param array|string $paths The PSR-4 base directories * * @throws \InvalidArgumentException - * - * @return void */ public function setPsr4($prefix, $paths) { @@ -319,8 +243,6 @@ class ClassLoader * Turns on searching the include path for class files. * * @param bool $useIncludePath - * - * @return void */ public function setUseIncludePath($useIncludePath) { @@ -343,8 +265,6 @@ class ClassLoader * that have not been registered with the class map. * * @param bool $classMapAuthoritative - * - * @return void */ public function setClassMapAuthoritative($classMapAuthoritative) { @@ -365,8 +285,6 @@ class ClassLoader * APCu prefix to use to cache found/not-found classes, if the extension is enabled. * * @param string|null $apcuPrefix - * - * @return void */ public function setApcuPrefix($apcuPrefix) { @@ -387,18 +305,14 @@ class ClassLoader * Registers this instance as an autoloader. * * @param bool $prepend Whether to prepend the autoloader or not - * - * @return void */ public function register($prepend = false) { spl_autoload_register(array($this, 'loadClass'), true, $prepend); if (null === $this->vendorDir) { - return; - } - - if ($prepend) { + //no-op + } elseif ($prepend) { self::$registeredLoaders = array($this->vendorDir => $this) + self::$registeredLoaders; } else { unset(self::$registeredLoaders[$this->vendorDir]); @@ -408,8 +322,6 @@ class ClassLoader /** * Unregisters this instance as an autoloader. - * - * @return void */ public function unregister() { @@ -424,18 +336,15 @@ class ClassLoader * Loads the given class or interface. * * @param string $class The name of the class - * @return true|null True if loaded, null otherwise + * @return bool|null True if loaded, null otherwise */ public function loadClass($class) { if ($file = $this->findFile($class)) { - $includeFile = self::$includeFile; - $includeFile($file); + includeFile($file); return true; } - - return null; } /** @@ -490,11 +399,6 @@ class ClassLoader return self::$registeredLoaders; } - /** - * @param string $class - * @param string $ext - * @return string|false - */ private function findFileWithExtension($class, $ext) { // PSR-4 lookup @@ -560,26 +464,14 @@ class ClassLoader return false; } - - /** - * @return void - */ - private static function initializeIncludeClosure() - { - if (self::$includeFile !== null) { - return; - } - - /** - * Scope isolated include. - * - * Prevents access to $this/self from included files. - * - * @param string $file - * @return void - */ - self::$includeFile = \Closure::bind(static function($file) { - include $file; - }, null, null); - } +} + +/** + * Scope isolated include. + * + * Prevents access to $this/self from included files. + */ +function includeFile($file) +{ + include $file; } diff --git a/vendor/composer/InstalledVersions.php b/vendor/composer/InstalledVersions.php index c6b54af7b..cf83ee179 100644 --- a/vendor/composer/InstalledVersions.php +++ b/vendor/composer/InstalledVersions.php @@ -18,29 +18,459 @@ use Composer\Semver\VersionParser; /** * This class is copied in every Composer installed project and available to all * - * See also https://getcomposer.org/doc/07-runtime.md#installed-versions - * - * To require its presence, you can require `composer-runtime-api ^2.0` - * - * @final + * To require it's presence, you can require `composer-runtime-api ^2.0` */ class InstalledVersions { - /** - * @var mixed[]|null - * @psalm-var array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array}|array{}|null - */ - private static $installed; - - /** - * @var bool|null - */ + private static $installed = array ( + 'root' => + array ( + 'pretty_version' => 'dev-master', + 'version' => 'dev-master', + 'aliases' => + array ( + ), + 'reference' => 'a37eab2610a0a2bcb655258781c1c7e925dc94c0', + 'name' => '__root__', + ), + 'versions' => + array ( + '__root__' => + array ( + 'pretty_version' => 'dev-master', + 'version' => 'dev-master', + 'aliases' => + array ( + ), + 'reference' => 'a37eab2610a0a2bcb655258781c1c7e925dc94c0', + ), + 'beberlei/assert' => + array ( + 'pretty_version' => 'v3.3.2', + 'version' => '3.3.2.0', + 'aliases' => + array ( + ), + 'reference' => 'cb70015c04be1baee6f5f5c953703347c0ac1655', + ), + 'chillerlan/php-qrcode' => + array ( + 'pretty_version' => '4.3.4', + 'version' => '4.3.4.0', + 'aliases' => + array ( + ), + 'reference' => '2ca4bf5ae048af1981d1023ee42a0a2a9d51e51d', + ), + 'chillerlan/php-settings-container' => + array ( + 'pretty_version' => '2.1.4', + 'version' => '2.1.4.0', + 'aliases' => + array ( + ), + 'reference' => '1beb7df3c14346d4344b0b2e12f6f9a74feabd4a', + ), + 'doctrine/instantiator' => + array ( + 'pretty_version' => '1.4.1', + 'version' => '1.4.1.0', + 'aliases' => + array ( + ), + 'reference' => '10dcfce151b967d20fde1b34ae6640712c3891bc', + ), + 'j4mie/idiorm' => + array ( + 'pretty_version' => 'dev-master', + 'version' => 'dev-master', + 'aliases' => + array ( + 0 => '9999999-dev', + ), + 'reference' => 'efc8ea06698f53e2c479c7696f2b154c47c3a3cb', + ), + 'jonahgeorge/jaeger-client-php' => + array ( + 'pretty_version' => 'v1.4.4', + 'version' => '1.4.4.0', + 'aliases' => + array ( + ), + 'reference' => '3173d9c68ad8cea16058f25337982b00cc3d1c2b', + ), + 'mervick/material-design-icons' => + array ( + 'pretty_version' => '2.2.0', + 'version' => '2.2.0.0', + 'aliases' => + array ( + ), + 'reference' => '635435c8d3df3a6da3241648caf8a65d1c07cc1a', + ), + 'myclabs/deep-copy' => + array ( + 'pretty_version' => '1.11.0', + 'version' => '1.11.0.0', + 'aliases' => + array ( + ), + 'reference' => '14daed4296fae74d9e3201d2c4925d1acb7aa614', + ), + 'nikic/php-parser' => + array ( + 'pretty_version' => 'v4.14.0', + 'version' => '4.14.0.0', + 'aliases' => + array ( + ), + 'reference' => '34bea19b6e03d8153165d8f30bba4c3be86184c1', + ), + 'opentracing/opentracing' => + array ( + 'pretty_version' => '1.0.2', + 'version' => '1.0.2.0', + 'aliases' => + array ( + ), + 'reference' => 'cd60bd1fb2a25280600bc74c7f9e0c13881a9116', + ), + 'packaged/thrift' => + array ( + 'pretty_version' => '0.13.01', + 'version' => '0.13.01.0', + 'aliases' => + array ( + ), + 'reference' => 'e3dbcfb79e319971d64264ffe9c340590cc8a228', + ), + 'paragonie/constant_time_encoding' => + array ( + 'pretty_version' => 'v2.6.3', + 'version' => '2.6.3.0', + 'aliases' => + array ( + ), + 'reference' => '58c3f47f650c94ec05a151692652a868995d2938', + ), + 'phar-io/manifest' => + array ( + 'pretty_version' => '2.0.3', + 'version' => '2.0.3.0', + 'aliases' => + array ( + ), + 'reference' => '97803eca37d319dfa7826cc2437fc020857acb53', + ), + 'phar-io/version' => + array ( + 'pretty_version' => '3.2.1', + 'version' => '3.2.1.0', + 'aliases' => + array ( + ), + 'reference' => '4f7fd7836c6f332bb2933569e566a0d6c4cbed74', + ), + 'phpdocumentor/reflection-common' => + array ( + 'pretty_version' => '2.2.0', + 'version' => '2.2.0.0', + 'aliases' => + array ( + ), + 'reference' => '1d01c49d4ed62f25aa84a747ad35d5a16924662b', + ), + 'phpdocumentor/reflection-docblock' => + array ( + 'pretty_version' => '5.3.0', + 'version' => '5.3.0.0', + 'aliases' => + array ( + ), + 'reference' => '622548b623e81ca6d78b721c5e029f4ce664f170', + ), + 'phpdocumentor/type-resolver' => + array ( + 'pretty_version' => '1.6.1', + 'version' => '1.6.1.0', + 'aliases' => + array ( + ), + 'reference' => '77a32518733312af16a44300404e945338981de3', + ), + 'phpspec/prophecy' => + array ( + 'pretty_version' => 'v1.15.0', + 'version' => '1.15.0.0', + 'aliases' => + array ( + ), + 'reference' => 'bbcd7380b0ebf3961ee21409db7b38bc31d69a13', + ), + 'phpstan/phpstan' => + array ( + 'pretty_version' => '1.10.3', + 'version' => '1.10.3.0', + 'aliases' => + array ( + ), + 'reference' => '5419375b5891add97dc74be71e6c1c34baaddf64', + ), + 'phpunit/php-code-coverage' => + array ( + 'pretty_version' => '9.2.15', + 'version' => '9.2.15.0', + 'aliases' => + array ( + ), + 'reference' => '2e9da11878c4202f97915c1cb4bb1ca318a63f5f', + ), + 'phpunit/php-file-iterator' => + array ( + 'pretty_version' => '3.0.6', + 'version' => '3.0.6.0', + 'aliases' => + array ( + ), + 'reference' => 'cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf', + ), + 'phpunit/php-invoker' => + array ( + 'pretty_version' => '3.1.1', + 'version' => '3.1.1.0', + 'aliases' => + array ( + ), + 'reference' => '5a10147d0aaf65b58940a0b72f71c9ac0423cc67', + ), + 'phpunit/php-text-template' => + array ( + 'pretty_version' => '2.0.4', + 'version' => '2.0.4.0', + 'aliases' => + array ( + ), + 'reference' => '5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28', + ), + 'phpunit/php-timer' => + array ( + 'pretty_version' => '5.0.3', + 'version' => '5.0.3.0', + 'aliases' => + array ( + ), + 'reference' => '5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2', + ), + 'phpunit/phpunit' => + array ( + 'pretty_version' => '9.5.16', + 'version' => '9.5.16.0', + 'aliases' => + array ( + ), + 'reference' => '5ff8c545a50226c569310a35f4fa89d79f1ddfdc', + ), + 'psr/cache' => + array ( + 'pretty_version' => '3.0.0', + 'version' => '3.0.0.0', + 'aliases' => + array ( + ), + 'reference' => 'aa5030cfa5405eccfdcb1083ce040c2cb8d253bf', + ), + 'psr/log' => + array ( + 'pretty_version' => '3.0.0', + 'version' => '3.0.0.0', + 'aliases' => + array ( + ), + 'reference' => 'fe5ea303b0887d5caefd3d431c3e61ad47037001', + ), + 'sebastian/cli-parser' => + array ( + 'pretty_version' => '1.0.1', + 'version' => '1.0.1.0', + 'aliases' => + array ( + ), + 'reference' => '442e7c7e687e42adc03470c7b668bc4b2402c0b2', + ), + 'sebastian/code-unit' => + array ( + 'pretty_version' => '1.0.8', + 'version' => '1.0.8.0', + 'aliases' => + array ( + ), + 'reference' => '1fc9f64c0927627ef78ba436c9b17d967e68e120', + ), + 'sebastian/code-unit-reverse-lookup' => + array ( + 'pretty_version' => '2.0.3', + 'version' => '2.0.3.0', + 'aliases' => + array ( + ), + 'reference' => 'ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5', + ), + 'sebastian/comparator' => + array ( + 'pretty_version' => '4.0.6', + 'version' => '4.0.6.0', + 'aliases' => + array ( + ), + 'reference' => '55f4261989e546dc112258c7a75935a81a7ce382', + ), + 'sebastian/complexity' => + array ( + 'pretty_version' => '2.0.2', + 'version' => '2.0.2.0', + 'aliases' => + array ( + ), + 'reference' => '739b35e53379900cc9ac327b2147867b8b6efd88', + ), + 'sebastian/diff' => + array ( + 'pretty_version' => '4.0.4', + 'version' => '4.0.4.0', + 'aliases' => + array ( + ), + 'reference' => '3461e3fccc7cfdfc2720be910d3bd73c69be590d', + ), + 'sebastian/environment' => + array ( + 'pretty_version' => '5.1.4', + 'version' => '5.1.4.0', + 'aliases' => + array ( + ), + 'reference' => '1b5dff7bb151a4db11d49d90e5408e4e938270f7', + ), + 'sebastian/exporter' => + array ( + 'pretty_version' => '4.0.4', + 'version' => '4.0.4.0', + 'aliases' => + array ( + ), + 'reference' => '65e8b7db476c5dd267e65eea9cab77584d3cfff9', + ), + 'sebastian/global-state' => + array ( + 'pretty_version' => '5.0.5', + 'version' => '5.0.5.0', + 'aliases' => + array ( + ), + 'reference' => '0ca8db5a5fc9c8646244e629625ac486fa286bf2', + ), + 'sebastian/lines-of-code' => + array ( + 'pretty_version' => '1.0.3', + 'version' => '1.0.3.0', + 'aliases' => + array ( + ), + 'reference' => 'c1c2e997aa3146983ed888ad08b15470a2e22ecc', + ), + 'sebastian/object-enumerator' => + array ( + 'pretty_version' => '4.0.4', + 'version' => '4.0.4.0', + 'aliases' => + array ( + ), + 'reference' => '5c9eeac41b290a3712d88851518825ad78f45c71', + ), + 'sebastian/object-reflector' => + array ( + 'pretty_version' => '2.0.4', + 'version' => '2.0.4.0', + 'aliases' => + array ( + ), + 'reference' => 'b4f479ebdbf63ac605d183ece17d8d7fe49c15c7', + ), + 'sebastian/recursion-context' => + array ( + 'pretty_version' => '4.0.4', + 'version' => '4.0.4.0', + 'aliases' => + array ( + ), + 'reference' => 'cd9d8cf3c5804de4341c283ed787f099f5506172', + ), + 'sebastian/resource-operations' => + array ( + 'pretty_version' => '3.0.3', + 'version' => '3.0.3.0', + 'aliases' => + array ( + ), + 'reference' => '0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8', + ), + 'sebastian/type' => + array ( + 'pretty_version' => '2.3.4', + 'version' => '2.3.4.0', + 'aliases' => + array ( + ), + 'reference' => 'b8cd8a1c753c90bc1a0f5372170e3e489136f914', + ), + 'sebastian/version' => + array ( + 'pretty_version' => '3.0.2', + 'version' => '3.0.2.0', + 'aliases' => + array ( + ), + 'reference' => 'c6c1022351a901512170118436c764e473f6de8c', + ), + 'spomky-labs/otphp' => + array ( + 'pretty_version' => 'v10.0.3', + 'version' => '10.0.3.0', + 'aliases' => + array ( + ), + 'reference' => '9784d9f7c790eed26e102d6c78f12c754036c366', + ), + 'thecodingmachine/safe' => + array ( + 'pretty_version' => 'v2.2.2', + 'version' => '2.2.2.0', + 'aliases' => + array ( + ), + 'reference' => '440284f9592c9df402832452a6871a8b3c48d97e', + ), + 'theseer/tokenizer' => + array ( + 'pretty_version' => '1.2.1', + 'version' => '1.2.1.0', + 'aliases' => + array ( + ), + 'reference' => '34a41e998c2183e22995f158c581e7b5e755ab9e', + ), + 'webmozart/assert' => + array ( + 'pretty_version' => '1.11.0', + 'version' => '1.11.0.0', + 'aliases' => + array ( + ), + 'reference' => '11cb2199493b2f8a3b53e7f19068fc6aac760991', + ), + ), +); private static $canGetVendors; - - /** - * @var array[] - * @psalm-var array}> - */ private static $installedByVendor = array(); /** @@ -56,6 +486,7 @@ class InstalledVersions $packages[] = array_keys($installed['versions']); } + if (1 === \count($packages)) { return $packages[0]; } @@ -63,42 +494,19 @@ class InstalledVersions return array_keys(array_flip(\call_user_func_array('array_merge', $packages))); } - /** - * Returns a list of all package names with a specific type e.g. 'library' - * - * @param string $type - * @return string[] - * @psalm-return list - */ - public static function getInstalledPackagesByType($type) - { - $packagesByType = array(); - - foreach (self::getInstalled() as $installed) { - foreach ($installed['versions'] as $name => $package) { - if (isset($package['type']) && $package['type'] === $type) { - $packagesByType[] = $name; - } - } - } - - return $packagesByType; - } - /** * Checks whether the given package is installed * * This also returns true if the package name is provided or replaced by another package * * @param string $packageName - * @param bool $includeDevRequirements * @return bool */ - public static function isInstalled($packageName, $includeDevRequirements = true) + public static function isInstalled($packageName) { foreach (self::getInstalled() as $installed) { if (isset($installed['versions'][$packageName])) { - return $includeDevRequirements || empty($installed['versions'][$packageName]['dev_requirement']); + return true; } } @@ -112,9 +520,10 @@ class InstalledVersions * * Composer\InstalledVersions::satisfies(new VersionParser, 'foo/bar', '^2.3') * - * @param VersionParser $parser Install composer/semver to have access to this class and functionality - * @param string $packageName - * @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package + * @param VersionParser $parser Install composer/semver to have access to this class and functionality + * @param string $packageName + * @param string|null $constraint A version constraint to check for, if you pass one you have to make sure composer/semver is required by your package + * * @return bool */ public static function satisfies(VersionParser $parser, $packageName, $constraint) @@ -224,26 +633,9 @@ class InstalledVersions throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); } - /** - * @param string $packageName - * @return string|null If the package is being replaced or provided but is not really installed, null will be returned as install path. Packages of type metapackages also have a null install path. - */ - public static function getInstallPath($packageName) - { - foreach (self::getInstalled() as $installed) { - if (!isset($installed['versions'][$packageName])) { - continue; - } - - return isset($installed['versions'][$packageName]['install_path']) ? $installed['versions'][$packageName]['install_path'] : null; - } - - throw new \OutOfBoundsException('Package "' . $packageName . '" is not installed'); - } - /** * @return array - * @psalm-return array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool} + * @psalm-return array{name: string, version: string, reference: string, pretty_version: string, aliases: string[]} */ public static function getRootPackage() { @@ -255,38 +647,14 @@ class InstalledVersions /** * Returns the raw installed.php data for custom implementations * - * @deprecated Use getAllRawData() instead which returns all datasets for all autoloaders present in the process. getRawData only returns the first dataset loaded, which may not be what you expect. * @return array[] - * @psalm-return array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} + * @psalm-return array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[]}, versions: list} */ public static function getRawData() { - @trigger_error('getRawData only returns the first dataset loaded, which may not be what you expect. Use getAllRawData() instead which returns all datasets for all autoloaders present in the process.', E_USER_DEPRECATED); - - if (null === self::$installed) { - // only require the installed.php file if this file is loaded from its dumped location, - // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 - if (substr(__DIR__, -8, 1) !== 'C') { - self::$installed = include __DIR__ . '/installed.php'; - } else { - self::$installed = array(); - } - } - return self::$installed; } - /** - * Returns the raw data of all installed.php which are currently loaded for custom implementations - * - * @return array[] - * @psalm-return list}> - */ - public static function getAllRawData() - { - return self::getInstalled(); - } - /** * Lets you reload the static array from another file * @@ -303,7 +671,7 @@ class InstalledVersions * @param array[] $data A vendor/composer/installed.php data set * @return void * - * @psalm-param array{root: array{name: string, pretty_version: string, version: string, reference: string|null, type: string, install_path: string, aliases: string[], dev: bool}, versions: array} $data + * @psalm-param array{root: array{name: string, version: string, reference: string, pretty_version: string, aliases: string[]}, versions: list} $data */ public static function reload($data) { @@ -313,7 +681,6 @@ class InstalledVersions /** * @return array[] - * @psalm-return list}> */ private static function getInstalled() { @@ -324,27 +691,16 @@ class InstalledVersions $installed = array(); if (self::$canGetVendors) { + // @phpstan-ignore-next-line foreach (ClassLoader::getRegisteredLoaders() as $vendorDir => $loader) { if (isset(self::$installedByVendor[$vendorDir])) { $installed[] = self::$installedByVendor[$vendorDir]; } elseif (is_file($vendorDir.'/composer/installed.php')) { $installed[] = self::$installedByVendor[$vendorDir] = require $vendorDir.'/composer/installed.php'; - if (null === self::$installed && strtr($vendorDir.'/composer', '\\', '/') === strtr(__DIR__, '\\', '/')) { - self::$installed = $installed[count($installed) - 1]; - } } } } - if (null === self::$installed) { - // only require the installed.php file if this file is loaded from its dumped location, - // and not from its source location in the composer/composer package, see https://github.com/composer/composer/issues/9937 - if (substr(__DIR__, -8, 1) !== 'C') { - self::$installed = require __DIR__ . '/installed.php'; - } else { - self::$installed = array(); - } - } $installed[] = self::$installed; return $installed; diff --git a/vendor/composer/LICENSE b/vendor/composer/LICENSE index f27399a04..62ecfd8d0 100644 --- a/vendor/composer/LICENSE +++ b/vendor/composer/LICENSE @@ -1,4 +1,3 @@ - Copyright (c) Nils Adermann, Jordi Boggiano Permission is hereby granted, free of charge, to any person obtaining a copy @@ -18,4 +17,3 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index 6835b271a..9e751e17c 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -2,7 +2,7 @@ // autoload_classmap.php @generated by Composer -$vendorDir = dirname(__DIR__); +$vendorDir = dirname(dirname(__FILE__)); $baseDir = dirname($vendorDir); return array( diff --git a/vendor/composer/autoload_files.php b/vendor/composer/autoload_files.php index cfc7a8338..f940286e8 100644 --- a/vendor/composer/autoload_files.php +++ b/vendor/composer/autoload_files.php @@ -2,10 +2,12 @@ // autoload_files.php @generated by Composer -$vendorDir = dirname(__DIR__); +$vendorDir = dirname(dirname(__FILE__)); $baseDir = dirname($vendorDir); return array( + '9b38cf48e83f5d8f60375221cd213eee' => $vendorDir . '/phpstan/phpstan/bootstrap.php', + 'ec07570ca5a812141189b1fa81503674' => $vendorDir . '/phpunit/phpunit/src/Framework/Assert/Functions.php', 'a4ecaeafb8cfb009ad0e052c90355e98' => $vendorDir . '/beberlei/assert/lib/Assert/functions.php', '6124b4c8570aa390c21fafd04a26c69f' => $vendorDir . '/myclabs/deep-copy/src/DeepCopy/deep_copy.php', '51fcf4e06c07cc00c920b44bcd900e7a' => $vendorDir . '/thecodingmachine/safe/deprecated/apc.php', @@ -95,6 +97,7 @@ return array( '4af1dca6db8c527c6eed27bff85ff0e5' => $vendorDir . '/thecodingmachine/safe/generated/yaz.php', 'fe43ca06499ac37bc2dedd823af71eb5' => $vendorDir . '/thecodingmachine/safe/generated/zip.php', '356736db98a6834f0a886b8d509b0ecd' => $vendorDir . '/thecodingmachine/safe/generated/zlib.php', - '9b38cf48e83f5d8f60375221cd213eee' => $vendorDir . '/phpstan/phpstan/bootstrap.php', - 'ec07570ca5a812141189b1fa81503674' => $vendorDir . '/phpunit/phpunit/src/Framework/Assert/Functions.php', + 'ff1b7935a93a4a9517db3ebe0533892a' => $vendorDir . '/opentracing/opentracing/src/OpenTracing/Tags.php', + '0db36546c71c357f5ee70c39bb03966f' => $vendorDir . '/opentracing/opentracing/src/OpenTracing/Formats.php', + '822502b10d2c1dae82956ef999e8b4be' => $vendorDir . '/jonahgeorge/jaeger-client-php/src/Jaeger/Constants.php', ); diff --git a/vendor/composer/autoload_namespaces.php b/vendor/composer/autoload_namespaces.php index 15a2ff3ad..b7fc0125d 100644 --- a/vendor/composer/autoload_namespaces.php +++ b/vendor/composer/autoload_namespaces.php @@ -2,7 +2,7 @@ // autoload_namespaces.php @generated by Composer -$vendorDir = dirname(__DIR__); +$vendorDir = dirname(dirname(__FILE__)); $baseDir = dirname($vendorDir); return array( diff --git a/vendor/composer/autoload_psr4.php b/vendor/composer/autoload_psr4.php index e8aa5c7b4..98ef4f1fd 100644 --- a/vendor/composer/autoload_psr4.php +++ b/vendor/composer/autoload_psr4.php @@ -2,7 +2,7 @@ // autoload_psr4.php @generated by Composer -$vendorDir = dirname(__DIR__); +$vendorDir = dirname(dirname(__FILE__)); $baseDir = dirname($vendorDir); return array( @@ -10,10 +10,15 @@ return array( 'chillerlan\\Settings\\' => array($vendorDir . '/chillerlan/php-settings-container/src'), 'chillerlan\\QRCode\\' => array($vendorDir . '/chillerlan/php-qrcode/src'), 'Webmozart\\Assert\\' => array($vendorDir . '/webmozart/assert/src'), + 'Thrift\\' => array($vendorDir . '/packaged/thrift/src'), + 'Psr\\Log\\' => array($vendorDir . '/psr/log/src'), + 'Psr\\Cache\\' => array($vendorDir . '/psr/cache/src'), 'Prophecy\\' => array($vendorDir . '/phpspec/prophecy/src/Prophecy'), 'PhpParser\\' => array($vendorDir . '/nikic/php-parser/lib/PhpParser'), 'ParagonIE\\ConstantTime\\' => array($vendorDir . '/paragonie/constant_time_encoding/src'), + 'OpenTracing\\' => array($vendorDir . '/opentracing/opentracing/src/OpenTracing'), 'OTPHP\\' => array($vendorDir . '/spomky-labs/otphp/src'), + 'Jaeger\\' => array($vendorDir . '/jonahgeorge/jaeger-client-php/src/Jaeger'), 'Doctrine\\Instantiator\\' => array($vendorDir . '/doctrine/instantiator/src/Doctrine/Instantiator'), 'DeepCopy\\' => array($vendorDir . '/myclabs/deep-copy/src/DeepCopy'), 'Assert\\' => array($vendorDir . '/beberlei/assert/lib/Assert'), diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php index ebee29895..51b54d2f0 100644 --- a/vendor/composer/autoload_real.php +++ b/vendor/composer/autoload_real.php @@ -23,26 +23,51 @@ class ComposerAutoloaderInit19fc2ff1c0f9a92279c7979386bb2056 } spl_autoload_register(array('ComposerAutoloaderInit19fc2ff1c0f9a92279c7979386bb2056', 'loadClassLoader'), true, true); - self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(__DIR__)); + self::$loader = $loader = new \Composer\Autoload\ClassLoader(\dirname(\dirname(__FILE__))); spl_autoload_unregister(array('ComposerAutoloaderInit19fc2ff1c0f9a92279c7979386bb2056', 'loadClassLoader')); - require __DIR__ . '/autoload_static.php'; - call_user_func(\Composer\Autoload\ComposerStaticInit19fc2ff1c0f9a92279c7979386bb2056::getInitializer($loader)); + $useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); + if ($useStaticLoader) { + require __DIR__ . '/autoload_static.php'; + + call_user_func(\Composer\Autoload\ComposerStaticInit19fc2ff1c0f9a92279c7979386bb2056::getInitializer($loader)); + } else { + $map = require __DIR__ . '/autoload_namespaces.php'; + foreach ($map as $namespace => $path) { + $loader->set($namespace, $path); + } + + $map = require __DIR__ . '/autoload_psr4.php'; + foreach ($map as $namespace => $path) { + $loader->setPsr4($namespace, $path); + } + + $classMap = require __DIR__ . '/autoload_classmap.php'; + if ($classMap) { + $loader->addClassMap($classMap); + } + } $loader->register(true); - $filesToLoad = \Composer\Autoload\ComposerStaticInit19fc2ff1c0f9a92279c7979386bb2056::$files; - $requireFile = \Closure::bind(static function ($fileIdentifier, $file) { - if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { - $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; - - require $file; - } - }, null, null); - foreach ($filesToLoad as $fileIdentifier => $file) { - $requireFile($fileIdentifier, $file); + if ($useStaticLoader) { + $includeFiles = Composer\Autoload\ComposerStaticInit19fc2ff1c0f9a92279c7979386bb2056::$files; + } else { + $includeFiles = require __DIR__ . '/autoload_files.php'; + } + foreach ($includeFiles as $fileIdentifier => $file) { + composerRequire19fc2ff1c0f9a92279c7979386bb2056($fileIdentifier, $file); } return $loader; } } + +function composerRequire19fc2ff1c0f9a92279c7979386bb2056($fileIdentifier, $file) +{ + if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { + require $file; + + $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; + } +} diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index a9ddd4831..67d12d734 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -7,6 +7,8 @@ namespace Composer\Autoload; class ComposerStaticInit19fc2ff1c0f9a92279c7979386bb2056 { public static $files = array ( + '9b38cf48e83f5d8f60375221cd213eee' => __DIR__ . '/..' . '/phpstan/phpstan/bootstrap.php', + 'ec07570ca5a812141189b1fa81503674' => __DIR__ . '/..' . '/phpunit/phpunit/src/Framework/Assert/Functions.php', 'a4ecaeafb8cfb009ad0e052c90355e98' => __DIR__ . '/..' . '/beberlei/assert/lib/Assert/functions.php', '6124b4c8570aa390c21fafd04a26c69f' => __DIR__ . '/..' . '/myclabs/deep-copy/src/DeepCopy/deep_copy.php', '51fcf4e06c07cc00c920b44bcd900e7a' => __DIR__ . '/..' . '/thecodingmachine/safe/deprecated/apc.php', @@ -96,8 +98,9 @@ class ComposerStaticInit19fc2ff1c0f9a92279c7979386bb2056 '4af1dca6db8c527c6eed27bff85ff0e5' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/yaz.php', 'fe43ca06499ac37bc2dedd823af71eb5' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/zip.php', '356736db98a6834f0a886b8d509b0ecd' => __DIR__ . '/..' . '/thecodingmachine/safe/generated/zlib.php', - '9b38cf48e83f5d8f60375221cd213eee' => __DIR__ . '/..' . '/phpstan/phpstan/bootstrap.php', - 'ec07570ca5a812141189b1fa81503674' => __DIR__ . '/..' . '/phpunit/phpunit/src/Framework/Assert/Functions.php', + 'ff1b7935a93a4a9517db3ebe0533892a' => __DIR__ . '/..' . '/opentracing/opentracing/src/OpenTracing/Tags.php', + '0db36546c71c357f5ee70c39bb03966f' => __DIR__ . '/..' . '/opentracing/opentracing/src/OpenTracing/Formats.php', + '822502b10d2c1dae82956ef999e8b4be' => __DIR__ . '/..' . '/jonahgeorge/jaeger-client-php/src/Jaeger/Constants.php', ); public static $prefixLengthsPsr4 = array ( @@ -114,16 +117,27 @@ class ComposerStaticInit19fc2ff1c0f9a92279c7979386bb2056 array ( 'Webmozart\\Assert\\' => 17, ), + 'T' => + array ( + 'Thrift\\' => 7, + ), 'P' => array ( + 'Psr\\Log\\' => 8, + 'Psr\\Cache\\' => 10, 'Prophecy\\' => 9, 'PhpParser\\' => 10, 'ParagonIE\\ConstantTime\\' => 23, ), 'O' => array ( + 'OpenTracing\\' => 12, 'OTPHP\\' => 6, ), + 'J' => + array ( + 'Jaeger\\' => 7, + ), 'D' => array ( 'Doctrine\\Instantiator\\' => 22, @@ -154,6 +168,18 @@ class ComposerStaticInit19fc2ff1c0f9a92279c7979386bb2056 array ( 0 => __DIR__ . '/..' . '/webmozart/assert/src', ), + 'Thrift\\' => + array ( + 0 => __DIR__ . '/..' . '/packaged/thrift/src', + ), + 'Psr\\Log\\' => + array ( + 0 => __DIR__ . '/..' . '/psr/log/src', + ), + 'Psr\\Cache\\' => + array ( + 0 => __DIR__ . '/..' . '/psr/cache/src', + ), 'Prophecy\\' => array ( 0 => __DIR__ . '/..' . '/phpspec/prophecy/src/Prophecy', @@ -166,10 +192,18 @@ class ComposerStaticInit19fc2ff1c0f9a92279c7979386bb2056 array ( 0 => __DIR__ . '/..' . '/paragonie/constant_time_encoding/src', ), + 'OpenTracing\\' => + array ( + 0 => __DIR__ . '/..' . '/opentracing/opentracing/src/OpenTracing', + ), 'OTPHP\\' => array ( 0 => __DIR__ . '/..' . '/spomky-labs/otphp/src', ), + 'Jaeger\\' => + array ( + 0 => __DIR__ . '/..' . '/jonahgeorge/jaeger-client-php/src/Jaeger', + ), 'Doctrine\\Instantiator\\' => array ( 0 => __DIR__ . '/..' . '/doctrine/instantiator/src/Doctrine/Instantiator', diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 6a7b5c878..0be499810 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -359,6 +359,77 @@ }, "install-path": "../j4mie/idiorm" }, + { + "name": "jonahgeorge/jaeger-client-php", + "version": "v1.4.4", + "version_normalized": "1.4.4.0", + "source": { + "type": "git", + "url": "https://github.com/jonahgeorge/jaeger-client-php.git", + "reference": "3173d9c68ad8cea16058f25337982b00cc3d1c2b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/jonahgeorge/jaeger-client-php/zipball/3173d9c68ad8cea16058f25337982b00cc3d1c2b", + "reference": "3173d9c68ad8cea16058f25337982b00cc3d1c2b", + "shasum": "" + }, + "require": { + "ext-sockets": "*", + "opentracing/opentracing": "^1.0", + "packaged/thrift": "^0.13", + "php": "^7.1 || ^8.0 || ^8.1", + "psr/cache": "^1.0 || ^2.0 || ^3.0", + "psr/log": "^1.0 || ^2.0 || ^3.0" + }, + "require-dev": { + "cache/array-adapter": "^1.0", + "phpunit/phpunit": "^7 || ^8 || ^9", + "squizlabs/php_codesniffer": "3.*", + "symfony/polyfill-php73": "^1.10" + }, + "time": "2023-01-31T13:40:20+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "files": [ + "./src/Jaeger/Constants.php" + ], + "psr-4": { + "Jaeger\\": "src/Jaeger/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Jonah George", + "homepage": "http://twitter.com/jonahgeorge" + }, + { + "name": "José Carlos Chávez", + "email": "jcchavezs@gmail.com" + }, + { + "name": "Contributors", + "homepage": "https://github.com/jonahgeorge/jaeger-client-php/graphs/contributors" + } + ], + "description": "Jaeger Bindings for PHP OpenTracing API", + "keywords": [ + "jaeger", + "opentracing", + "trace", + "tracing" + ], + "support": { + "issues": "https://github.com/jonahgeorge/jaeger-client-php/issues", + "source": "https://github.com/jonahgeorge/jaeger-client-php/tree/v1.4.4" + }, + "install-path": "../jonahgeorge/jaeger-client-php" + }, { "name": "mervick/material-design-icons", "version": "2.2.0", @@ -526,6 +597,100 @@ }, "install-path": "../nikic/php-parser" }, + { + "name": "opentracing/opentracing", + "version": "1.0.2", + "version_normalized": "1.0.2.0", + "source": { + "type": "git", + "url": "https://github.com/opentracing/opentracing-php.git", + "reference": "cd60bd1fb2a25280600bc74c7f9e0c13881a9116" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/opentracing/opentracing-php/zipball/cd60bd1fb2a25280600bc74c7f9e0c13881a9116", + "reference": "cd60bd1fb2a25280600bc74c7f9e0c13881a9116", + "shasum": "" + }, + "require": { + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "phpstan/phpstan": "~0.12", + "phpunit/phpunit": "^7.0 || ^9.0", + "squizlabs/php_codesniffer": "3.*" + }, + "time": "2022-01-27T19:59:21+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "files": [ + "src/OpenTracing/Tags.php", + "src/OpenTracing/Formats.php" + ], + "psr-4": { + "OpenTracing\\": "src/OpenTracing/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "José Carlos Chávez", + "email": "jcchavezs@gmail.com" + } + ], + "description": "OpenTracing API for PHP", + "support": { + "issues": "https://github.com/opentracing/opentracing-php/issues", + "source": "https://github.com/opentracing/opentracing-php/tree/1.0.2" + }, + "install-path": "../opentracing/opentracing" + }, + { + "name": "packaged/thrift", + "version": "0.13.01", + "version_normalized": "0.13.01.0", + "source": { + "type": "git", + "url": "https://github.com/packaged/thrift.git", + "reference": "e3dbcfb79e319971d64264ffe9c340590cc8a228" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/packaged/thrift/zipball/e3dbcfb79e319971d64264ffe9c340590cc8a228", + "reference": "e3dbcfb79e319971d64264ffe9c340590cc8a228", + "shasum": "" + }, + "require": { + "php": "^5.5 || ^7.0 || ^8.0" + }, + "time": "2021-01-25T13:32:28+00:00", + "type": "library", + "installation-source": "dist", + "autoload": { + "psr-4": { + "Thrift\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "description": "Apache Thrift", + "homepage": "http://thrift.apache.org/", + "keywords": [ + "apache", + "thrift" + ], + "support": { + "issues": "https://github.com/packaged/thrift/issues", + "source": "https://github.com/packaged/thrift/tree/0.13.01" + }, + "install-path": "../packaged/thrift" + }, { "name": "paragonie/constant_time_encoding", "version": "v2.6.3", @@ -1453,6 +1618,111 @@ ], "install-path": "../phpunit/phpunit" }, + { + "name": "psr/cache", + "version": "3.0.0", + "version_normalized": "3.0.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/cache.git", + "reference": "aa5030cfa5405eccfdcb1083ce040c2cb8d253bf" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/cache/zipball/aa5030cfa5405eccfdcb1083ce040c2cb8d253bf", + "reference": "aa5030cfa5405eccfdcb1083ce040c2cb8d253bf", + "shasum": "" + }, + "require": { + "php": ">=8.0.0" + }, + "time": "2021-02-03T23:26:27+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Psr\\Cache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for caching libraries", + "keywords": [ + "cache", + "psr", + "psr-6" + ], + "support": { + "source": "https://github.com/php-fig/cache/tree/3.0.0" + }, + "install-path": "../psr/cache" + }, + { + "name": "psr/log", + "version": "3.0.0", + "version_normalized": "3.0.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/log.git", + "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/log/zipball/fe5ea303b0887d5caefd3d431c3e61ad47037001", + "reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001", + "shasum": "" + }, + "require": { + "php": ">=8.0.0" + }, + "time": "2021-07-14T16:46:02+00:00", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-4": { + "Psr\\Log\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interface for logging libraries", + "homepage": "https://github.com/php-fig/log", + "keywords": [ + "log", + "psr", + "psr-3" + ], + "support": { + "source": "https://github.com/php-fig/log/tree/3.0.0" + }, + "install-path": "../psr/log" + }, { "name": "sebastian/cli-parser", "version": "1.0.1", diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 13f4018bf..cec06e2b7 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -1,403 +1,448 @@ - array( - 'name' => '__root__', - 'pretty_version' => 'dev-master', - 'version' => 'dev-master', - 'reference' => 'b7a6c948d078a59739f14de8454e0e7237d0722e', - 'type' => 'library', - 'install_path' => __DIR__ . '/../../', - 'aliases' => array(), - 'dev' => true, + + array ( + 'pretty_version' => 'dev-master', + 'version' => 'dev-master', + 'aliases' => + array ( ), - 'versions' => array( - '__root__' => array( - 'pretty_version' => 'dev-master', - 'version' => 'dev-master', - 'reference' => 'b7a6c948d078a59739f14de8454e0e7237d0722e', - 'type' => 'library', - 'install_path' => __DIR__ . '/../../', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'beberlei/assert' => array( - 'pretty_version' => 'v3.3.2', - 'version' => '3.3.2.0', - 'reference' => 'cb70015c04be1baee6f5f5c953703347c0ac1655', - 'type' => 'library', - 'install_path' => __DIR__ . '/../beberlei/assert', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'chillerlan/php-qrcode' => array( - 'pretty_version' => '4.3.4', - 'version' => '4.3.4.0', - 'reference' => '2ca4bf5ae048af1981d1023ee42a0a2a9d51e51d', - 'type' => 'library', - 'install_path' => __DIR__ . '/../chillerlan/php-qrcode', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'chillerlan/php-settings-container' => array( - 'pretty_version' => '2.1.4', - 'version' => '2.1.4.0', - 'reference' => '1beb7df3c14346d4344b0b2e12f6f9a74feabd4a', - 'type' => 'library', - 'install_path' => __DIR__ . '/../chillerlan/php-settings-container', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'doctrine/instantiator' => array( - 'pretty_version' => '1.4.1', - 'version' => '1.4.1.0', - 'reference' => '10dcfce151b967d20fde1b34ae6640712c3891bc', - 'type' => 'library', - 'install_path' => __DIR__ . '/../doctrine/instantiator', - 'aliases' => array(), - 'dev_requirement' => true, - ), - 'j4mie/idiorm' => array( - 'pretty_version' => 'dev-master', - 'version' => 'dev-master', - 'reference' => 'efc8ea06698f53e2c479c7696f2b154c47c3a3cb', - 'type' => 'library', - 'install_path' => __DIR__ . '/../j4mie/idiorm', - 'aliases' => array( - 0 => '9999999-dev', - ), - 'dev_requirement' => false, - ), - 'mervick/material-design-icons' => array( - 'pretty_version' => '2.2.0', - 'version' => '2.2.0.0', - 'reference' => '635435c8d3df3a6da3241648caf8a65d1c07cc1a', - 'type' => 'library', - 'install_path' => __DIR__ . '/../mervick/material-design-icons', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'myclabs/deep-copy' => array( - 'pretty_version' => '1.11.0', - 'version' => '1.11.0.0', - 'reference' => '14daed4296fae74d9e3201d2c4925d1acb7aa614', - 'type' => 'library', - 'install_path' => __DIR__ . '/../myclabs/deep-copy', - 'aliases' => array(), - 'dev_requirement' => true, - ), - 'nikic/php-parser' => array( - 'pretty_version' => 'v4.14.0', - 'version' => '4.14.0.0', - 'reference' => '34bea19b6e03d8153165d8f30bba4c3be86184c1', - 'type' => 'library', - 'install_path' => __DIR__ . '/../nikic/php-parser', - 'aliases' => array(), - 'dev_requirement' => true, - ), - 'paragonie/constant_time_encoding' => array( - 'pretty_version' => 'v2.6.3', - 'version' => '2.6.3.0', - 'reference' => '58c3f47f650c94ec05a151692652a868995d2938', - 'type' => 'library', - 'install_path' => __DIR__ . '/../paragonie/constant_time_encoding', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'phar-io/manifest' => array( - 'pretty_version' => '2.0.3', - 'version' => '2.0.3.0', - 'reference' => '97803eca37d319dfa7826cc2437fc020857acb53', - 'type' => 'library', - 'install_path' => __DIR__ . '/../phar-io/manifest', - 'aliases' => array(), - 'dev_requirement' => true, - ), - 'phar-io/version' => array( - 'pretty_version' => '3.2.1', - 'version' => '3.2.1.0', - 'reference' => '4f7fd7836c6f332bb2933569e566a0d6c4cbed74', - 'type' => 'library', - 'install_path' => __DIR__ . '/../phar-io/version', - 'aliases' => array(), - 'dev_requirement' => true, - ), - 'phpdocumentor/reflection-common' => array( - 'pretty_version' => '2.2.0', - 'version' => '2.2.0.0', - 'reference' => '1d01c49d4ed62f25aa84a747ad35d5a16924662b', - 'type' => 'library', - 'install_path' => __DIR__ . '/../phpdocumentor/reflection-common', - 'aliases' => array(), - 'dev_requirement' => true, - ), - 'phpdocumentor/reflection-docblock' => array( - 'pretty_version' => '5.3.0', - 'version' => '5.3.0.0', - 'reference' => '622548b623e81ca6d78b721c5e029f4ce664f170', - 'type' => 'library', - 'install_path' => __DIR__ . '/../phpdocumentor/reflection-docblock', - 'aliases' => array(), - 'dev_requirement' => true, - ), - 'phpdocumentor/type-resolver' => array( - 'pretty_version' => '1.6.1', - 'version' => '1.6.1.0', - 'reference' => '77a32518733312af16a44300404e945338981de3', - 'type' => 'library', - 'install_path' => __DIR__ . '/../phpdocumentor/type-resolver', - 'aliases' => array(), - 'dev_requirement' => true, - ), - 'phpspec/prophecy' => array( - 'pretty_version' => 'v1.15.0', - 'version' => '1.15.0.0', - 'reference' => 'bbcd7380b0ebf3961ee21409db7b38bc31d69a13', - 'type' => 'library', - 'install_path' => __DIR__ . '/../phpspec/prophecy', - 'aliases' => array(), - 'dev_requirement' => true, - ), - 'phpstan/phpstan' => array( - 'pretty_version' => '1.10.3', - 'version' => '1.10.3.0', - 'reference' => '5419375b5891add97dc74be71e6c1c34baaddf64', - 'type' => 'library', - 'install_path' => __DIR__ . '/../phpstan/phpstan', - 'aliases' => array(), - 'dev_requirement' => true, - ), - 'phpunit/php-code-coverage' => array( - 'pretty_version' => '9.2.15', - 'version' => '9.2.15.0', - 'reference' => '2e9da11878c4202f97915c1cb4bb1ca318a63f5f', - 'type' => 'library', - 'install_path' => __DIR__ . '/../phpunit/php-code-coverage', - 'aliases' => array(), - 'dev_requirement' => true, - ), - 'phpunit/php-file-iterator' => array( - 'pretty_version' => '3.0.6', - 'version' => '3.0.6.0', - 'reference' => 'cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf', - 'type' => 'library', - 'install_path' => __DIR__ . '/../phpunit/php-file-iterator', - 'aliases' => array(), - 'dev_requirement' => true, - ), - 'phpunit/php-invoker' => array( - 'pretty_version' => '3.1.1', - 'version' => '3.1.1.0', - 'reference' => '5a10147d0aaf65b58940a0b72f71c9ac0423cc67', - 'type' => 'library', - 'install_path' => __DIR__ . '/../phpunit/php-invoker', - 'aliases' => array(), - 'dev_requirement' => true, - ), - 'phpunit/php-text-template' => array( - 'pretty_version' => '2.0.4', - 'version' => '2.0.4.0', - 'reference' => '5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28', - 'type' => 'library', - 'install_path' => __DIR__ . '/../phpunit/php-text-template', - 'aliases' => array(), - 'dev_requirement' => true, - ), - 'phpunit/php-timer' => array( - 'pretty_version' => '5.0.3', - 'version' => '5.0.3.0', - 'reference' => '5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2', - 'type' => 'library', - 'install_path' => __DIR__ . '/../phpunit/php-timer', - 'aliases' => array(), - 'dev_requirement' => true, - ), - 'phpunit/phpunit' => array( - 'pretty_version' => '9.5.16', - 'version' => '9.5.16.0', - 'reference' => '5ff8c545a50226c569310a35f4fa89d79f1ddfdc', - 'type' => 'library', - 'install_path' => __DIR__ . '/../phpunit/phpunit', - 'aliases' => array(), - 'dev_requirement' => true, - ), - 'sebastian/cli-parser' => array( - 'pretty_version' => '1.0.1', - 'version' => '1.0.1.0', - 'reference' => '442e7c7e687e42adc03470c7b668bc4b2402c0b2', - 'type' => 'library', - 'install_path' => __DIR__ . '/../sebastian/cli-parser', - 'aliases' => array(), - 'dev_requirement' => true, - ), - 'sebastian/code-unit' => array( - 'pretty_version' => '1.0.8', - 'version' => '1.0.8.0', - 'reference' => '1fc9f64c0927627ef78ba436c9b17d967e68e120', - 'type' => 'library', - 'install_path' => __DIR__ . '/../sebastian/code-unit', - 'aliases' => array(), - 'dev_requirement' => true, - ), - 'sebastian/code-unit-reverse-lookup' => array( - 'pretty_version' => '2.0.3', - 'version' => '2.0.3.0', - 'reference' => 'ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5', - 'type' => 'library', - 'install_path' => __DIR__ . '/../sebastian/code-unit-reverse-lookup', - 'aliases' => array(), - 'dev_requirement' => true, - ), - 'sebastian/comparator' => array( - 'pretty_version' => '4.0.6', - 'version' => '4.0.6.0', - 'reference' => '55f4261989e546dc112258c7a75935a81a7ce382', - 'type' => 'library', - 'install_path' => __DIR__ . '/../sebastian/comparator', - 'aliases' => array(), - 'dev_requirement' => true, - ), - 'sebastian/complexity' => array( - 'pretty_version' => '2.0.2', - 'version' => '2.0.2.0', - 'reference' => '739b35e53379900cc9ac327b2147867b8b6efd88', - 'type' => 'library', - 'install_path' => __DIR__ . '/../sebastian/complexity', - 'aliases' => array(), - 'dev_requirement' => true, - ), - 'sebastian/diff' => array( - 'pretty_version' => '4.0.4', - 'version' => '4.0.4.0', - 'reference' => '3461e3fccc7cfdfc2720be910d3bd73c69be590d', - 'type' => 'library', - 'install_path' => __DIR__ . '/../sebastian/diff', - 'aliases' => array(), - 'dev_requirement' => true, - ), - 'sebastian/environment' => array( - 'pretty_version' => '5.1.4', - 'version' => '5.1.4.0', - 'reference' => '1b5dff7bb151a4db11d49d90e5408e4e938270f7', - 'type' => 'library', - 'install_path' => __DIR__ . '/../sebastian/environment', - 'aliases' => array(), - 'dev_requirement' => true, - ), - 'sebastian/exporter' => array( - 'pretty_version' => '4.0.4', - 'version' => '4.0.4.0', - 'reference' => '65e8b7db476c5dd267e65eea9cab77584d3cfff9', - 'type' => 'library', - 'install_path' => __DIR__ . '/../sebastian/exporter', - 'aliases' => array(), - 'dev_requirement' => true, - ), - 'sebastian/global-state' => array( - 'pretty_version' => '5.0.5', - 'version' => '5.0.5.0', - 'reference' => '0ca8db5a5fc9c8646244e629625ac486fa286bf2', - 'type' => 'library', - 'install_path' => __DIR__ . '/../sebastian/global-state', - 'aliases' => array(), - 'dev_requirement' => true, - ), - 'sebastian/lines-of-code' => array( - 'pretty_version' => '1.0.3', - 'version' => '1.0.3.0', - 'reference' => 'c1c2e997aa3146983ed888ad08b15470a2e22ecc', - 'type' => 'library', - 'install_path' => __DIR__ . '/../sebastian/lines-of-code', - 'aliases' => array(), - 'dev_requirement' => true, - ), - 'sebastian/object-enumerator' => array( - 'pretty_version' => '4.0.4', - 'version' => '4.0.4.0', - 'reference' => '5c9eeac41b290a3712d88851518825ad78f45c71', - 'type' => 'library', - 'install_path' => __DIR__ . '/../sebastian/object-enumerator', - 'aliases' => array(), - 'dev_requirement' => true, - ), - 'sebastian/object-reflector' => array( - 'pretty_version' => '2.0.4', - 'version' => '2.0.4.0', - 'reference' => 'b4f479ebdbf63ac605d183ece17d8d7fe49c15c7', - 'type' => 'library', - 'install_path' => __DIR__ . '/../sebastian/object-reflector', - 'aliases' => array(), - 'dev_requirement' => true, - ), - 'sebastian/recursion-context' => array( - 'pretty_version' => '4.0.4', - 'version' => '4.0.4.0', - 'reference' => 'cd9d8cf3c5804de4341c283ed787f099f5506172', - 'type' => 'library', - 'install_path' => __DIR__ . '/../sebastian/recursion-context', - 'aliases' => array(), - 'dev_requirement' => true, - ), - 'sebastian/resource-operations' => array( - 'pretty_version' => '3.0.3', - 'version' => '3.0.3.0', - 'reference' => '0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8', - 'type' => 'library', - 'install_path' => __DIR__ . '/../sebastian/resource-operations', - 'aliases' => array(), - 'dev_requirement' => true, - ), - 'sebastian/type' => array( - 'pretty_version' => '2.3.4', - 'version' => '2.3.4.0', - 'reference' => 'b8cd8a1c753c90bc1a0f5372170e3e489136f914', - 'type' => 'library', - 'install_path' => __DIR__ . '/../sebastian/type', - 'aliases' => array(), - 'dev_requirement' => true, - ), - 'sebastian/version' => array( - 'pretty_version' => '3.0.2', - 'version' => '3.0.2.0', - 'reference' => 'c6c1022351a901512170118436c764e473f6de8c', - 'type' => 'library', - 'install_path' => __DIR__ . '/../sebastian/version', - 'aliases' => array(), - 'dev_requirement' => true, - ), - 'spomky-labs/otphp' => array( - 'pretty_version' => 'v10.0.3', - 'version' => '10.0.3.0', - 'reference' => '9784d9f7c790eed26e102d6c78f12c754036c366', - 'type' => 'library', - 'install_path' => __DIR__ . '/../spomky-labs/otphp', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'thecodingmachine/safe' => array( - 'pretty_version' => 'v2.2.2', - 'version' => '2.2.2.0', - 'reference' => '440284f9592c9df402832452a6871a8b3c48d97e', - 'type' => 'library', - 'install_path' => __DIR__ . '/../thecodingmachine/safe', - 'aliases' => array(), - 'dev_requirement' => false, - ), - 'theseer/tokenizer' => array( - 'pretty_version' => '1.2.1', - 'version' => '1.2.1.0', - 'reference' => '34a41e998c2183e22995f158c581e7b5e755ab9e', - 'type' => 'library', - 'install_path' => __DIR__ . '/../theseer/tokenizer', - 'aliases' => array(), - 'dev_requirement' => true, - ), - 'webmozart/assert' => array( - 'pretty_version' => '1.11.0', - 'version' => '1.11.0.0', - 'reference' => '11cb2199493b2f8a3b53e7f19068fc6aac760991', - 'type' => 'library', - 'install_path' => __DIR__ . '/../webmozart/assert', - 'aliases' => array(), - 'dev_requirement' => true, - ), + 'reference' => 'a37eab2610a0a2bcb655258781c1c7e925dc94c0', + 'name' => '__root__', + ), + 'versions' => + array ( + '__root__' => + array ( + 'pretty_version' => 'dev-master', + 'version' => 'dev-master', + 'aliases' => + array ( + ), + 'reference' => 'a37eab2610a0a2bcb655258781c1c7e925dc94c0', ), + 'beberlei/assert' => + array ( + 'pretty_version' => 'v3.3.2', + 'version' => '3.3.2.0', + 'aliases' => + array ( + ), + 'reference' => 'cb70015c04be1baee6f5f5c953703347c0ac1655', + ), + 'chillerlan/php-qrcode' => + array ( + 'pretty_version' => '4.3.4', + 'version' => '4.3.4.0', + 'aliases' => + array ( + ), + 'reference' => '2ca4bf5ae048af1981d1023ee42a0a2a9d51e51d', + ), + 'chillerlan/php-settings-container' => + array ( + 'pretty_version' => '2.1.4', + 'version' => '2.1.4.0', + 'aliases' => + array ( + ), + 'reference' => '1beb7df3c14346d4344b0b2e12f6f9a74feabd4a', + ), + 'doctrine/instantiator' => + array ( + 'pretty_version' => '1.4.1', + 'version' => '1.4.1.0', + 'aliases' => + array ( + ), + 'reference' => '10dcfce151b967d20fde1b34ae6640712c3891bc', + ), + 'j4mie/idiorm' => + array ( + 'pretty_version' => 'dev-master', + 'version' => 'dev-master', + 'aliases' => + array ( + 0 => '9999999-dev', + ), + 'reference' => 'efc8ea06698f53e2c479c7696f2b154c47c3a3cb', + ), + 'jonahgeorge/jaeger-client-php' => + array ( + 'pretty_version' => 'v1.4.4', + 'version' => '1.4.4.0', + 'aliases' => + array ( + ), + 'reference' => '3173d9c68ad8cea16058f25337982b00cc3d1c2b', + ), + 'mervick/material-design-icons' => + array ( + 'pretty_version' => '2.2.0', + 'version' => '2.2.0.0', + 'aliases' => + array ( + ), + 'reference' => '635435c8d3df3a6da3241648caf8a65d1c07cc1a', + ), + 'myclabs/deep-copy' => + array ( + 'pretty_version' => '1.11.0', + 'version' => '1.11.0.0', + 'aliases' => + array ( + ), + 'reference' => '14daed4296fae74d9e3201d2c4925d1acb7aa614', + ), + 'nikic/php-parser' => + array ( + 'pretty_version' => 'v4.14.0', + 'version' => '4.14.0.0', + 'aliases' => + array ( + ), + 'reference' => '34bea19b6e03d8153165d8f30bba4c3be86184c1', + ), + 'opentracing/opentracing' => + array ( + 'pretty_version' => '1.0.2', + 'version' => '1.0.2.0', + 'aliases' => + array ( + ), + 'reference' => 'cd60bd1fb2a25280600bc74c7f9e0c13881a9116', + ), + 'packaged/thrift' => + array ( + 'pretty_version' => '0.13.01', + 'version' => '0.13.01.0', + 'aliases' => + array ( + ), + 'reference' => 'e3dbcfb79e319971d64264ffe9c340590cc8a228', + ), + 'paragonie/constant_time_encoding' => + array ( + 'pretty_version' => 'v2.6.3', + 'version' => '2.6.3.0', + 'aliases' => + array ( + ), + 'reference' => '58c3f47f650c94ec05a151692652a868995d2938', + ), + 'phar-io/manifest' => + array ( + 'pretty_version' => '2.0.3', + 'version' => '2.0.3.0', + 'aliases' => + array ( + ), + 'reference' => '97803eca37d319dfa7826cc2437fc020857acb53', + ), + 'phar-io/version' => + array ( + 'pretty_version' => '3.2.1', + 'version' => '3.2.1.0', + 'aliases' => + array ( + ), + 'reference' => '4f7fd7836c6f332bb2933569e566a0d6c4cbed74', + ), + 'phpdocumentor/reflection-common' => + array ( + 'pretty_version' => '2.2.0', + 'version' => '2.2.0.0', + 'aliases' => + array ( + ), + 'reference' => '1d01c49d4ed62f25aa84a747ad35d5a16924662b', + ), + 'phpdocumentor/reflection-docblock' => + array ( + 'pretty_version' => '5.3.0', + 'version' => '5.3.0.0', + 'aliases' => + array ( + ), + 'reference' => '622548b623e81ca6d78b721c5e029f4ce664f170', + ), + 'phpdocumentor/type-resolver' => + array ( + 'pretty_version' => '1.6.1', + 'version' => '1.6.1.0', + 'aliases' => + array ( + ), + 'reference' => '77a32518733312af16a44300404e945338981de3', + ), + 'phpspec/prophecy' => + array ( + 'pretty_version' => 'v1.15.0', + 'version' => '1.15.0.0', + 'aliases' => + array ( + ), + 'reference' => 'bbcd7380b0ebf3961ee21409db7b38bc31d69a13', + ), + 'phpstan/phpstan' => + array ( + 'pretty_version' => '1.10.3', + 'version' => '1.10.3.0', + 'aliases' => + array ( + ), + 'reference' => '5419375b5891add97dc74be71e6c1c34baaddf64', + ), + 'phpunit/php-code-coverage' => + array ( + 'pretty_version' => '9.2.15', + 'version' => '9.2.15.0', + 'aliases' => + array ( + ), + 'reference' => '2e9da11878c4202f97915c1cb4bb1ca318a63f5f', + ), + 'phpunit/php-file-iterator' => + array ( + 'pretty_version' => '3.0.6', + 'version' => '3.0.6.0', + 'aliases' => + array ( + ), + 'reference' => 'cf1c2e7c203ac650e352f4cc675a7021e7d1b3cf', + ), + 'phpunit/php-invoker' => + array ( + 'pretty_version' => '3.1.1', + 'version' => '3.1.1.0', + 'aliases' => + array ( + ), + 'reference' => '5a10147d0aaf65b58940a0b72f71c9ac0423cc67', + ), + 'phpunit/php-text-template' => + array ( + 'pretty_version' => '2.0.4', + 'version' => '2.0.4.0', + 'aliases' => + array ( + ), + 'reference' => '5da5f67fc95621df9ff4c4e5a84d6a8a2acf7c28', + ), + 'phpunit/php-timer' => + array ( + 'pretty_version' => '5.0.3', + 'version' => '5.0.3.0', + 'aliases' => + array ( + ), + 'reference' => '5a63ce20ed1b5bf577850e2c4e87f4aa902afbd2', + ), + 'phpunit/phpunit' => + array ( + 'pretty_version' => '9.5.16', + 'version' => '9.5.16.0', + 'aliases' => + array ( + ), + 'reference' => '5ff8c545a50226c569310a35f4fa89d79f1ddfdc', + ), + 'psr/cache' => + array ( + 'pretty_version' => '3.0.0', + 'version' => '3.0.0.0', + 'aliases' => + array ( + ), + 'reference' => 'aa5030cfa5405eccfdcb1083ce040c2cb8d253bf', + ), + 'psr/log' => + array ( + 'pretty_version' => '3.0.0', + 'version' => '3.0.0.0', + 'aliases' => + array ( + ), + 'reference' => 'fe5ea303b0887d5caefd3d431c3e61ad47037001', + ), + 'sebastian/cli-parser' => + array ( + 'pretty_version' => '1.0.1', + 'version' => '1.0.1.0', + 'aliases' => + array ( + ), + 'reference' => '442e7c7e687e42adc03470c7b668bc4b2402c0b2', + ), + 'sebastian/code-unit' => + array ( + 'pretty_version' => '1.0.8', + 'version' => '1.0.8.0', + 'aliases' => + array ( + ), + 'reference' => '1fc9f64c0927627ef78ba436c9b17d967e68e120', + ), + 'sebastian/code-unit-reverse-lookup' => + array ( + 'pretty_version' => '2.0.3', + 'version' => '2.0.3.0', + 'aliases' => + array ( + ), + 'reference' => 'ac91f01ccec49fb77bdc6fd1e548bc70f7faa3e5', + ), + 'sebastian/comparator' => + array ( + 'pretty_version' => '4.0.6', + 'version' => '4.0.6.0', + 'aliases' => + array ( + ), + 'reference' => '55f4261989e546dc112258c7a75935a81a7ce382', + ), + 'sebastian/complexity' => + array ( + 'pretty_version' => '2.0.2', + 'version' => '2.0.2.0', + 'aliases' => + array ( + ), + 'reference' => '739b35e53379900cc9ac327b2147867b8b6efd88', + ), + 'sebastian/diff' => + array ( + 'pretty_version' => '4.0.4', + 'version' => '4.0.4.0', + 'aliases' => + array ( + ), + 'reference' => '3461e3fccc7cfdfc2720be910d3bd73c69be590d', + ), + 'sebastian/environment' => + array ( + 'pretty_version' => '5.1.4', + 'version' => '5.1.4.0', + 'aliases' => + array ( + ), + 'reference' => '1b5dff7bb151a4db11d49d90e5408e4e938270f7', + ), + 'sebastian/exporter' => + array ( + 'pretty_version' => '4.0.4', + 'version' => '4.0.4.0', + 'aliases' => + array ( + ), + 'reference' => '65e8b7db476c5dd267e65eea9cab77584d3cfff9', + ), + 'sebastian/global-state' => + array ( + 'pretty_version' => '5.0.5', + 'version' => '5.0.5.0', + 'aliases' => + array ( + ), + 'reference' => '0ca8db5a5fc9c8646244e629625ac486fa286bf2', + ), + 'sebastian/lines-of-code' => + array ( + 'pretty_version' => '1.0.3', + 'version' => '1.0.3.0', + 'aliases' => + array ( + ), + 'reference' => 'c1c2e997aa3146983ed888ad08b15470a2e22ecc', + ), + 'sebastian/object-enumerator' => + array ( + 'pretty_version' => '4.0.4', + 'version' => '4.0.4.0', + 'aliases' => + array ( + ), + 'reference' => '5c9eeac41b290a3712d88851518825ad78f45c71', + ), + 'sebastian/object-reflector' => + array ( + 'pretty_version' => '2.0.4', + 'version' => '2.0.4.0', + 'aliases' => + array ( + ), + 'reference' => 'b4f479ebdbf63ac605d183ece17d8d7fe49c15c7', + ), + 'sebastian/recursion-context' => + array ( + 'pretty_version' => '4.0.4', + 'version' => '4.0.4.0', + 'aliases' => + array ( + ), + 'reference' => 'cd9d8cf3c5804de4341c283ed787f099f5506172', + ), + 'sebastian/resource-operations' => + array ( + 'pretty_version' => '3.0.3', + 'version' => '3.0.3.0', + 'aliases' => + array ( + ), + 'reference' => '0f4443cb3a1d92ce809899753bc0d5d5a8dd19a8', + ), + 'sebastian/type' => + array ( + 'pretty_version' => '2.3.4', + 'version' => '2.3.4.0', + 'aliases' => + array ( + ), + 'reference' => 'b8cd8a1c753c90bc1a0f5372170e3e489136f914', + ), + 'sebastian/version' => + array ( + 'pretty_version' => '3.0.2', + 'version' => '3.0.2.0', + 'aliases' => + array ( + ), + 'reference' => 'c6c1022351a901512170118436c764e473f6de8c', + ), + 'spomky-labs/otphp' => + array ( + 'pretty_version' => 'v10.0.3', + 'version' => '10.0.3.0', + 'aliases' => + array ( + ), + 'reference' => '9784d9f7c790eed26e102d6c78f12c754036c366', + ), + 'thecodingmachine/safe' => + array ( + 'pretty_version' => 'v2.2.2', + 'version' => '2.2.2.0', + 'aliases' => + array ( + ), + 'reference' => '440284f9592c9df402832452a6871a8b3c48d97e', + ), + 'theseer/tokenizer' => + array ( + 'pretty_version' => '1.2.1', + 'version' => '1.2.1.0', + 'aliases' => + array ( + ), + 'reference' => '34a41e998c2183e22995f158c581e7b5e755ab9e', + ), + 'webmozart/assert' => + array ( + 'pretty_version' => '1.11.0', + 'version' => '1.11.0.0', + 'aliases' => + array ( + ), + 'reference' => '11cb2199493b2f8a3b53e7f19068fc6aac760991', + ), + ), ); diff --git a/vendor/jonahgeorge/jaeger-client-php/.editorconfig b/vendor/jonahgeorge/jaeger-client-php/.editorconfig new file mode 100644 index 000000000..1492202b4 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/.editorconfig @@ -0,0 +1,16 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true + +[*.md] +trim_trailing_whitespace = false + +[*.yml] +indent_style = space +indent_size = 2 diff --git a/vendor/jonahgeorge/jaeger-client-php/.github/workflows/main.yaml b/vendor/jonahgeorge/jaeger-client-php/.github/workflows/main.yaml new file mode 100644 index 000000000..d0e5dc1f5 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/.github/workflows/main.yaml @@ -0,0 +1,44 @@ +name: Test + +on: [push, pull_request] + +jobs: + run: + runs-on: ubuntu-latest + strategy: + matrix: + php-versions: ['7.1', '7.2', '7.3', '7.4', '8.0', '8.1'] + name: PHP ${{ matrix.php-versions }} + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + coverage: xdebug + + - name: Get composer cache directory + id: composercache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + + - name: Cache dependencies + uses: actions/cache@v2 + with: + path: ${{ steps.composercache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer- + + - name: Install dependencies + run: | + composer install \ + --no-interaction \ + --no-ansi \ + --no-progress + + - name: Run lint + run: composer lint + + - name: Run test + run: composer test diff --git a/vendor/jonahgeorge/jaeger-client-php/.gitignore b/vendor/jonahgeorge/jaeger-client-php/.gitignore new file mode 100644 index 000000000..07dc555db --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/.gitignore @@ -0,0 +1,17 @@ +# Please do not use this ignore file to define platform specific files. +# +# For these purposes create a global .gitignore file, which is a list of rules +# for ignoring files in every Git repository on your computer. +# +# https://help.github.com/articles/ignoring-files/#create-a-global-gitignore + +jaeger-idl +vendor + +composer.lock +composer.phar + +jaeger-client-php.iml + +phpunit.xml +phpcs.xml diff --git a/vendor/jonahgeorge/jaeger-client-php/CONTRIBUTING.md b/vendor/jonahgeorge/jaeger-client-php/CONTRIBUTING.md new file mode 100644 index 000000000..e5ec5ed4f --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/CONTRIBUTING.md @@ -0,0 +1,3 @@ +# How to Contribute to Jaeger + +We'd love your help! diff --git a/vendor/jonahgeorge/jaeger-client-php/LICENSE b/vendor/jonahgeorge/jaeger-client-php/LICENSE new file mode 100644 index 000000000..8e37af0cb --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2018 Jonah George, José Carlos Chávez + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/vendor/jonahgeorge/jaeger-client-php/README.md b/vendor/jonahgeorge/jaeger-client-php/README.md new file mode 100644 index 000000000..6396bb70f --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/README.md @@ -0,0 +1,219 @@ +![Build Status](https://github.com/jonahgeorge/jaeger-client-php/workflows/Test/badge.svg) [![PHP version][packagist-img]][packagist] + +# Jaeger Bindings for PHP OpenTracing API + +This is a client-side library that can be used to instrument PHP apps for distributed trace collection, +and to send those traces to Jaeger. See the [OpenTracing PHP API](https://github.com/opentracing/opentracing-php) +for additional detail. + +## Contributing and Developing + +Please see [CONTRIBUTING.md](./CONTRIBUTING.md). + +## Installation + +Jaeger client can be installed via Composer: + +```bash +composer require jonahgeorge/jaeger-client-php +``` + +## Getting Started + +```php + [ + 'type' => Jaeger\SAMPLER_TYPE_CONST, + 'param' => true, + ], + 'logging' => true, + ], + 'your-app-name' +); +$config->initializeTracer(); + +$tracer = GlobalTracer::get(); + +$scope = $tracer->startActiveSpan('TestSpan', []); +$scope->close(); + +$tracer->flush(); +``` + +### Samplers + +List of supported samplers, for more info about samplers, please read [Jaeger Sampling](https://www.jaegertracing.io/docs/1.9/sampling/) guide. + +#### Const sampler +This sampler either samples everything, or nothing. + +##### Configuration +``` +'sampler' => [ + 'type' => Jaeger\SAMPLER_TYPE_CONST, + 'param' => true, // boolean wheter to trace or not +], +``` + +#### Probabilistic sampler +This sampler samples request by given rate. + +##### Configuration +``` +'sampler' => [ + 'type' => Jaeger\SAMPLER_TYPE_PROBABILISTIC, + 'param' => 0.5, // float [0.0, 1.0] +], +``` + +#### Rate limiting sampler +Samples maximum specified number of traces (requests) per second. + +##### Requirements +* `psr/cache` PSR-6 cache component to store and retrieve sampler state between requests. +Cache component is passed to `Jaeger\Config` trough its constructor. +* `hrtime()` function, that can retrieve time in nanoseconds. You need either `php 7.3` or [PECL/hrtime](http://pecl.php.net/package/hrtime) extension. + +##### Configuration +``` +'sampler' => [ + 'type' => Jaeger\SAMPLER_TYPE_RATE_LIMITING, + 'param' => 100 // integer maximum number of traces per second, + 'cache' => [ + 'currentBalanceKey' => 'rate.currentBalance' // string + 'lastTickKey' => 'rate.lastTick' // string + ] +], +``` +## Dispatch mode + +The library supports 3 ways of sending data to Jaeger Agent: + +1. `Zipkin.thrift` over Compact protocol (socket - UDP) - default +2. `Jaeger.thrift` over Binary protocol (socket - UDP) +2. `Jaeger.thrift` over Binary protocol (HTTP) + +If you want to enable "`Jaeger.thrift` over Binary protocol" one or other, than +you need to set `dispatch_mode` config option or `JAEGER_DISPATCH_MODE` env +variable. + +Allowed values for `dispatch_mode` are: +- `jaeger_over_binary_udp` +- `jaeger_over_binary_http` +- `zipkin_over_compact_udp` + +There are 3 constants available, so it is better to use them: +```php +class Config +{ + const ZIPKIN_OVER_COMPACT_UDP = "zipkin_over_compact_udp"; + const JAEGER_OVER_BINARY_UDP = "jaeger_over_binary_udp"; + const JAEGER_OVER_BINARY_HTTP = "jaeger_over_binary_http"; + ... +} +``` + +A possible config with custom `dispatch_mode` can look like this: +```php +// config.php + +use Jaeger\Config; + +return [ + 'sampler' => [ + 'type' => Jaeger\SAMPLER_TYPE_CONST, + 'param' => true, + ], + 'logging' => true, + "tags" => [ + // process. prefix works only with JAEGER_OVER_HTTP, JAEGER_OVER_BINARY + // otherwise it will be shown as simple global tag + "process.process-tag-key-1" => "process-value-1", // all tags with `process.` prefix goes to process section + "process.process-tag-key-2" => "process-value-2", // all tags with `process.` prefix goes to process section + "global-tag-key-1" => "global-tag-value-1", // this tag will be appended to all spans + "global-tag-key-2" => "global-tag-value-2", // this tag will be appended to all spans + ], + "local_agent" => [ + "reporting_host" => "localhost", +// You can override port by setting local_agent.reporting_port value + "reporting_port" => 6832 + ], +// Different ways to send data to Jaeger. Config::ZIPKIN_OVER_COMPACT - default): + 'dispatch_mode' => Config::JAEGER_OVER_BINARY_UDP, +]; +``` +The full example you can see at `examples` directory. + +By default, for each `dispatch_mode` there is default `reporting_port` config value. Table with +default values you can see below: + +`dispatch_mode` | default `reporting_port` +------------------------ | ---------------- +ZIPKIN_OVER_COMPACT_UDP | 5775 +JAEGER_OVER_BINARY_UDP | 6832 +JAEGER_OVER_BINARY_HTTP | 14268 + +## IPv6 + +In case you need IPv6 support you need to set `ip_version` Config variable. +By default, IPv4 is used. There is an alias `Config::IP_VERSION` which you can use +as an alternative to raw `ip_version`. + +Example: + +```php +use Jaeger\Config; + +$config = new Config( + [ + "ip_version" => Config::IPV6, // <-- or use Config::IP_VERSION constant + 'logging' => true, + 'dispatch_mode' => Config::JAEGER_OVER_BINARY_UDP, + ], + 'serviceNameExample', +); +$config->initializeTracer(); +``` +or + +```php +use Jaeger\Config; + +$config = new Config( + [ + Config::IP_VERSION => Config::IPV6, // <-- + 'logging' => true, + 'dispatch_mode' => Config::JAEGER_OVER_BINARY_UDP, + ], + 'serviceNameExample', +); +$config->initializeTracer(); +``` + + +## Testing + +Tests are located in the `tests` directory. See [tests/README.md](./tests/README.md). + +## Roadmap + +- [Support Span baggage](https://github.com/jonahgeorge/jaeger-client-php/issues/5) +- [Support Tracer metrics](https://github.com/jonahgeorge/jaeger-client-php/issues/12) +- [Support Tracer error reporting](https://github.com/jonahgeorge/jaeger-client-php/issues/13) + +## License + +[MIT License](./LICENSE). + +[ci-img]: https://travis-ci.org/jonahgeorge/jaeger-client-php.svg?branch=travis +[ci]: https://travis-ci.org/jonahgeorge/jaeger-client-php +[packagist-img]: https://badge.fury.io/ph/jonahgeorge%2Fjaeger-client-php.svg +[packagist]: https://badge.fury.io/ph/jonahgeorge%2Fjaeger-client-php diff --git a/vendor/jonahgeorge/jaeger-client-php/build/.gitignore b/vendor/jonahgeorge/jaeger-client-php/build/.gitignore new file mode 100644 index 000000000..d6b7ef32c --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/build/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/vendor/jonahgeorge/jaeger-client-php/composer.json b/vendor/jonahgeorge/jaeger-client-php/composer.json new file mode 100644 index 000000000..a9bb99a06 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/composer.json @@ -0,0 +1,62 @@ +{ + "name": "jonahgeorge/jaeger-client-php", + "description": "Jaeger Bindings for PHP OpenTracing API", + "keywords": [ + "jaeger", + "opentracing", + "trace", + "tracing" + ], + "license": "MIT", + "authors": [ + { + "name": "Jonah George", + "homepage": "http://twitter.com/jonahgeorge" + }, + { + "name": "José Carlos Chávez", + "email": "jcchavezs@gmail.com" + }, + { + "name": "Contributors", + "homepage": "https://github.com/jonahgeorge/jaeger-client-php/graphs/contributors" + } + ], + "require": { + "php": "^7.1 || ^8.0 || ^8.1", + "ext-sockets": "*", + "opentracing/opentracing": "^1.0", + "packaged/thrift": "^0.13", + "psr/cache": "^1.0 || ^2.0 || ^3.0", + "psr/log": "^1.0 || ^2.0 || ^3.0" + }, + "require-dev": { + "phpunit/phpunit": "^7 || ^8 || ^9", + "squizlabs/php_codesniffer": "3.*", + "cache/array-adapter": "^1.0", + "symfony/polyfill-php73": "^1.10" + }, + "config": { + "optimize-autoloader": true, + "preferred-install": "dist", + "sort-packages": true + }, + "autoload": { + "psr-4": { + "Jaeger\\": "src/Jaeger/" + }, + "files": [ + "./src/Jaeger/Constants.php" + ] + }, + "autoload-dev": { + "Jaeger\\Tests\\": "tests/Jaeger/" + }, + "minimum-stability": "dev", + "prefer-stable": true, + "scripts": { + "fix-lint": "./vendor/bin/phpcbf", + "lint": "./vendor/bin/phpcs", + "test": "./vendor/bin/phpunit" + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/examples/config.php b/vendor/jonahgeorge/jaeger-client-php/examples/config.php new file mode 100644 index 000000000..5c4726165 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/examples/config.php @@ -0,0 +1,26 @@ + [ + 'type' => Jaeger\SAMPLER_TYPE_CONST, + 'param' => true, + ], + 'logging' => true, + "tags" => [ + // process. prefix works only with JAEGER_OVER_HTTP, JAEGER_OVER_BINARY + // otherwise it will be shown as simple global tag + "process.process-tag-key-1" => "process-value-1", // all tags with `process.` prefix goes to process section + "process.process-tag-key-2" => "process-value-2", // all tags with `process.` prefix goes to process section + "global-tag-key-1" => "global-tag-value-1", // this tag will be appended to all spans + "global-tag-key-2" => "global-tag-value-2", // this tag will be appended to all spans + ], + "local_agent" => [ + "reporting_host" => "localhost", +// You can override port by setting local_agent.reporting_port value +// "reporting_port" => 6832 + ], +// Different ways to send data to Jaeger. Config::ZIPKIN_OVER_COMPACT - default): + 'dispatch_mode' => Config::JAEGER_OVER_BINARY_UDP, +]; diff --git a/vendor/jonahgeorge/jaeger-client-php/examples/jaeger.php b/vendor/jonahgeorge/jaeger-client-php/examples/jaeger.php new file mode 100644 index 000000000..ed9304fe2 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/examples/jaeger.php @@ -0,0 +1,51 @@ +initializeTracer(); + +$tracer = GlobalTracer::get(); + +$scope = $tracer->startActiveSpan('JaegerSpan', []); +$scope->getSpan()->setTag("tag1", "value1"); +$scope->getSpan()->setTag("tag2", "value2"); +$scope->getSpan()->setTag("tag3", "value2"); +$scope->getSpan()->log([ + "key1" => "value1", + "key2" => 2, + "key3" => true +]); + +$scope->getSpan()->addBaggageItem("baggage-item1", "baggage-value1"); +$scope->getSpan()->addBaggageItem("baggage-item2", "baggage-value2"); +$scope->getSpan()->addBaggageItem("baggage-item3", "baggage-value3"); + + $nestedSpanScope = $tracer->startActiveSpan("Nested1"); + $nestedSpanScope->getSpan()->setTag("tag1", "value1"); + $nestedSpanScope->getSpan()->setTag("tag2", "value2"); + $nestedSpanScope->getSpan()->setTag("tag3", "value2"); + $nestedSpanScope->getSpan()->log([ + "key1" => "value1", + "key2" => 2, + "key3" => true + ]); + + $nestedSpanScope->getSpan()->addBaggageItem("baggage-item1", "baggage-value1"); + $nestedSpanScope->getSpan()->addBaggageItem("baggage-item2", "baggage-value2"); + $nestedSpanScope->getSpan()->addBaggageItem("baggage-item3", "baggage-value3"); + + sleep(1); + + $nestedSpanScope->close(); + +sleep(1); +$scope->close(); +$tracer->flush(); diff --git a/vendor/jonahgeorge/jaeger-client-php/phpcs.xml.dist b/vendor/jonahgeorge/jaeger-client-php/phpcs.xml.dist new file mode 100644 index 000000000..7d5db0974 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/phpcs.xml.dist @@ -0,0 +1,37 @@ + + + + + The coding standard for Jaeger Client + + + + + + + + + + + + src + + + src/Jaeger/Thrift/* + diff --git a/vendor/jonahgeorge/jaeger-client-php/phpunit.xml.dist b/vendor/jonahgeorge/jaeger-client-php/phpunit.xml.dist new file mode 100644 index 000000000..d6795d99b --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/phpunit.xml.dist @@ -0,0 +1,47 @@ + + + + + src/Jaeger + + src/ + src/Jaeger/Constants.php + src/Jaeger/Thrift/Agent/AgentIf.php + src/Jaeger/Thrift/Agent/AggregationValidatorIf.php + src/Jaeger/Thrift/Agent/BaggageRestrictionManagerIf.php + src/Jaeger/Thrift/Agent/DependencyIf.php + src/Jaeger/Thrift/Agent/SamplingManagerIf.php + src/Jaeger/Thrift/CollectorIf.php + src/Jaeger/Thrift/Crossdock/TracedServiceIf.php + + + + + + + tests/Jaeger + + + + + + + + + + + + + + + diff --git a/vendor/jonahgeorge/jaeger-client-php/scripts/thrift-gen.sh b/vendor/jonahgeorge/jaeger-client-php/scripts/thrift-gen.sh new file mode 100644 index 000000000..7420f915f --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/scripts/thrift-gen.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +set -e + +cd "$(dirname "$0")/.." + +# checkout jaeger thrift files +rm -rf jaeger-idl +git clone https://github.com/jaegertracing/jaeger-idl + +# define thrift cmd +THRIFT="docker run -u $(id -u) -v '${PWD}:/data' thrift:0.11.0 thrift -o /data/jaeger-idl" +THRIFT_CMD="${THRIFT} --gen php:psr4,oop" + +# generate php files +FILES=$(find jaeger-idl/thrift -type f -name \*.thrift) +for f in ${FILES}; do + echo "${THRIFT_CMD} "/data/${f}"" + eval $THRIFT_CMD "/data/${f}" +done + +# move generated files +rm -rf src/Jaeger/Thrift +mv jaeger-idl/gen-php/Jaeger/Thrift src/Jaeger/Thrift + +# remove thrift files +rm -rf jaeger-idl diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/AgentClient/HttpAgentClient.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/AgentClient/HttpAgentClient.php new file mode 100644 index 000000000..e270b76ac --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/AgentClient/HttpAgentClient.php @@ -0,0 +1,27 @@ +input_ = $input; + $this->output_ = $output ? $output : $input; + } + + public function emitZipkinBatch(array $spans) + { + } + + public function emitBatch(\Jaeger\Thrift\Batch $batch) + { + $batch->write($this->output_); + $this->output_->getTransport()->flush(); + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Codec/BinaryCodec.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Codec/BinaryCodec.php new file mode 100644 index 000000000..36c2ffe2c --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Codec/BinaryCodec.php @@ -0,0 +1,39 @@ +urlEncoding = $urlEncoding; + $this->traceIdHeader = str_replace('_', '-', strtolower($traceIdHeader)); + $this->baggagePrefix = str_replace('_', '-', strtolower($baggageHeaderPrefix)); + $this->debugIdHeader = str_replace('_', '-', strtolower($debugIdHeader)); + $this->prefixLength = strlen($baggageHeaderPrefix); + } + + /** + * {@inheritdoc} + * + * @see \Jaeger\Tracer::inject + * + * @param SpanContext $spanContext + * @param mixed $carrier + * + * @return void + */ + public function inject(SpanContext $spanContext, &$carrier) + { + $carrier[$this->traceIdHeader] = $this->spanContextToString( + $spanContext->getTraceId(), + $spanContext->getSpanId(), + $spanContext->getParentId(), + $spanContext->getFlags() + ); + + $baggage = $spanContext->getBaggage(); + if (empty($baggage)) { + return; + } + + foreach ($baggage as $key => $value) { + $encodedValue = $value; + + if ($this->urlEncoding) { + $encodedValue = urlencode($value); + } + + $carrier[$this->baggagePrefix . $key] = $encodedValue; + } + } + + /** + * {@inheritdoc} + * + * @see \Jaeger\Tracer::extract + * + * @param mixed $carrier + * @return SpanContext|null + * + * @throws Exception + */ + public function extract($carrier) + { + $traceId = null; + $spanId = null; + $parentId = null; + $flags = null; + $baggage = null; + $debugId = null; + + foreach ($carrier as $key => $value) { + $ucKey = strtolower($key); + + if ($ucKey === $this->traceIdHeader) { + if ($this->urlEncoding) { + $value = urldecode($value); + } + list($traceId, $spanId, $parentId, $flags) = + $this->spanContextFromString($value); + } elseif ($this->startsWith($ucKey, $this->baggagePrefix)) { + if ($this->urlEncoding) { + $value = urldecode($value); + } + $attrKey = substr($key, $this->prefixLength); + if ($baggage === null) { + $baggage = [strtolower($attrKey) => $value]; + } else { + $baggage[strtolower($attrKey)] = $value; + } + } elseif ($ucKey === $this->debugIdHeader) { + if ($this->urlEncoding) { + $value = urldecode($value); + } + $debugId = $value; + } + } + + if ($traceId === null && $baggage !== null) { + throw new Exception('baggage without trace ctx'); + } + + if ($traceId === null) { + if ($debugId !== null) { + return new SpanContext(null, null, null, null, [], $debugId); + } + return null; + } + + return new SpanContext($traceId, $spanId, $parentId, $flags, $baggage); + } + + /** + * Store a span context to a string. + * + * @param int $traceId + * @param int $spanId + * @param int $parentId + * @param int $flags + * @return string + */ + private function spanContextToString($traceId, $spanId, $parentId, $flags) + { + $parentId = $parentId ?? 0; + return sprintf('%x:%x:%x:%x', $traceId, $spanId, $parentId, $flags); + } + + /** + * Create a span context from a string. + * + * @param string $value + * @return array + * + * @throws Exception + */ + private function spanContextFromString($value): array + { + $parts = explode(':', $value); + + if (count($parts) != 4) { + throw new Exception('Malformed tracer state string.'); + } + + return [ + CodecUtility::hexToInt64($parts[0]), + CodecUtility::hexToInt64($parts[1]), + CodecUtility::hexToInt64($parts[2]), + $parts[3], + ]; + } + + /** + * Checks that a string ($haystack) starts with a given prefix ($needle). + * + * @param string $haystack + * @param string $needle + * @return bool + */ + private function startsWith(string $haystack, string $needle): bool + { + return substr($haystack, 0, strlen($needle)) == $needle; + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Codec/ZipkinCodec.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Codec/ZipkinCodec.php new file mode 100644 index 000000000..1ea5d7c0b --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Codec/ZipkinCodec.php @@ -0,0 +1,85 @@ +getTraceId()); + $carrier[self::SPAN_ID_NAME] = dechex($spanContext->getSpanId()); + if ($spanContext->getParentId() != null) { + $carrier[self::PARENT_ID_NAME] = dechex($spanContext->getParentId()); + } + $carrier[self::FLAGS_NAME] = (int) $spanContext->getFlags(); + } + + /** + * {@inheritdoc} + * + * @see \Jaeger\Tracer::extract + * + * @param mixed $carrier + * @return SpanContext|null + */ + public function extract($carrier) + { + $traceId = "0"; + $spanId = "0"; + $parentId = "0"; + $flags = 0; + + if (isset($carrier[strtolower(self::SAMPLED_NAME)])) { + if ($carrier[strtolower(self::SAMPLED_NAME)] === "1" || + strtolower($carrier[strtolower(self::SAMPLED_NAME)] === "true") + ) { + $flags = $flags | SAMPLED_FLAG; + } + } + + if (isset($carrier[strtolower(self::TRACE_ID_NAME)])) { + $traceId = CodecUtility::hexToInt64($carrier[strtolower(self::TRACE_ID_NAME)], 16, 10); + } + + if (isset($carrier[strtolower(self::PARENT_ID_NAME)])) { + $parentId = CodecUtility::hexToInt64($carrier[strtolower(self::PARENT_ID_NAME)], 16, 10); + } + + if (isset($carrier[strtolower(self::SPAN_ID_NAME)])) { + $spanId = CodecUtility::hexToInt64($carrier[strtolower(self::SPAN_ID_NAME)], 16, 10); + } + + if (isset($carrier[strtolower(self::FLAGS_NAME)])) { + if ($carrier[strtolower(self::FLAGS_NAME)] === "1") { + $flags = $flags | DEBUG_FLAG; + } + } + + if ($traceId != "0" && $spanId != "0") { + return new SpanContext($traceId, $spanId, $parentId, $flags); + } + + return null; + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Config.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Config.php new file mode 100644 index 000000000..28fb972da --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Config.php @@ -0,0 +1,390 @@ +logger; + } + + /** + * @var CacheItemPoolInterface + */ + private $cache; + + /** + * Config constructor. + * @param array $config + * @param string|null $serviceName + * @param LoggerInterface|null $logger + * @param CacheItemPoolInterface|null $cache + * @throws Exception + */ + public function __construct( + array $config, + string $serviceName = null, + LoggerInterface $logger = null, + CacheItemPoolInterface $cache = null + ) { + $this->config = $config; + + $this->setConfigFromEnv(); + + if (empty($this->config["dispatch_mode"])) { + $this->config["dispatch_mode"] = self::ZIPKIN_OVER_COMPACT_UDP; + } + + if (empty($this->config[Config::IP_VERSION])) { + $this->config[Config::IP_VERSION] = self::IPV4; + } + + $this->serviceName = $this->config['service_name'] ?? $serviceName; + + if ($this->serviceName === null) { + throw new Exception('service_name required in the config or param.'); + } + + $this->logger = $logger ?: new NullLogger(); + $this->cache = $cache; + } + + /** + * @return Tracer|null + * @throws Exception + */ + public function initializeTracer() + { + if ($this->initialized) { + $this->logger->warning('Jaeger tracer already initialized, skipping'); + return null; + } + + $reporter = $this->getReporter(); + $sampler = $this->getSampler(); + + + $tracer = $this->createTracer($reporter, $sampler); + + $this->initializeGlobalTracer($tracer); + + return $tracer; + } + + /** + * @param ReporterInterface $reporter + * @param SamplerInterface $sampler + * @return Tracer + */ + public function createTracer(ReporterInterface $reporter, SamplerInterface $sampler): Tracer + { + return new Tracer( + $this->serviceName, + $reporter, + $sampler, + $this->shouldUseOneSpanPerRpc(), + $this->logger, + null, + $this->getTraceIdHeader(), + $this->getBaggageHeaderPrefix(), + $this->getDebugIdHeaderKey(), + $this->getConfiguredTags() + ); + } + + /** + * @return string + */ + public function getServiceName(): string + { + return $this->serviceName; + } + + /** + * @param Tracer $tracer + */ + private function initializeGlobalTracer(Tracer $tracer) + { + GlobalTracer::set($tracer); + $this->logger->debug('OpenTracing\GlobalTracer initialized to ' . $tracer->getServiceName()); + } + + /** + * @return bool + */ + private function getLogging(): bool + { + return (bool)($this->config['logging'] ?? false); + } + + /** + * @return ReporterInterface + */ + private function getReporter(): ReporterInterface + { + switch ($this->config["dispatch_mode"]) { + case self::JAEGER_OVER_BINARY_UDP: + $reporter = (new JaegerReporterFactory($this))->createReporter(); + break; + case self::ZIPKIN_OVER_COMPACT_UDP: + $reporter = (new ZipkinReporterFactory($this))->createReporter(); + break; + case self::JAEGER_OVER_BINARY_HTTP: + $reporter = (new JaegerHttpReporterFactory($this))->createReporter(); + break; + default: + throw new \RuntimeException( + sprintf( + "Unsupported `dispatch_mode` value: %s. Allowed values are: %s", + $this->config["dispatch_mode"], + implode(", ", Config::getAvailableDispatchModes()) + ) + ); + } + + if ($this->getLogging()) { + $reporter = new CompositeReporter($reporter, new LoggingReporter($this->logger)); + } + + return $reporter; + } + + /** + * @return SamplerInterface + * @throws \Psr\Cache\InvalidArgumentException + * @throws Exception + */ + private function getSampler(): SamplerInterface + { + $samplerConfig = $this->config['sampler'] ?? []; + $samplerType = $samplerConfig['type'] ?? null; + $samplerParam = $samplerConfig['param'] ?? null; + + if ($samplerType === null || $samplerType === SAMPLER_TYPE_REMOTE) { + // todo: implement remote sampling + return new ProbabilisticSampler((float)$samplerParam); + } elseif ($samplerType === SAMPLER_TYPE_CONST) { + return new ConstSampler($samplerParam ?? false); + } elseif ($samplerType === SAMPLER_TYPE_PROBABILISTIC) { + return new ProbabilisticSampler((float)$samplerParam); + } elseif ($samplerType === SAMPLER_TYPE_RATE_LIMITING) { + if (!$this->cache) { + throw new Exception('You cannot use RateLimitingSampler without cache component'); + } + $cacheConfig = $samplerConfig['cache'] ?? []; + return new RateLimitingSampler( + $samplerParam ?? 0, + new RateLimiter( + $this->cache, + $cacheConfig['currentBalanceKey'] ?? 'rate.currentBalance', + $cacheConfig['lastTickKey'] ?? 'rate.lastTick' + ) + ); + } + throw new Exception('Unknown sampler type ' . $samplerType); + } + + /** + * The UDP max buffer length. + * + * @return int + */ + public function getMaxBufferLength(): int + { + return (int)($this->config['max_buffer_length'] ?? 64000); + } + + /** + * @return string + */ + public function getLocalAgentReportingHost(): string + { + return $this->getLocalAgentGroup()['reporting_host'] ?? DEFAULT_REPORTING_HOST; + } + + /** + * @return int + */ + public function getLocalAgentReportingPort(): int + { + $port = $this->getLocalAgentGroup()['reporting_port'] ?? null; + if (empty($this->getLocalAgentGroup()['reporting_port'])) { + switch ($this->config['dispatch_mode']) { + case self::JAEGER_OVER_BINARY_UDP: + $port = DEFAULT_JAEGER_UDP_BINARY_REPORTING_PORT; + break; + case self::JAEGER_OVER_BINARY_HTTP: + $port = DEFAULT_JAEGER_HTTP_BINARY_REPORTING_PORT; + break; + default: + $port = DEFAULT_ZIPKIN_UDP_COMPACT_REPORTING_PORT; + } + } + return (int)$port; + } + + /** + * @return array + */ + private function getLocalAgentGroup(): array + { + return $this->config['local_agent'] ?? []; + } + + /** + * @return string + */ + private function getTraceIdHeader(): string + { + return $this->config['trace_id_header'] ?? TRACE_ID_HEADER; + } + + /** + * @return string + */ + private function getBaggageHeaderPrefix(): string + { + return $this->config['baggage_header_prefix'] ?? BAGGAGE_HEADER_PREFIX; + } + + /** + * @return string + */ + private function getDebugIdHeaderKey(): string + { + return $this->config['debug_id_header_key'] ?? DEBUG_ID_HEADER_KEY; + } + + /** + * Get a list of user-defined tags to be added to each span created by the tracer initialized by this config. + * @return string[] + */ + private function getConfiguredTags(): array + { + return $this->config['tags'] ?? []; + } + + /** + * Whether to follow the Zipkin model of using one span per RPC, + * as opposed to the model of using separate spans on the RPC client and server. + * Defaults to true. + * + * @return bool + */ + private function shouldUseOneSpanPerRpc(): bool + { + return $this->config['one_span_per_rpc'] ?? true; + } + + public function ipProtocolVersion(): string + { + return $this->config[self::IP_VERSION] ?? self::IPV4; + } + + /** + * Sets values from env vars into config props, unless ones has been already set. + */ + private function setConfigFromEnv() + { + // general + if (isset($_ENV['JAEGER_SERVICE_NAME']) && !isset($this->config['service_name'])) { + $this->config['service_name'] = $_ENV['JAEGER_SERVICE_NAME']; + } + + if (isset($_ENV['JAEGER_TAGS']) && !isset($this->config["tags"])) { + $this->config['tags'] = $_ENV['JAEGER_TAGS']; + } + + if (isset($_ENV['JAEGER_DISPATCH_MODE']) && !isset($this->config['dispatch_mode'])) { + $this->config['dispatch_mode'] = $_ENV['JAEGER_DISPATCH_MODE']; + } + + // reporting + if (isset($_ENV['JAEGER_AGENT_HOST']) && !isset($this->config['local_agent']['reporting_host'])) { + $this->config['local_agent']['reporting_host'] = $_ENV['JAEGER_AGENT_HOST']; + } + + if (isset($_ENV['JAEGER_AGENT_PORT']) && !isset($this->config['local_agent']['reporting_port'])) { + $this->config['local_agent']['reporting_port'] = intval($_ENV['JAEGER_AGENT_PORT']); + } + + if (isset($_ENV['JAEGER_REPORTER_LOG_SPANS']) && !isset($this->config['logging'])) { + $this->config['logging'] = filter_var($_ENV['JAEGER_REPORTER_LOG_SPANS'], FILTER_VALIDATE_BOOLEAN); + } + + if (isset($_ENV['JAEGER_REPORTER_MAX_QUEUE_SIZE']) && !isset($this->config['max_buffer_length'])) { + $this->config['max_buffer_length'] = intval($_ENV['JAEGER_REPORTER_MAX_QUEUE_SIZE']); + } + + // sampling + if (isset($_ENV['JAEGER_SAMPLER_TYPE']) && !isset($this->config['sampler']['type'])) { + $this->config['sampler']['type'] = $_ENV['JAEGER_SAMPLER_TYPE']; + } + + if (isset($_ENV['JAEGER_SAMPLER_PARAM']) && !isset($this->config['sampler']['param'])) { + $this->config['sampler']['param'] = $_ENV['JAEGER_SAMPLER_PARAM']; + } + + if (isset($_ENV['IP_VERSION']) && !isset($this->config[Config::IP_VERSION])) { + $this->config[Config::IP_VERSION] = $_ENV['IP_VERSION']; + } + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Constants.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Constants.php new file mode 100644 index 000000000..1e4be65f5 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Constants.php @@ -0,0 +1,100 @@ +specialSpanTags; + } + + /** + * @return string + */ + public function getProcessTagsPrefix(): string + { + return $this->processTagsPrefix; + } + + public function mapSpanToJaeger(Span $span) : JaegerThriftSpan + { + $timestamp = $span->getStartTime(); + $duration = $span->getEndTime() - $span->getStartTime(); + + /** @var Tag[] $tags */ + $tags = []; + + $tags[] = new Tag([ + "key" => COMPONENT, + "vType" => TagType::STRING, + "vStr" => $span->getComponent() ?? $span->getTracer()->getServiceName(), + ]); + + // Handle special tags + $peerService = $span->peer['service_name'] ?? null; + if ($peerService !== null) { + $tags[] = new Tag([ + "key" => PEER_SERVICE, + "vType" => TagType::STRING, + "vStr" => $peerService, + ]); + } + + $peerHostIpv4 = $span->peer['ipv4'] ?? null; + if ($peerHostIpv4 !== null) { + $tags[] = new Tag([ + "key" => PEER_HOST_IPV4, + "vType" => TagType::STRING, + "vStr" => $peerHostIpv4, + ]); + } + + $peerPort = $span->peer['port'] ?? null; + if ($peerPort !== null) { + $tags[] = new Tag([ + "key" => PEER_PORT, + "vType" => TagType::LONG, + "vLong" => $peerPort, + ]); + } + + $spanKind = $span->getKind(); + if ($spanKind !== null) { + $tags[] = new Tag([ + "key" => SPAN_KIND, + "vType" => TagType::STRING, + "vStr" => $spanKind, + ]); + } + + /** @var BinaryAnnotation[] $binaryAnnotationTags */ + $binaryAnnotationTags = $span->getTags(); + foreach ($binaryAnnotationTags as $binaryAnnotationTag) { + if (in_array($binaryAnnotationTag->key, $this->specialSpanTags, true)) { + continue ; + } + + if (strpos($binaryAnnotationTag->key, $this->processTagsPrefix) === 0) { + continue; + } + + $type = ""; + $vkey = ""; + switch ($binaryAnnotationTag->annotation_type) { + case AnnotationType::BOOL: + $type = TagType::BOOL; + $vkey = "vBool"; + break; + case AnnotationType::BYTES: + $type = TagType::BINARY; + $vkey = "vBinary"; + break; + case AnnotationType::DOUBLE: + $type = TagType::DOUBLE; + $vkey = "vDouble"; + break; + case AnnotationType::I16: + case AnnotationType::I32: + case AnnotationType::I64: + $type = TagType::LONG; + $vkey = "vLong"; + break; + default: + $type = TagType::STRING; + $vkey = "vStr"; + } + + $tags[] = new Tag([ + "key" => $binaryAnnotationTag->key, + "vType" => $type, + $vkey => $binaryAnnotationTag->value, + ]); + } + + /** @var Log[] $logs */ + $logs = []; + + $spanLogs = $span->getLogs(); + + foreach ($spanLogs as $spanLog) { + /** @var Tag $fields */ + $fields = []; + + if (!empty($spanLog["fields"])) { + $fields[] = new Tag([ + "key" => "event", + "vType" => TagType::STRING, + "vStr" => json_encode($spanLog["fields"]) + ]); + } + + $logs[] = new Log([ + "timestamp" => $spanLog["timestamp"], + "fields" => $fields + ]); + } + + return new JaegerThriftSpan([ + "traceIdLow" => (int)$span->getContext()->getTraceId(), + "traceIdHigh" => 0, + "spanId" => (int)$span->getContext()->getSpanId(), + "parentSpanId" => (int)$span->getContext()->getParentId(), + "operationName" => $span->getOperationName(), + "startTime" => $timestamp, + "duration" => $duration, + "flags" => (int)$span->isDebug(), + "tags" => $tags, + "logs" => $logs + ]); + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Reporter/CompositeReporter.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Reporter/CompositeReporter.php new file mode 100644 index 000000000..78533cc76 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Reporter/CompositeReporter.php @@ -0,0 +1,51 @@ +reporters = $reporters; + } + + /** + * {@inheritdoc} + * + * @param Span $span + * @return void + */ + public function reportSpan(Span $span) + { + foreach ($this->reporters as $reporter) { + $reporter->reportSpan($span); + } + } + + /** + * {@inheritdoc} + * + * @return void + */ + public function close() + { + foreach ($this->reporters as $reporter) { + $reporter->close(); + } + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Reporter/InMemoryReporter.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Reporter/InMemoryReporter.php new file mode 100644 index 000000000..8aabe2ee8 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Reporter/InMemoryReporter.php @@ -0,0 +1,47 @@ +spans[] = $span; + } + + /** + * @return Span[] + */ + public function getSpans(): array + { + return $this->spans; + } + + /** + * {@inheritdoc} + * + * Only implemented to satisfy the sampler interface. + * + * @return void + */ + public function close() + { + // nothing to do + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Reporter/JaegerReporter.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Reporter/JaegerReporter.php new file mode 100644 index 000000000..999d69e0a --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Reporter/JaegerReporter.php @@ -0,0 +1,35 @@ +sender = $sender; + } + + public function reportSpan(Span $span) + { + $this->sender->append($span); + } + + public function close() + { + $this->sender->flush(); + $this->sender->close(); + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Reporter/LoggingReporter.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Reporter/LoggingReporter.php new file mode 100644 index 000000000..264ea94c5 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Reporter/LoggingReporter.php @@ -0,0 +1,51 @@ +logger = $logger ?? new NullLogger(); + } + + /** + * {@inheritdoc} + * + * @param Span $span + * @return void + */ + public function reportSpan(Span $span) + { + $this->logger->debug('Reporting span ' . $span->getOperationName()); + } + + /** + * {@inheritdoc} + * + * Only implemented to satisfy the sampler interface. + * + * @return void + */ + public function close() + { + // nothing to do + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Reporter/NullReporter.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Reporter/NullReporter.php new file mode 100644 index 000000000..84a953bef --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Reporter/NullReporter.php @@ -0,0 +1,32 @@ +transport = $transport; + } + + /** + * {@inheritdoc} + * + * @param Span $span + * @return void + */ + public function reportSpan(Span $span) + { + $this->transport->append($span); + } + + /** + * {@inheritdoc} + * + * @return void + */ + public function close() + { + $this->transport->flush(); + $this->transport->close(); + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Reporter/ReporterInterface.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Reporter/ReporterInterface.php new file mode 100644 index 000000000..fea8a8713 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Reporter/ReporterInterface.php @@ -0,0 +1,28 @@ +config = $config; + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/ReporterFactory/JaegerHttpReporterFactory.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/ReporterFactory/JaegerHttpReporterFactory.php new file mode 100644 index 000000000..038e81161 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/ReporterFactory/JaegerHttpReporterFactory.php @@ -0,0 +1,35 @@ +config->getLocalAgentReportingHost(), + $this->config->getLocalAgentReportingPort(), + "/api/traces" + ); + + try { + $transport->open(); + } catch (TTransportException $e) { + $this->config->getLogger()->warning($e->getMessage()); + } + $protocol = new TBinaryProtocol($transport); + $client = new HttpAgentClient($protocol); + $this->config->getLogger()->debug('Initializing HTTP Jaeger Tracer with Jaeger.Thrift over Binary protocol'); + $sender = new JaegerSender($client, $this->config->getLogger()); + $sender->setMaxBufferLength($this->config->getMaxBufferLength()); + return new JaegerReporter($sender); + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/ReporterFactory/JaegerReporterFactory.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/ReporterFactory/JaegerReporterFactory.php new file mode 100644 index 000000000..9865884b5 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/ReporterFactory/JaegerReporterFactory.php @@ -0,0 +1,44 @@ +config->getLocalAgentReportingHost(), + $this->config->getLocalAgentReportingPort(), + $this->config->getLogger(), + $this->config + ); + + $transport = new TBufferedTransport( + $udp, + $this->config->getMaxBufferLength(), + $this->config->getMaxBufferLength() + ); + + try { + $transport->open(); + } catch (TTransportException $e) { + $this->config->getLogger()->warning($e->getMessage()); + } + $protocol = new TBinaryProtocol($transport); + $client = new AgentClient($protocol); + $this->config->getLogger()->debug('Initializing UDP Jaeger Tracer with Jaeger.Thrift over Binary protocol'); + $sender = new JaegerSender($client, $this->config->getLogger()); + $sender->setMaxBufferLength($this->config->getMaxBufferLength()); + return new JaegerReporter($sender); + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/ReporterFactory/ReporterFactoryInterface.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/ReporterFactory/ReporterFactoryInterface.php new file mode 100644 index 000000000..4bfd3204f --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/ReporterFactory/ReporterFactoryInterface.php @@ -0,0 +1,10 @@ +config->getLocalAgentReportingHost(), + $this->config->getLocalAgentReportingPort(), + $this->config->getLogger(), + $this->config + ); + + $transport = new TBufferedTransport( + $udp, + $this->config->getMaxBufferLength(), + $this->config->getMaxBufferLength() + ); + + try { + $transport->open(); + } catch (TTransportException $e) { + $this->config->getLogger()->warning($e->getMessage()); + } + $protocol = new TCompactProtocol($transport); + $client = new AgentClient($protocol); + $this->config->getLogger()->debug('Initializing UDP Jaeger Tracer with Zipkin.Thrift over Compact protocol'); + $sender = new UdpSender($client, $this->config->getMaxBufferLength(), $this->config->getLogger()); + return new RemoteReporter($sender); + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Sampler/ConstSampler.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Sampler/ConstSampler.php new file mode 100644 index 000000000..7c6ba3d62 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Sampler/ConstSampler.php @@ -0,0 +1,68 @@ +tags = [ + SAMPLER_TYPE_TAG_KEY => SAMPLER_TYPE_CONST, + SAMPLER_PARAM_TAG_KEY => $decision, + ]; + + $this->decision = $decision; + } + + /** + * {@inheritdoc} + * + * @param string $traceId The traceId on the span. + * @param string $operation The operation name set on the span. + * @return array + */ + public function isSampled(string $traceId, string $operation = ''): array + { + return [$this->decision, $this->tags]; + } + + /** + * {@inheritdoc} + * + * Only implemented to satisfy the sampler interface. + * + * @return void + */ + public function close() + { + // nothing to do + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Sampler/ProbabilisticSampler.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Sampler/ProbabilisticSampler.php new file mode 100644 index 000000000..cb265d01e --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Sampler/ProbabilisticSampler.php @@ -0,0 +1,88 @@ +tags = [ + SAMPLER_TYPE_TAG_KEY => SAMPLER_TYPE_PROBABILISTIC, + SAMPLER_PARAM_TAG_KEY => $rate, + ]; + + if ($rate < 0.0 || $rate > 1.0) { + throw new OutOfBoundsException('Sampling rate must be between 0.0 and 1.0.'); + } + + $this->rate = $rate; + if ($rate < 0.5) { + $this->boundary = (int)($rate * PHP_INT_MAX); + } else { + // more precise calculation due to int and float having different precision near PHP_INT_MAX + $this->boundary = PHP_INT_MAX - (int)((1 - $rate) * PHP_INT_MAX); + } + } + + /** + * {@inheritdoc} + * + * @param string $traceId The traceId on the span. + * @param string $operation The operation name set on the span. + * @return array + */ + public function isSampled(string $traceId, string $operation = ''): array + { + return [($traceId < $this->boundary), $this->tags]; + } + + /** + * {@inheritdoc} + * + * Only implemented to satisfy the sampler interface. + * + * @return void + */ + public function close() + { + // nothing to do + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Sampler/RateLimitingSampler.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Sampler/RateLimitingSampler.php new file mode 100644 index 000000000..d0ea0f180 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Sampler/RateLimitingSampler.php @@ -0,0 +1,62 @@ +tags = [ + SAMPLER_TYPE_TAG_KEY => SAMPLER_TYPE_RATE_LIMITING, + SAMPLER_PARAM_TAG_KEY => $maxTracesPerSecond, + ]; + + $maxTracesPerNanosecond = $maxTracesPerSecond / 1000000000.0; + $this->rateLimiter = $rateLimiter; + $this->rateLimiter->initialize($maxTracesPerNanosecond, $maxTracesPerSecond > 1.0 ? 1.0 : $maxTracesPerSecond); + } + + /** + * Whether or not the new trace should be sampled. + * + * Implementations should return an array in the format [$decision, $tags]. + * + * @param string $traceId The traceId on the span. + * @param string $operation The operation name set on the span. + * @return array + */ + public function isSampled(string $traceId = '', string $operation = '') + { + return [$this->rateLimiter->checkCredit(1.0), $this->tags]; + } + + /** + * {@inheritdoc} + * + * Only implemented to satisfy the sampler interface. + * + * @return void + */ + public function close() + { + // nothing to do + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Sampler/SamplerInterface.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Sampler/SamplerInterface.php new file mode 100644 index 000000000..b6d44e783 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Sampler/SamplerInterface.php @@ -0,0 +1,29 @@ +scopeManager = $scopeManager; + $this->wrapped = $wrapped; + $this->finishSpanOnClose = $finishSpanOnClose; + $this->toRestore = $scopeManager->getActive(); + } + + /** + * {@inheritdoc} + */ + public function close(): void + { + if ($this->scopeManager->getActive() !== $this) { + // This shouldn't happen if users call methods in expected order + return; + } + + if ($this->finishSpanOnClose) { + $this->wrapped->finish(); + } + + $this->scopeManager->setActive($this->toRestore); + } + + /** + * {@inheritdoc} + */ + public function getSpan(): OTSpan + { + return $this->wrapped; + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/ScopeManager.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/ScopeManager.php new file mode 100644 index 000000000..eb5c27676 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/ScopeManager.php @@ -0,0 +1,45 @@ +active = new Scope($this, $span, $finishSpanOnClose); + + return $this->active; + } + + /** + * {@inheritdoc} + */ + public function getActive(): ?OTScope + { + return $this->active; + } + + /** + * Sets the scope as active. + * @param OTScope|null $scope + */ + public function setActive(OTScope $scope = null) + { + $this->active = $scope; + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Sender/JaegerSender.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Sender/JaegerSender.php new file mode 100644 index 000000000..dfce510b8 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Sender/JaegerSender.php @@ -0,0 +1,236 @@ +agentClient = $agentClient; + $this->logger = $logger ?? new NullLogger(); + $this->mapper = $mapper ?? new SpanToJaegerMapper(); + } + + + public function flush(): int + { + $count = count($this->spans); + if ($count === 0) { + return 0; + } + + $jaegerThriftSpans = $this->makeJaegerBatch($this->spans); + + try { + $this->send($jaegerThriftSpans); + } catch (\Exception $e) { + $this->logger->warning($e->getMessage()); + } + + $this->spans = []; + + return $count; + } + + public function setMaxBufferLength($maxBufferLength) + { + $this->maxBufferLength = $maxBufferLength; + } + + /** + * @param JaegerSpan[] $spans + * @return array + */ + private function makeJaegerBatch(array $spans) : array + { + /** @var JaegerThriftSpan[] $jaegerSpans */ + $jaegerSpans = []; + + foreach ($spans as $span) { + if (empty($this->tracer)) { + $this->tracer = $span->getTracer(); + } + + $jaegerSpans[] = $this->mapper->mapSpanToJaeger($span); + } + + return $jaegerSpans; + } + + /** + * @param JaegerThriftSpan[] $spans + */ + private function send(array $spans) + { + if (empty($this->tracer)) { + return ; + } + + $chunks = $this->chunkSplit($spans); + foreach ($chunks as $chunk) { + /** @var JaegerThriftSpan[] $chunk */ + $this->emitJaegerBatch($chunk); + } + } + + /** + * @param JaegerThriftSpan $span + */ + private function getBufferLength($span) + { + $memoryBuffer = new TMemoryBuffer(); + $span->write(new TBinaryProtocol($memoryBuffer)); + return $memoryBuffer->available(); + } + + private function chunkSplit(array $spans): array + { + $actualBufferSize = $this->jaegerBatchOverheadLength; + $chunkId = 0; + $chunks = []; + + foreach ($spans as $span) { + $spanBufferLength = $this->getBufferLength($span); + if (!empty($chunks[$chunkId]) && ($actualBufferSize + $spanBufferLength) > $this->maxBufferLength) { + // point to next chunk + ++$chunkId; + + // reset buffer size + $actualBufferSize = $this->jaegerBatchOverheadLength; + } + + if (!isset($chunks[$chunkId])) { + $chunks[$chunkId] = []; + } + + $chunks[$chunkId][] = $span; + $actualBufferSize += $spanBufferLength; + } + + return $chunks; + } + + protected function emitJaegerBatch(array $spans) + { + /** @var Tag[] $tags */ + $tags = []; + + foreach ($this->tracer->getTags() as $k => $v) { + if (!in_array($k, $this->mapper->getSpecialSpanTags())) { + if (strpos($k, $this->mapper->getProcessTagsPrefix()) !== 0) { + continue ; + } + + $quoted = preg_quote($this->mapper->getProcessTagsPrefix()); + $k = preg_replace(sprintf('/^%s/', $quoted), '', $k); + } + + if ($k === JAEGER_HOSTNAME_TAG_KEY) { + $k = "hostname"; + } + + $tags[] = new Tag([ + "key" => $k, + "vType" => TagType::STRING, + "vStr" => $v + ]); + } + + $tags[] = new Tag([ + "key" => "format", + "vType" => TagType::STRING, + "vStr" => "jaeger.thrift" + ]); + + $tags[] = new Tag([ + "key" => "ip", + "vType" => TagType::STRING, + "vStr" => $this->tracer->getIpAddress() + ]); + + $batch = new Batch([ + "spans" => $spans, + "process" => new Process([ + "serviceName" => $this->tracer->getServiceName(), + "tags" => $tags + ]) + ]); + + $this->agentClient->emitBatch($batch); + } + + /** + * @param JaegerSpan $span + */ + public function append(JaegerSpan $span) + { + $this->spans[] = $span; + } + + public function close() + { + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Sender/SenderInterface.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Sender/SenderInterface.php new file mode 100644 index 000000000..24dc4fbfa --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Sender/SenderInterface.php @@ -0,0 +1,12 @@ +client = $client; + $this->maxBufferLength = $maxBufferLength; + $this->logger = $logger ?? new NullLogger(); + } + + /** + * @param JaegerSpan $span + */ + public function append(JaegerSpan $span) + { + $this->spans[] = $span; + } + + /** + * @return int the number of flushed spans + */ + public function flush(): int + { + $count = count($this->spans); + if ($count === 0) { + return 0; + } + + $zipkinSpans = $this->makeZipkinBatch($this->spans); + + try { + $this->send($zipkinSpans); + } catch (Exception $e) { + $this->logger->warning($e->getMessage()); + } + + $this->spans = []; + + return $count; + } + + public function close() + { + } + + /** + * Emits the thrift-objects. + * + * @param array|ThriftSpan[]|TBase[] $thrifts + */ + private function send(array $thrifts) + { + foreach ($this->chunkSplit($thrifts) as $chunk) { + /* @var $chunk ThriftSpan[] */ + $this->client->emitZipkinBatch($chunk); + } + } + + /** + * @param JaegerSpan[] $spans + * @return ThriftSpan[] + */ + private function makeZipkinBatch(array $spans): array + { + /** @var ThriftSpan[] */ + $zipkinSpans = []; + + foreach ($spans as $span) { + /** @var JaegerSpan $span */ + + $endpoint = $this->makeEndpoint( + $span->getTracer()->getIpAddress(), + 0, // span.port, + $span->getTracer()->getServiceName() + ); + + $timestamp = $span->getStartTime(); + $duration = $span->getEndTime() - $span->getStartTime(); + + $this->addZipkinAnnotations($span, $endpoint); + + $zipkinSpan = new ThriftSpan([ + 'name' => $span->getOperationName(), + 'id' => $span->getContext()->getSpanId(), + 'parent_id' => $span->getContext()->getParentId() ?? null, + 'trace_id' => $span->getContext()->getTraceId(), + 'annotations' => $this->createAnnotations($span, $endpoint), + 'binary_annotations' => $span->getTags(), + 'debug' => $span->isDebug(), + 'timestamp' => $timestamp, + 'duration' => $duration, + ]); + + $zipkinSpans[] = $zipkinSpan; + } + + return $zipkinSpans; + } + + private function addZipkinAnnotations(JaegerSpan $span, Endpoint $endpoint) + { + if ($span->isRpc() && $span->peer) { + $isClient = $span->isRpcClient(); + + $host = $this->makeEndpoint( + $span->peer['ipv4'] ?? 0, + $span->peer['port'] ?? 0, + $span->peer['service_name'] ?? '' + ); + + $key = ($isClient) ? self::SERVER_ADDR : self::CLIENT_ADDR; + + $peer = $this->makePeerAddressTag($key, $host); + $span->tags[$key] = $peer; + } else { + $tag = $this->makeLocalComponentTag( + $span->getComponent() ?? $span->getTracer()->getServiceName(), + $endpoint + ); + + $span->tags[COMPONENT] = $tag; + } + } + + private function makeLocalComponentTag(string $componentName, Endpoint $endpoint): BinaryAnnotation + { + return new BinaryAnnotation([ + 'key' => "lc", + 'value' => $componentName, + 'annotation_type' => AnnotationType::STRING, + 'host' => $endpoint, + ]); + } + + private function makeEndpoint(string $ipv4, int $port, string $serviceName): Endpoint + { + $ipv4 = $this->ipv4ToInt($ipv4); + + return new Endpoint([ + 'ipv4' => $ipv4, + 'port' => $port, + 'service_name' => $serviceName, + ]); + } + + private function ipv4ToInt(string $ipv4): int + { + if ($ipv4 == 'localhost') { + $ipv4 = '127.0.0.1'; + } elseif ($ipv4 == '::1') { + $ipv4 = '127.0.0.1'; + } + + $long = ip2long($ipv4); + if (PHP_INT_SIZE === 8) { + return $long >> 31 ? $long - (1 << 32) : $long; + } + return $long; + } + + // Used for Zipkin binary annotations like CA/SA (client/server address). + // They are modeled as Boolean type with '0x01' as the value. + private function makePeerAddressTag(string $key, Endpoint $host): BinaryAnnotation + { + return new BinaryAnnotation([ + "key" => $key, + "value" => '0x01', + "annotation_type" => AnnotationType::BOOL, + "host" => $host, + ]); + } + + /** + * Splits an array of thrift-objects into several chunks when the buffer limit has been reached. + * + * @param array|ThriftSpan[]|TBase[] $thrifts + * + * @return array + */ + private function chunkSplit(array $thrifts): array + { + $actualBufferSize = $this->zipkinBatchOverheadLength; + $chunkId = 0; + $chunks = []; + + foreach ($thrifts as $thrift) { + $spanBufferLength = $this->getBufferLength($thrift); + + if (!empty($chunks[$chunkId]) && ($actualBufferSize + $spanBufferLength) > $this->maxBufferLength) { + // point to next chunk + ++$chunkId; + + // reset buffer size + $actualBufferSize = $this->zipkinBatchOverheadLength; + } + + if (!isset($chunks[$chunkId])) { + $chunks[$chunkId] = []; + } + + $chunks[$chunkId][] = $thrift; + $actualBufferSize += $spanBufferLength; + } + + return $chunks; + } + + /** + * Returns the length of a thrift-object. + * + * @param ThriftSpan|TBase $thrift + * + * @return int + */ + private function getBufferLength($thrift): int + { + $memoryBuffer = new TMemoryBuffer(); + + $thrift->write(new TCompactProtocol($memoryBuffer)); + + return $memoryBuffer->available(); + } + + /* + * @param JaegerSpan $span + * @param Endpoint $endpoint + * + * @return array|Annotation[] + */ + private function createAnnotations(JaegerSpan $span, Endpoint $endpoint): array + { + $annotations = []; + + foreach ($span->getLogs() as $values) { + $annotations[] = new Annotation([ + 'timestamp' => $values['timestamp'], + 'value' => json_encode($values['fields']), + 'host' => $endpoint, + ]); + } + + return $annotations; + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Span.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Span.php new file mode 100644 index 000000000..abcb07c89 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Span.php @@ -0,0 +1,476 @@ +context = $context; + $this->tracer = $tracer; + + $this->operationName = $operationName; + $this->startTime = $this->microTime($startTime); + $this->endTime = null; + $this->kind = null; + $this->peer = null; + $this->component = null; + + foreach ($tags as $key => $value) { + $this->setTag($key, $value); + } + } + + /** + * Converts time to microtime int + * - int represents microseconds + * - float represents seconds + * + * @param int|float|DateTime|null $time + * @return int + */ + protected function microTime($time): int + { + if ($time === null) { + return $this->timestampMicro(); + } + + if ($time instanceof \DateTimeInterface) { + return (int)round($time->format('U.u') * 1000000, 0); + } + + if (is_int($time)) { + return $time; + } + + if (is_float($time)) { + return (int)round($time * 1000000, 0); + } + + throw new \InvalidArgumentException(sprintf( + 'Time should be one of the types int|float|DateTime|null, got %s.', + gettype($time) + )); + } + + /** + * @return Tracer + */ + public function getTracer(): Tracer + { + return $this->tracer; + } + + /** + * @return bool + */ + public function isDebug(): bool + { + return $this->debug; + } + + /** + * @return int + */ + public function getStartTime(): int + { + return $this->startTime; + } + + /** + * @return int|null + */ + public function getEndTime() + { + return $this->endTime; + } + + /** + * @return string + */ + public function getOperationName(): string + { + return $this->operationName; + } + + /** + * @return mixed + */ + public function getComponent() + { + // TODO + return $this->component; + } + + /** + * {@inheritdoc} + * + * @return SpanContext + */ + public function getContext(): OTSpanContext + { + return $this->context; + } + + /** + * {@inheritdoc} + */ + public function finish($finishTime = null, array $logRecords = []): void + { + if (!$this->isSampled()) { + return; + } + + foreach ($logRecords as $logRecord) { + $this->log($logRecord); + } + + $this->endTime = $this->microTime($finishTime); + $this->tracer->reportSpan($this); + } + + /** + * Returns true if the trace should be measured. + * + * @return bool + */ + public function isSampled(): bool + { + $context = $this->getContext(); + + return ($context->getFlags() & SAMPLED_FLAG) == SAMPLED_FLAG; + } + + /** + * {@inheritdoc} + */ + public function overwriteOperationName(string $newOperationName): void + { + // TODO log warning + $this->operationName = $newOperationName; + } + + /** + * {@inheritdoc} + * + * @param array $tags + * @return void + */ + public function setTags($tags) + { + foreach ($tags as $key => $value) { + $this->setTag($key, $value); + } + } + + /** + * {@inheritdoc} + */ + public function setTag(string $key, $value): void + { + if ($this->isSampled()) { + $special = self::SPECIAL_TAGS[$key] ?? null; + $handled = false; + + if ($special !== null && is_callable([$this, $special])) { + $handled = $this->$special($value); + } + + if (!$handled) { + $tag = $this->makeTag($key, $value); + $this->tags[$key] = $tag; + } + } + } + + const SPECIAL_TAGS = [ + PEER_SERVICE => 'setPeerService', + PEER_HOST_IPV4 => 'setPeerHostIpv4', + PEER_PORT => 'setPeerPort', + SPAN_KIND => 'setSpanKind', + COMPONENT => 'setComponent', + ]; + + /** + * Sets a low-cardinality identifier of the module, library, + * or package that is generating a span. + * + * @see Span::setTag() + * + * @param string $value + * @return bool + */ + private function setComponent($value): bool + { + $this->component = $value; + return true; + } + + /** + * @return bool + */ + private function setSpanKind($value): bool + { + $validSpanKinds = [ + SPAN_KIND_RPC_CLIENT, + SPAN_KIND_RPC_SERVER, + SPAN_KIND_MESSAGE_BUS_CONSUMER, + SPAN_KIND_MESSAGE_BUS_PRODUCER, + ]; + + if ($value === null || in_array($value, $validSpanKinds, true)) { + $this->kind = $value; + return true; + } + return false; + } + + /** + * @return string|null + */ + public function getKind(): ?string + { + return $this->kind; + } + + /** + * @return bool + */ + private function setPeerPort($value): bool + { + if ($this->peer === null) { + $this->peer = ['port' => $value]; + } else { + $this->peer['port'] = $value; + } + return true; + } + + /** + * @return bool + */ + private function setPeerHostIpv4($value): bool + { + if ($this->peer === null) { + $this->peer = ['ipv4' => $value]; + } else { + $this->peer['ipv4'] = $value; + } + return true; + } + + /** + * @return bool + */ + private function setPeerService($value): bool + { + if ($this->peer === null) { + $this->peer = ['service_name' => $value]; + } else { + $this->peer['service_name'] = $value; + } + return true; + } + + /** + * @return bool + */ + public function isRpc(): bool + { + return $this->kind == SPAN_KIND_RPC_CLIENT || $this->kind == SPAN_KIND_RPC_SERVER; + } + + /** + * @return bool + */ + public function isRpcClient(): bool + { + return $this->kind == SPAN_KIND_RPC_CLIENT; + } + + /** + * {@inheritdoc} + */ + public function log(array $fields = [], $timestamp = null): void + { + $timestamp = $this->microTime($timestamp); + if ($timestamp < $this->getStartTime()) { + $timestamp = $this->timestampMicro(); + } + + $this->logs[] = [ + 'fields' => $fields, + 'timestamp' => $timestamp, + ]; + } + + /** + * Returns the logs. + * + * [ + * [ + * 'timestamp' => timestamp in microsecond, + * 'fields' => [ + * 'error' => 'message', + * ] + * ] + * ] + * + * @return array + */ + public function getLogs(): array + { + return $this->logs; + } + + /** + * {@inheritdoc} + */ + public function addBaggageItem(string $key, string $value): void + { + $this->context = $this->context->withBaggageItem($key, $value); + } + + /** + * {@inheritdoc} + */ + public function getBaggageItem(string $key): ?string + { + return $this->context->getBaggageItem($key); + } + + /** + * @return array + */ + public function getTags(): array + { + return $this->tags; + } + + /** + * @return int + */ + private function timestampMicro(): int + { + return round(microtime(true) * 1000000); + } + + /** + * @param string $key + * @param mixed $value + * @return BinaryAnnotation + */ + private function makeTag(string $key, $value): BinaryAnnotation + { + $valueType = gettype($value); + $annotationType = null; + switch ($valueType) { + case "boolean": + $annotationType = AnnotationType::BOOL; + break; + case "integer": + $annotationType = AnnotationType::I64; + break; + case "double": + $annotationType = AnnotationType::DOUBLE; + break; + default: + $annotationType = AnnotationType::STRING; + $value = (string)$value; + if (strlen($value) > 1024) { + $value = substr($value, 0, 1024); + } + } + + return new BinaryAnnotation([ + 'key' => $key, + 'value' => $value, + 'annotation_type' => $annotationType, + ]); + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/SpanContext.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/SpanContext.php new file mode 100644 index 000000000..447ffd1a5 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/SpanContext.php @@ -0,0 +1,120 @@ +traceId = $traceId; + $this->spanId = $spanId; + $this->parentId = $parentId; + $this->flags = $flags; + $this->baggage = is_array($baggage) ? $baggage : []; + $this->debugId = $debugId; + } + + /** + * {@inheritdoc} + * @return ArrayIterator + */ + #[\ReturnTypeWillChange] + public function getIterator() + { + return new ArrayIterator($this->baggage); + } + + /** + * {@inheritdoc} + */ + public function getBaggageItem(string $key): ?string + { + return array_key_exists($key, $this->baggage) ? $this->baggage[$key] : null; + } + + /** + * {@inheritdoc} + * + * @param string $key + * @param string $value + * @return SpanContext + */ + public function withBaggageItem(string $key, string $value): OTSpanContext + { + return new self( + $this->traceId, + $this->spanId, + $this->parentId, + $this->flags, + [$key => $value] + $this->baggage + ); + } + + public function getTraceId() + { + return $this->traceId; + } + + public function getParentId() + { + return $this->parentId; + } + + public function getSpanId() + { + return $this->spanId; + } + + /** + * Get the span context flags. + * + * @return int|null + */ + public function getFlags() + { + return $this->flags; + } + + public function getBaggage() + { + return $this->baggage; + } + + public function getDebugId() + { + return $this->debugId; + } + + public function isDebugIdContainerOnly(): bool + { + return ($this->traceId === null) && ($this->debugId !== null); + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/AgentClient.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/AgentClient.php new file mode 100644 index 000000000..640df4598 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/AgentClient.php @@ -0,0 +1,76 @@ +input_ = $input; + $this->output_ = $output ? $output : $input; + } + + public function emitZipkinBatch(array $spans) + { + $this->send_emitZipkinBatch($spans); + } + + public function send_emitZipkinBatch(array $spans) + { + $args = new \Jaeger\Thrift\Agent\Agent_emitZipkinBatch_args(); + $args->spans = $spans; + $bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary'); + if ($bin_accel) + { + thrift_protocol_write_binary($this->output_, 'emitZipkinBatch', TMessageType::ONEWAY, $args, $this->seqid_, $this->output_->isStrictWrite()); + } + else + { + $this->output_->writeMessageBegin('emitZipkinBatch', TMessageType::ONEWAY, $this->seqid_); + $args->write($this->output_); + $this->output_->writeMessageEnd(); + $this->output_->getTransport()->flush(); + } + } + public function emitBatch(\Jaeger\Thrift\Batch $batch) + { + $this->send_emitBatch($batch); + } + + public function send_emitBatch(\Jaeger\Thrift\Batch $batch) + { + $args = new \Jaeger\Thrift\Agent\Agent_emitBatch_args(); + $args->batch = $batch; + $bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary'); + if ($bin_accel) + { + thrift_protocol_write_binary($this->output_, 'emitBatch', TMessageType::ONEWAY, $args, $this->seqid_, $this->output_->isStrictWrite()); + } + else + { + $this->output_->writeMessageBegin('emitBatch', TMessageType::ONEWAY, $this->seqid_); + $args->write($this->output_); + $this->output_->writeMessageEnd(); + $this->output_->getTransport()->flush(); + } + } +} + + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/AgentIf.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/AgentIf.php new file mode 100644 index 000000000..30efc8cf3 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/AgentIf.php @@ -0,0 +1,30 @@ + array( + 'var' => 'batch', + 'isRequired' => false, + 'type' => TType::STRUCT, + 'class' => '\Jaeger\Thrift\Batch', + ), + ); + + /** + * @var \Jaeger\Thrift\Batch + */ + public $batch = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'Agent_emitBatch_args'; + } + + public function read($input) + { + return $this->_read('Agent_emitBatch_args', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('Agent_emitBatch_args', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Agent_emitZipkinBatch_args.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Agent_emitZipkinBatch_args.php new file mode 100644 index 000000000..cc58527bb --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Agent_emitZipkinBatch_args.php @@ -0,0 +1,60 @@ + array( + 'var' => 'spans', + 'isRequired' => false, + 'type' => TType::LST, + 'etype' => TType::STRUCT, + 'elem' => array( + 'type' => TType::STRUCT, + 'class' => '\Jaeger\Thrift\Agent\Zipkin\Span', + ), + ), + ); + + /** + * @var \Jaeger\Thrift\Agent\Zipkin\Span[] + */ + public $spans = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'Agent_emitZipkinBatch_args'; + } + + public function read($input) + { + return $this->_read('Agent_emitZipkinBatch_args', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('Agent_emitZipkinBatch_args', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/AggregationValidatorClient.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/AggregationValidatorClient.php new file mode 100644 index 000000000..73825978a --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/AggregationValidatorClient.php @@ -0,0 +1,83 @@ +input_ = $input; + $this->output_ = $output ? $output : $input; + } + + public function validateTrace($traceId) + { + $this->send_validateTrace($traceId); + return $this->recv_validateTrace(); + } + + public function send_validateTrace($traceId) + { + $args = new \Jaeger\Thrift\Agent\AggregationValidator_validateTrace_args(); + $args->traceId = $traceId; + $bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary'); + if ($bin_accel) + { + thrift_protocol_write_binary($this->output_, 'validateTrace', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite()); + } + else + { + $this->output_->writeMessageBegin('validateTrace', TMessageType::CALL, $this->seqid_); + $args->write($this->output_); + $this->output_->writeMessageEnd(); + $this->output_->getTransport()->flush(); + } + } + + public function recv_validateTrace() + { + $bin_accel = ($this->input_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_read_binary'); + if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, '\Jaeger\Thrift\Agent\AggregationValidator_validateTrace_result', $this->input_->isStrictRead()); + else + { + $rseqid = 0; + $fname = null; + $mtype = 0; + + $this->input_->readMessageBegin($fname, $mtype, $rseqid); + if ($mtype == TMessageType::EXCEPTION) { + $x = new TApplicationException(); + $x->read($this->input_); + $this->input_->readMessageEnd(); + throw $x; + } + $result = new \Jaeger\Thrift\Agent\AggregationValidator_validateTrace_result(); + $result->read($this->input_); + $this->input_->readMessageEnd(); + } + if ($result->success !== null) { + return $result->success; + } + throw new \Exception("validateTrace failed: unknown result"); + } + +} + + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/AggregationValidatorIf.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/AggregationValidatorIf.php new file mode 100644 index 000000000..853cd2a4f --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/AggregationValidatorIf.php @@ -0,0 +1,27 @@ + array( + 'var' => 'traceId', + 'isRequired' => true, + 'type' => TType::STRING, + ), + ); + + /** + * @var string + */ + public $traceId = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'AggregationValidator_validateTrace_args'; + } + + public function read($input) + { + return $this->_read('AggregationValidator_validateTrace_args', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('AggregationValidator_validateTrace_args', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/AggregationValidator_validateTrace_result.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/AggregationValidator_validateTrace_result.php new file mode 100644 index 000000000..6060c5ae3 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/AggregationValidator_validateTrace_result.php @@ -0,0 +1,56 @@ + array( + 'var' => 'success', + 'isRequired' => false, + 'type' => TType::STRUCT, + 'class' => '\Jaeger\Thrift\Agent\ValidateTraceResponse', + ), + ); + + /** + * @var \Jaeger\Thrift\Agent\ValidateTraceResponse + */ + public $success = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'AggregationValidator_validateTrace_result'; + } + + public function read($input) + { + return $this->_read('AggregationValidator_validateTrace_result', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('AggregationValidator_validateTrace_result', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/BaggageRestriction.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/BaggageRestriction.php new file mode 100644 index 000000000..27593c4c1 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/BaggageRestriction.php @@ -0,0 +1,65 @@ + array( + 'var' => 'baggageKey', + 'isRequired' => true, + 'type' => TType::STRING, + ), + 2 => array( + 'var' => 'maxValueLength', + 'isRequired' => true, + 'type' => TType::I32, + ), + ); + + /** + * @var string + */ + public $baggageKey = null; + /** + * @var int + */ + public $maxValueLength = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'BaggageRestriction'; + } + + public function read($input) + { + return $this->_read('BaggageRestriction', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('BaggageRestriction', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/BaggageRestrictionManagerClient.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/BaggageRestrictionManagerClient.php new file mode 100644 index 000000000..379153534 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/BaggageRestrictionManagerClient.php @@ -0,0 +1,83 @@ +input_ = $input; + $this->output_ = $output ? $output : $input; + } + + public function getBaggageRestrictions($serviceName) + { + $this->send_getBaggageRestrictions($serviceName); + return $this->recv_getBaggageRestrictions(); + } + + public function send_getBaggageRestrictions($serviceName) + { + $args = new \Jaeger\Thrift\Agent\BaggageRestrictionManager_getBaggageRestrictions_args(); + $args->serviceName = $serviceName; + $bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary'); + if ($bin_accel) + { + thrift_protocol_write_binary($this->output_, 'getBaggageRestrictions', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite()); + } + else + { + $this->output_->writeMessageBegin('getBaggageRestrictions', TMessageType::CALL, $this->seqid_); + $args->write($this->output_); + $this->output_->writeMessageEnd(); + $this->output_->getTransport()->flush(); + } + } + + public function recv_getBaggageRestrictions() + { + $bin_accel = ($this->input_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_read_binary'); + if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, '\Jaeger\Thrift\Agent\BaggageRestrictionManager_getBaggageRestrictions_result', $this->input_->isStrictRead()); + else + { + $rseqid = 0; + $fname = null; + $mtype = 0; + + $this->input_->readMessageBegin($fname, $mtype, $rseqid); + if ($mtype == TMessageType::EXCEPTION) { + $x = new TApplicationException(); + $x->read($this->input_); + $this->input_->readMessageEnd(); + throw $x; + } + $result = new \Jaeger\Thrift\Agent\BaggageRestrictionManager_getBaggageRestrictions_result(); + $result->read($this->input_); + $this->input_->readMessageEnd(); + } + if ($result->success !== null) { + return $result->success; + } + throw new \Exception("getBaggageRestrictions failed: unknown result"); + } + +} + + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/BaggageRestrictionManagerIf.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/BaggageRestrictionManagerIf.php new file mode 100644 index 000000000..010bda741 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/BaggageRestrictionManagerIf.php @@ -0,0 +1,31 @@ + array( + 'var' => 'serviceName', + 'isRequired' => false, + 'type' => TType::STRING, + ), + ); + + /** + * @var string + */ + public $serviceName = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'BaggageRestrictionManager_getBaggageRestrictions_args'; + } + + public function read($input) + { + return $this->_read('BaggageRestrictionManager_getBaggageRestrictions_args', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('BaggageRestrictionManager_getBaggageRestrictions_args', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/BaggageRestrictionManager_getBaggageRestrictions_result.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/BaggageRestrictionManager_getBaggageRestrictions_result.php new file mode 100644 index 000000000..a3c52b37c --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/BaggageRestrictionManager_getBaggageRestrictions_result.php @@ -0,0 +1,60 @@ + array( + 'var' => 'success', + 'isRequired' => false, + 'type' => TType::LST, + 'etype' => TType::STRUCT, + 'elem' => array( + 'type' => TType::STRUCT, + 'class' => '\Jaeger\Thrift\Agent\BaggageRestriction', + ), + ), + ); + + /** + * @var \Jaeger\Thrift\Agent\BaggageRestriction[] + */ + public $success = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'BaggageRestrictionManager_getBaggageRestrictions_result'; + } + + public function read($input) + { + return $this->_read('BaggageRestrictionManager_getBaggageRestrictions_result', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('BaggageRestrictionManager_getBaggageRestrictions_result', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Dependencies.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Dependencies.php new file mode 100644 index 000000000..4295b9798 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Dependencies.php @@ -0,0 +1,61 @@ + array( + 'var' => 'links', + 'isRequired' => true, + 'type' => TType::LST, + 'etype' => TType::STRUCT, + 'elem' => array( + 'type' => TType::STRUCT, + 'class' => '\Jaeger\Thrift\Agent\DependencyLink', + ), + ), + ); + + /** + * @var \Jaeger\Thrift\Agent\DependencyLink[] + */ + public $links = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'Dependencies'; + } + + public function read($input) + { + return $this->_read('Dependencies', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('Dependencies', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/DependencyClient.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/DependencyClient.php new file mode 100644 index 000000000..2c247633d --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/DependencyClient.php @@ -0,0 +1,105 @@ +input_ = $input; + $this->output_ = $output ? $output : $input; + } + + public function getDependenciesForTrace($traceId) + { + $this->send_getDependenciesForTrace($traceId); + return $this->recv_getDependenciesForTrace(); + } + + public function send_getDependenciesForTrace($traceId) + { + $args = new \Jaeger\Thrift\Agent\Dependency_getDependenciesForTrace_args(); + $args->traceId = $traceId; + $bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary'); + if ($bin_accel) + { + thrift_protocol_write_binary($this->output_, 'getDependenciesForTrace', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite()); + } + else + { + $this->output_->writeMessageBegin('getDependenciesForTrace', TMessageType::CALL, $this->seqid_); + $args->write($this->output_); + $this->output_->writeMessageEnd(); + $this->output_->getTransport()->flush(); + } + } + + public function recv_getDependenciesForTrace() + { + $bin_accel = ($this->input_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_read_binary'); + if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, '\Jaeger\Thrift\Agent\Dependency_getDependenciesForTrace_result', $this->input_->isStrictRead()); + else + { + $rseqid = 0; + $fname = null; + $mtype = 0; + + $this->input_->readMessageBegin($fname, $mtype, $rseqid); + if ($mtype == TMessageType::EXCEPTION) { + $x = new TApplicationException(); + $x->read($this->input_); + $this->input_->readMessageEnd(); + throw $x; + } + $result = new \Jaeger\Thrift\Agent\Dependency_getDependenciesForTrace_result(); + $result->read($this->input_); + $this->input_->readMessageEnd(); + } + if ($result->success !== null) { + return $result->success; + } + throw new \Exception("getDependenciesForTrace failed: unknown result"); + } + + public function saveDependencies(\Jaeger\Thrift\Agent\Dependencies $dependencies) + { + $this->send_saveDependencies($dependencies); + } + + public function send_saveDependencies(\Jaeger\Thrift\Agent\Dependencies $dependencies) + { + $args = new \Jaeger\Thrift\Agent\Dependency_saveDependencies_args(); + $args->dependencies = $dependencies; + $bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary'); + if ($bin_accel) + { + thrift_protocol_write_binary($this->output_, 'saveDependencies', TMessageType::ONEWAY, $args, $this->seqid_, $this->output_->isStrictWrite()); + } + else + { + $this->output_->writeMessageBegin('saveDependencies', TMessageType::ONEWAY, $this->seqid_); + $args->write($this->output_); + $this->output_->writeMessageEnd(); + $this->output_->getTransport()->flush(); + } + } +} + + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/DependencyIf.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/DependencyIf.php new file mode 100644 index 000000000..c9432e7d8 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/DependencyIf.php @@ -0,0 +1,31 @@ + array( + 'var' => 'parent', + 'isRequired' => true, + 'type' => TType::STRING, + ), + 2 => array( + 'var' => 'child', + 'isRequired' => true, + 'type' => TType::STRING, + ), + 4 => array( + 'var' => 'callCount', + 'isRequired' => true, + 'type' => TType::I64, + ), + ); + + /** + * @var string + */ + public $parent = null; + /** + * @var string + */ + public $child = null; + /** + * @var int + */ + public $callCount = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'DependencyLink'; + } + + public function read($input) + { + return $this->_read('DependencyLink', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('DependencyLink', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Dependency_getDependenciesForTrace_args.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Dependency_getDependenciesForTrace_args.php new file mode 100644 index 000000000..5100ea77b --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Dependency_getDependenciesForTrace_args.php @@ -0,0 +1,55 @@ + array( + 'var' => 'traceId', + 'isRequired' => true, + 'type' => TType::STRING, + ), + ); + + /** + * @var string + */ + public $traceId = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'Dependency_getDependenciesForTrace_args'; + } + + public function read($input) + { + return $this->_read('Dependency_getDependenciesForTrace_args', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('Dependency_getDependenciesForTrace_args', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Dependency_getDependenciesForTrace_result.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Dependency_getDependenciesForTrace_result.php new file mode 100644 index 000000000..ebdd1303e --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Dependency_getDependenciesForTrace_result.php @@ -0,0 +1,56 @@ + array( + 'var' => 'success', + 'isRequired' => false, + 'type' => TType::STRUCT, + 'class' => '\Jaeger\Thrift\Agent\Dependencies', + ), + ); + + /** + * @var \Jaeger\Thrift\Agent\Dependencies + */ + public $success = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'Dependency_getDependenciesForTrace_result'; + } + + public function read($input) + { + return $this->_read('Dependency_getDependenciesForTrace_result', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('Dependency_getDependenciesForTrace_result', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Dependency_saveDependencies_args.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Dependency_saveDependencies_args.php new file mode 100644 index 000000000..0d250c297 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Dependency_saveDependencies_args.php @@ -0,0 +1,56 @@ + array( + 'var' => 'dependencies', + 'isRequired' => false, + 'type' => TType::STRUCT, + 'class' => '\Jaeger\Thrift\Agent\Dependencies', + ), + ); + + /** + * @var \Jaeger\Thrift\Agent\Dependencies + */ + public $dependencies = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'Dependency_saveDependencies_args'; + } + + public function read($input) + { + return $this->_read('Dependency_saveDependencies_args', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('Dependency_saveDependencies_args', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/OperationSamplingStrategy.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/OperationSamplingStrategy.php new file mode 100644 index 000000000..7532a7b50 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/OperationSamplingStrategy.php @@ -0,0 +1,66 @@ + array( + 'var' => 'operation', + 'isRequired' => true, + 'type' => TType::STRING, + ), + 2 => array( + 'var' => 'probabilisticSampling', + 'isRequired' => true, + 'type' => TType::STRUCT, + 'class' => '\Jaeger\Thrift\Agent\ProbabilisticSamplingStrategy', + ), + ); + + /** + * @var string + */ + public $operation = null; + /** + * @var \Jaeger\Thrift\Agent\ProbabilisticSamplingStrategy + */ + public $probabilisticSampling = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'OperationSamplingStrategy'; + } + + public function read($input) + { + return $this->_read('OperationSamplingStrategy', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('OperationSamplingStrategy', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/PerOperationSamplingStrategies.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/PerOperationSamplingStrategies.php new file mode 100644 index 000000000..2a6ae8a61 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/PerOperationSamplingStrategies.php @@ -0,0 +1,88 @@ + array( + 'var' => 'defaultSamplingProbability', + 'isRequired' => true, + 'type' => TType::DOUBLE, + ), + 2 => array( + 'var' => 'defaultLowerBoundTracesPerSecond', + 'isRequired' => true, + 'type' => TType::DOUBLE, + ), + 3 => array( + 'var' => 'perOperationStrategies', + 'isRequired' => true, + 'type' => TType::LST, + 'etype' => TType::STRUCT, + 'elem' => array( + 'type' => TType::STRUCT, + 'class' => '\Jaeger\Thrift\Agent\OperationSamplingStrategy', + ), + ), + 4 => array( + 'var' => 'defaultUpperBoundTracesPerSecond', + 'isRequired' => false, + 'type' => TType::DOUBLE, + ), + ); + + /** + * @var double + */ + public $defaultSamplingProbability = null; + /** + * @var double + */ + public $defaultLowerBoundTracesPerSecond = null; + /** + * @var \Jaeger\Thrift\Agent\OperationSamplingStrategy[] + */ + public $perOperationStrategies = null; + /** + * @var double + */ + public $defaultUpperBoundTracesPerSecond = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'PerOperationSamplingStrategies'; + } + + public function read($input) + { + return $this->_read('PerOperationSamplingStrategies', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('PerOperationSamplingStrategies', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/ProbabilisticSamplingStrategy.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/ProbabilisticSamplingStrategy.php new file mode 100644 index 000000000..708ceb9a4 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/ProbabilisticSamplingStrategy.php @@ -0,0 +1,56 @@ + array( + 'var' => 'samplingRate', + 'isRequired' => true, + 'type' => TType::DOUBLE, + ), + ); + + /** + * @var double + */ + public $samplingRate = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'ProbabilisticSamplingStrategy'; + } + + public function read($input) + { + return $this->_read('ProbabilisticSamplingStrategy', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('ProbabilisticSamplingStrategy', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/RateLimitingSamplingStrategy.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/RateLimitingSamplingStrategy.php new file mode 100644 index 000000000..d5502e8ee --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/RateLimitingSamplingStrategy.php @@ -0,0 +1,56 @@ + array( + 'var' => 'maxTracesPerSecond', + 'isRequired' => true, + 'type' => TType::I16, + ), + ); + + /** + * @var int + */ + public $maxTracesPerSecond = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'RateLimitingSamplingStrategy'; + } + + public function read($input) + { + return $this->_read('RateLimitingSamplingStrategy', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('RateLimitingSamplingStrategy', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/SamplingManagerClient.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/SamplingManagerClient.php new file mode 100644 index 000000000..9f5494a91 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/SamplingManagerClient.php @@ -0,0 +1,83 @@ +input_ = $input; + $this->output_ = $output ? $output : $input; + } + + public function getSamplingStrategy($serviceName) + { + $this->send_getSamplingStrategy($serviceName); + return $this->recv_getSamplingStrategy(); + } + + public function send_getSamplingStrategy($serviceName) + { + $args = new \Jaeger\Thrift\Agent\SamplingManager_getSamplingStrategy_args(); + $args->serviceName = $serviceName; + $bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary'); + if ($bin_accel) + { + thrift_protocol_write_binary($this->output_, 'getSamplingStrategy', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite()); + } + else + { + $this->output_->writeMessageBegin('getSamplingStrategy', TMessageType::CALL, $this->seqid_); + $args->write($this->output_); + $this->output_->writeMessageEnd(); + $this->output_->getTransport()->flush(); + } + } + + public function recv_getSamplingStrategy() + { + $bin_accel = ($this->input_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_read_binary'); + if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, '\Jaeger\Thrift\Agent\SamplingManager_getSamplingStrategy_result', $this->input_->isStrictRead()); + else + { + $rseqid = 0; + $fname = null; + $mtype = 0; + + $this->input_->readMessageBegin($fname, $mtype, $rseqid); + if ($mtype == TMessageType::EXCEPTION) { + $x = new TApplicationException(); + $x->read($this->input_); + $this->input_->readMessageEnd(); + throw $x; + } + $result = new \Jaeger\Thrift\Agent\SamplingManager_getSamplingStrategy_result(); + $result->read($this->input_); + $this->input_->readMessageEnd(); + } + if ($result->success !== null) { + return $result->success; + } + throw new \Exception("getSamplingStrategy failed: unknown result"); + } + +} + + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/SamplingManagerIf.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/SamplingManagerIf.php new file mode 100644 index 000000000..ef17cf308 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/SamplingManagerIf.php @@ -0,0 +1,27 @@ + array( + 'var' => 'serviceName', + 'isRequired' => false, + 'type' => TType::STRING, + ), + ); + + /** + * @var string + */ + public $serviceName = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'SamplingManager_getSamplingStrategy_args'; + } + + public function read($input) + { + return $this->_read('SamplingManager_getSamplingStrategy_args', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('SamplingManager_getSamplingStrategy_args', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/SamplingManager_getSamplingStrategy_result.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/SamplingManager_getSamplingStrategy_result.php new file mode 100644 index 000000000..79e6dce58 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/SamplingManager_getSamplingStrategy_result.php @@ -0,0 +1,56 @@ + array( + 'var' => 'success', + 'isRequired' => false, + 'type' => TType::STRUCT, + 'class' => '\Jaeger\Thrift\Agent\SamplingStrategyResponse', + ), + ); + + /** + * @var \Jaeger\Thrift\Agent\SamplingStrategyResponse + */ + public $success = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'SamplingManager_getSamplingStrategy_result'; + } + + public function read($input) + { + return $this->_read('SamplingManager_getSamplingStrategy_result', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('SamplingManager_getSamplingStrategy_result', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/SamplingStrategyResponse.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/SamplingStrategyResponse.php new file mode 100644 index 000000000..bc807a57d --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/SamplingStrategyResponse.php @@ -0,0 +1,86 @@ + array( + 'var' => 'strategyType', + 'isRequired' => true, + 'type' => TType::I32, + ), + 2 => array( + 'var' => 'probabilisticSampling', + 'isRequired' => false, + 'type' => TType::STRUCT, + 'class' => '\Jaeger\Thrift\Agent\ProbabilisticSamplingStrategy', + ), + 3 => array( + 'var' => 'rateLimitingSampling', + 'isRequired' => false, + 'type' => TType::STRUCT, + 'class' => '\Jaeger\Thrift\Agent\RateLimitingSamplingStrategy', + ), + 4 => array( + 'var' => 'operationSampling', + 'isRequired' => false, + 'type' => TType::STRUCT, + 'class' => '\Jaeger\Thrift\Agent\PerOperationSamplingStrategies', + ), + ); + + /** + * @var int + */ + public $strategyType = null; + /** + * @var \Jaeger\Thrift\Agent\ProbabilisticSamplingStrategy + */ + public $probabilisticSampling = null; + /** + * @var \Jaeger\Thrift\Agent\RateLimitingSamplingStrategy + */ + public $rateLimitingSampling = null; + /** + * @var \Jaeger\Thrift\Agent\PerOperationSamplingStrategies + */ + public $operationSampling = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'SamplingStrategyResponse'; + } + + public function read($input) + { + return $this->_read('SamplingStrategyResponse', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('SamplingStrategyResponse', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/SamplingStrategyType.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/SamplingStrategyType.php new file mode 100644 index 000000000..c8dff918a --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/SamplingStrategyType.php @@ -0,0 +1,28 @@ + 'PROBABILISTIC', + 1 => 'RATE_LIMITING', + ); +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/ValidateTraceResponse.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/ValidateTraceResponse.php new file mode 100644 index 000000000..226f61e80 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/ValidateTraceResponse.php @@ -0,0 +1,65 @@ + array( + 'var' => 'ok', + 'isRequired' => true, + 'type' => TType::BOOL, + ), + 2 => array( + 'var' => 'traceCount', + 'isRequired' => true, + 'type' => TType::I64, + ), + ); + + /** + * @var bool + */ + public $ok = null; + /** + * @var int + */ + public $traceCount = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'ValidateTraceResponse'; + } + + public function read($input) + { + return $this->_read('ValidateTraceResponse', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('ValidateTraceResponse', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Zipkin/Annotation.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Zipkin/Annotation.php new file mode 100644 index 000000000..e7e48dade --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Zipkin/Annotation.php @@ -0,0 +1,87 @@ + array( + 'var' => 'timestamp', + 'isRequired' => false, + 'type' => TType::I64, + ), + 2 => array( + 'var' => 'value', + 'isRequired' => false, + 'type' => TType::STRING, + ), + 3 => array( + 'var' => 'host', + 'isRequired' => false, + 'type' => TType::STRUCT, + 'class' => '\Jaeger\Thrift\Agent\Zipkin\Endpoint', + ), + ); + + /** + * Microseconds from epoch. + * + * This value should use the most precise value possible. For example, + * gettimeofday or syncing nanoTime against a tick of currentTimeMillis. + * + * @var int + */ + public $timestamp = null; + /** + * @var string + */ + public $value = null; + /** + * Always the host that recorded the event. By specifying the host you allow + * rollup of all events (such as client requests to a service) by IP address. + * + * @var \Jaeger\Thrift\Agent\Zipkin\Endpoint + */ + public $host = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'Annotation'; + } + + public function read($input) + { + return $this->_read('Annotation', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('Annotation', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Zipkin/AnnotationType.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Zipkin/AnnotationType.php new file mode 100644 index 000000000..e21c0b0d8 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Zipkin/AnnotationType.php @@ -0,0 +1,38 @@ + 'BOOL', + 1 => 'BYTES', + 2 => 'I16', + 3 => 'I32', + 4 => 'I64', + 5 => 'DOUBLE', + 6 => 'STRING', + ); +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Zipkin/BinaryAnnotation.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Zipkin/BinaryAnnotation.php new file mode 100644 index 000000000..806a74831 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Zipkin/BinaryAnnotation.php @@ -0,0 +1,106 @@ + array( + 'var' => 'key', + 'isRequired' => false, + 'type' => TType::STRING, + ), + 2 => array( + 'var' => 'value', + 'isRequired' => false, + 'type' => TType::STRING, + ), + 3 => array( + 'var' => 'annotation_type', + 'isRequired' => false, + 'type' => TType::I32, + ), + 4 => array( + 'var' => 'host', + 'isRequired' => false, + 'type' => TType::STRUCT, + 'class' => '\Jaeger\Thrift\Agent\Zipkin\Endpoint', + ), + ); + + /** + * @var string + */ + public $key = null; + /** + * @var string + */ + public $value = null; + /** + * @var int + */ + public $annotation_type = null; + /** + * The host that recorded tag, which allows you to differentiate between + * multiple tags with the same key. There are two exceptions to this. + * + * When the key is CLIENT_ADDR or SERVER_ADDR, host indicates the source or + * destination of an RPC. This exception allows zipkin to display network + * context of uninstrumented services, or clients such as web browsers. + * + * @var \Jaeger\Thrift\Agent\Zipkin\Endpoint + */ + public $host = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'BinaryAnnotation'; + } + + public function read($input) + { + return $this->_read('BinaryAnnotation', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('BinaryAnnotation', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Zipkin/Constant.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Zipkin/Constant.php new file mode 100644 index 000000000..ebfcebe48 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Zipkin/Constant.php @@ -0,0 +1,246 @@ + array( + 'var' => 'ipv4', + 'isRequired' => false, + 'type' => TType::I32, + ), + 2 => array( + 'var' => 'port', + 'isRequired' => false, + 'type' => TType::I16, + ), + 3 => array( + 'var' => 'service_name', + 'isRequired' => false, + 'type' => TType::STRING, + ), + 4 => array( + 'var' => 'ipv6', + 'isRequired' => false, + 'type' => TType::STRING, + ), + ); + + /** + * IPv4 host address packed into 4 bytes. + * + * Ex for the ip 1.2.3.4, it would be (1 << 24) | (2 << 16) | (3 << 8) | 4 + * + * @var int + */ + public $ipv4 = null; + /** + * IPv4 port + * + * Note: this is to be treated as an unsigned integer, so watch for negatives. + * + * Conventionally, when the port isn't known, port = 0. + * + * @var int + */ + public $port = null; + /** + * Service name in lowercase, such as "memcache" or "zipkin-web" + * + * Conventionally, when the service name isn't known, service_name = "unknown". + * + * @var string + */ + public $service_name = null; + /** + * IPv6 host address packed into 16 bytes. Ex Inet6Address.getBytes() + * + * @var string + */ + public $ipv6 = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'Endpoint'; + } + + public function read($input) + { + return $this->_read('Endpoint', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('Endpoint', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Zipkin/Response.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Zipkin/Response.php new file mode 100644 index 000000000..88c7f5e5d --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Zipkin/Response.php @@ -0,0 +1,56 @@ + array( + 'var' => 'ok', + 'isRequired' => true, + 'type' => TType::BOOL, + ), + ); + + /** + * @var bool + */ + public $ok = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'Response'; + } + + public function read($input) + { + return $this->_read('Response', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('Response', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Zipkin/Span.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Zipkin/Span.php new file mode 100644 index 000000000..32a69b645 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Zipkin/Span.php @@ -0,0 +1,190 @@ + array( + 'var' => 'trace_id', + 'isRequired' => false, + 'type' => TType::I64, + ), + 3 => array( + 'var' => 'name', + 'isRequired' => false, + 'type' => TType::STRING, + ), + 4 => array( + 'var' => 'id', + 'isRequired' => false, + 'type' => TType::I64, + ), + 5 => array( + 'var' => 'parent_id', + 'isRequired' => false, + 'type' => TType::I64, + ), + 6 => array( + 'var' => 'annotations', + 'isRequired' => false, + 'type' => TType::LST, + 'etype' => TType::STRUCT, + 'elem' => array( + 'type' => TType::STRUCT, + 'class' => '\Jaeger\Thrift\Agent\Zipkin\Annotation', + ), + ), + 8 => array( + 'var' => 'binary_annotations', + 'isRequired' => false, + 'type' => TType::LST, + 'etype' => TType::STRUCT, + 'elem' => array( + 'type' => TType::STRUCT, + 'class' => '\Jaeger\Thrift\Agent\Zipkin\BinaryAnnotation', + ), + ), + 9 => array( + 'var' => 'debug', + 'isRequired' => false, + 'type' => TType::BOOL, + ), + 10 => array( + 'var' => 'timestamp', + 'isRequired' => false, + 'type' => TType::I64, + ), + 11 => array( + 'var' => 'duration', + 'isRequired' => false, + 'type' => TType::I64, + ), + 12 => array( + 'var' => 'trace_id_high', + 'isRequired' => false, + 'type' => TType::I64, + ), + ); + + /** + * @var int + */ + public $trace_id = null; + /** + * Span name in lowercase, rpc method for example + * + * Conventionally, when the span name isn't known, name = "unknown". + * + * @var string + */ + public $name = null; + /** + * @var int + */ + public $id = null; + /** + * @var int + */ + public $parent_id = null; + /** + * @var \Jaeger\Thrift\Agent\Zipkin\Annotation[] + */ + public $annotations = null; + /** + * @var \Jaeger\Thrift\Agent\Zipkin\BinaryAnnotation[] + */ + public $binary_annotations = null; + /** + * @var bool + */ + public $debug = false; + /** + * Microseconds from epoch of the creation of this span. + * + * This value should be set directly by instrumentation, using the most + * precise value possible. For example, gettimeofday or syncing nanoTime + * against a tick of currentTimeMillis. + * + * For compatibilty with instrumentation that precede this field, collectors + * or span stores can derive this via Annotation.timestamp. + * For example, SERVER_RECV.timestamp or CLIENT_SEND.timestamp. + * + * This field is optional for compatibility with old data: first-party span + * stores are expected to support this at time of introduction. + * + * @var int + */ + public $timestamp = null; + /** + * Measurement of duration in microseconds, used to support queries. + * + * This value should be set directly, where possible. Doing so encourages + * precise measurement decoupled from problems of clocks, such as skew or NTP + * updates causing time to move backwards. + * + * For compatibilty with instrumentation that precede this field, collectors + * or span stores can derive this by subtracting Annotation.timestamp. + * For example, SERVER_SEND.timestamp - SERVER_RECV.timestamp. + * + * If this field is persisted as unset, zipkin will continue to work, except + * duration query support will be implementation-specific. Similarly, setting + * this field non-atomically is implementation-specific. + * + * This field is i64 vs i32 to support spans longer than 35 minutes. + * + * @var int + */ + public $duration = null; + /** + * Optional unique 8-byte additional identifier for a trace. If non zero, this + * means the trace uses 128 bit traceIds instead of 64 bit. + * + * @var int + */ + public $trace_id_high = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'Span'; + } + + public function read($input) + { + return $this->_read('Span', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('Span', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Zipkin/ZipkinCollectorClient.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Zipkin/ZipkinCollectorClient.php new file mode 100644 index 000000000..2978675c4 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Zipkin/ZipkinCollectorClient.php @@ -0,0 +1,83 @@ +input_ = $input; + $this->output_ = $output ? $output : $input; + } + + public function submitZipkinBatch(array $spans) + { + $this->send_submitZipkinBatch($spans); + return $this->recv_submitZipkinBatch(); + } + + public function send_submitZipkinBatch(array $spans) + { + $args = new \Jaeger\Thrift\Agent\Zipkin\ZipkinCollector_submitZipkinBatch_args(); + $args->spans = $spans; + $bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary'); + if ($bin_accel) + { + thrift_protocol_write_binary($this->output_, 'submitZipkinBatch', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite()); + } + else + { + $this->output_->writeMessageBegin('submitZipkinBatch', TMessageType::CALL, $this->seqid_); + $args->write($this->output_); + $this->output_->writeMessageEnd(); + $this->output_->getTransport()->flush(); + } + } + + public function recv_submitZipkinBatch() + { + $bin_accel = ($this->input_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_read_binary'); + if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, '\Jaeger\Thrift\Agent\Zipkin\ZipkinCollector_submitZipkinBatch_result', $this->input_->isStrictRead()); + else + { + $rseqid = 0; + $fname = null; + $mtype = 0; + + $this->input_->readMessageBegin($fname, $mtype, $rseqid); + if ($mtype == TMessageType::EXCEPTION) { + $x = new TApplicationException(); + $x->read($this->input_); + $this->input_->readMessageEnd(); + throw $x; + } + $result = new \Jaeger\Thrift\Agent\Zipkin\ZipkinCollector_submitZipkinBatch_result(); + $result->read($this->input_); + $this->input_->readMessageEnd(); + } + if ($result->success !== null) { + return $result->success; + } + throw new \Exception("submitZipkinBatch failed: unknown result"); + } + +} + + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Zipkin/ZipkinCollectorIf.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Zipkin/ZipkinCollectorIf.php new file mode 100644 index 000000000..83abf8119 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Zipkin/ZipkinCollectorIf.php @@ -0,0 +1,27 @@ + array( + 'var' => 'spans', + 'isRequired' => false, + 'type' => TType::LST, + 'etype' => TType::STRUCT, + 'elem' => array( + 'type' => TType::STRUCT, + 'class' => '\Jaeger\Thrift\Agent\Zipkin\Span', + ), + ), + ); + + /** + * @var \Jaeger\Thrift\Agent\Zipkin\Span[] + */ + public $spans = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'ZipkinCollector_submitZipkinBatch_args'; + } + + public function read($input) + { + return $this->_read('ZipkinCollector_submitZipkinBatch_args', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('ZipkinCollector_submitZipkinBatch_args', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Zipkin/ZipkinCollector_submitZipkinBatch_result.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Zipkin/ZipkinCollector_submitZipkinBatch_result.php new file mode 100644 index 000000000..faf165446 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Agent/Zipkin/ZipkinCollector_submitZipkinBatch_result.php @@ -0,0 +1,60 @@ + array( + 'var' => 'success', + 'isRequired' => false, + 'type' => TType::LST, + 'etype' => TType::STRUCT, + 'elem' => array( + 'type' => TType::STRUCT, + 'class' => '\Jaeger\Thrift\Agent\Zipkin\Response', + ), + ), + ); + + /** + * @var \Jaeger\Thrift\Agent\Zipkin\Response[] + */ + public $success = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'ZipkinCollector_submitZipkinBatch_result'; + } + + public function read($input) + { + return $this->_read('ZipkinCollector_submitZipkinBatch_result', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('ZipkinCollector_submitZipkinBatch_result', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Batch.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Batch.php new file mode 100644 index 000000000..56e9e5206 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Batch.php @@ -0,0 +1,71 @@ + array( + 'var' => 'process', + 'isRequired' => true, + 'type' => TType::STRUCT, + 'class' => '\Jaeger\Thrift\Process', + ), + 2 => array( + 'var' => 'spans', + 'isRequired' => true, + 'type' => TType::LST, + 'etype' => TType::STRUCT, + 'elem' => array( + 'type' => TType::STRUCT, + 'class' => '\Jaeger\Thrift\Span', + ), + ), + ); + + /** + * @var \Jaeger\Thrift\Process + */ + public $process = null; + /** + * @var \Jaeger\Thrift\Span[] + */ + public $spans = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'Batch'; + } + + public function read($input) + { + return $this->_read('Batch', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('Batch', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/BatchSubmitResponse.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/BatchSubmitResponse.php new file mode 100644 index 000000000..7ddc25eb5 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/BatchSubmitResponse.php @@ -0,0 +1,56 @@ + array( + 'var' => 'ok', + 'isRequired' => true, + 'type' => TType::BOOL, + ), + ); + + /** + * @var bool + */ + public $ok = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'BatchSubmitResponse'; + } + + public function read($input) + { + return $this->_read('BatchSubmitResponse', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('BatchSubmitResponse', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/CollectorClient.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/CollectorClient.php new file mode 100644 index 000000000..e3c6e14c1 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/CollectorClient.php @@ -0,0 +1,83 @@ +input_ = $input; + $this->output_ = $output ? $output : $input; + } + + public function submitBatches(array $batches) + { + $this->send_submitBatches($batches); + return $this->recv_submitBatches(); + } + + public function send_submitBatches(array $batches) + { + $args = new \Jaeger\Thrift\Collector_submitBatches_args(); + $args->batches = $batches; + $bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary'); + if ($bin_accel) + { + thrift_protocol_write_binary($this->output_, 'submitBatches', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite()); + } + else + { + $this->output_->writeMessageBegin('submitBatches', TMessageType::CALL, $this->seqid_); + $args->write($this->output_); + $this->output_->writeMessageEnd(); + $this->output_->getTransport()->flush(); + } + } + + public function recv_submitBatches() + { + $bin_accel = ($this->input_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_read_binary'); + if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, '\Jaeger\Thrift\Collector_submitBatches_result', $this->input_->isStrictRead()); + else + { + $rseqid = 0; + $fname = null; + $mtype = 0; + + $this->input_->readMessageBegin($fname, $mtype, $rseqid); + if ($mtype == TMessageType::EXCEPTION) { + $x = new TApplicationException(); + $x->read($this->input_); + $this->input_->readMessageEnd(); + throw $x; + } + $result = new \Jaeger\Thrift\Collector_submitBatches_result(); + $result->read($this->input_); + $this->input_->readMessageEnd(); + } + if ($result->success !== null) { + return $result->success; + } + throw new \Exception("submitBatches failed: unknown result"); + } + +} + + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/CollectorIf.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/CollectorIf.php new file mode 100644 index 000000000..da4f023ec --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/CollectorIf.php @@ -0,0 +1,27 @@ + array( + 'var' => 'batches', + 'isRequired' => false, + 'type' => TType::LST, + 'etype' => TType::STRUCT, + 'elem' => array( + 'type' => TType::STRUCT, + 'class' => '\Jaeger\Thrift\Batch', + ), + ), + ); + + /** + * @var \Jaeger\Thrift\Batch[] + */ + public $batches = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'Collector_submitBatches_args'; + } + + public function read($input) + { + return $this->_read('Collector_submitBatches_args', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('Collector_submitBatches_args', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Collector_submitBatches_result.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Collector_submitBatches_result.php new file mode 100644 index 000000000..aae083707 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Collector_submitBatches_result.php @@ -0,0 +1,60 @@ + array( + 'var' => 'success', + 'isRequired' => false, + 'type' => TType::LST, + 'etype' => TType::STRUCT, + 'elem' => array( + 'type' => TType::STRUCT, + 'class' => '\Jaeger\Thrift\BatchSubmitResponse', + ), + ), + ); + + /** + * @var \Jaeger\Thrift\BatchSubmitResponse[] + */ + public $success = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'Collector_submitBatches_result'; + } + + public function read($input) + { + return $this->_read('Collector_submitBatches_result', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('Collector_submitBatches_result', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/Downstream.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/Downstream.php new file mode 100644 index 000000000..92b269aa6 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/Downstream.php @@ -0,0 +1,102 @@ + array( + 'var' => 'serviceName', + 'isRequired' => true, + 'type' => TType::STRING, + ), + 2 => array( + 'var' => 'serverRole', + 'isRequired' => true, + 'type' => TType::STRING, + ), + 3 => array( + 'var' => 'host', + 'isRequired' => true, + 'type' => TType::STRING, + ), + 4 => array( + 'var' => 'port', + 'isRequired' => true, + 'type' => TType::STRING, + ), + 5 => array( + 'var' => 'transport', + 'isRequired' => true, + 'type' => TType::I32, + ), + 6 => array( + 'var' => 'downstream', + 'isRequired' => false, + 'type' => TType::STRUCT, + 'class' => '\Jaeger\Thrift\Crossdock\Downstream', + ), + ); + + /** + * @var string + */ + public $serviceName = null; + /** + * @var string + */ + public $serverRole = null; + /** + * @var string + */ + public $host = null; + /** + * @var string + */ + public $port = null; + /** + * @var int + */ + public $transport = null; + /** + * @var \Jaeger\Thrift\Crossdock\Downstream + */ + public $downstream = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'Downstream'; + } + + public function read($input) + { + return $this->_read('Downstream', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('Downstream', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/JoinTraceRequest.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/JoinTraceRequest.php new file mode 100644 index 000000000..39e6242b7 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/JoinTraceRequest.php @@ -0,0 +1,66 @@ + array( + 'var' => 'serverRole', + 'isRequired' => true, + 'type' => TType::STRING, + ), + 2 => array( + 'var' => 'downstream', + 'isRequired' => false, + 'type' => TType::STRUCT, + 'class' => '\Jaeger\Thrift\Crossdock\Downstream', + ), + ); + + /** + * @var string + */ + public $serverRole = null; + /** + * @var \Jaeger\Thrift\Crossdock\Downstream + */ + public $downstream = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'JoinTraceRequest'; + } + + public function read($input) + { + return $this->_read('JoinTraceRequest', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('JoinTraceRequest', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/ObservedSpan.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/ObservedSpan.php new file mode 100644 index 000000000..d60331851 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/ObservedSpan.php @@ -0,0 +1,74 @@ + array( + 'var' => 'traceId', + 'isRequired' => true, + 'type' => TType::STRING, + ), + 2 => array( + 'var' => 'sampled', + 'isRequired' => true, + 'type' => TType::BOOL, + ), + 3 => array( + 'var' => 'baggage', + 'isRequired' => true, + 'type' => TType::STRING, + ), + ); + + /** + * @var string + */ + public $traceId = null; + /** + * @var bool + */ + public $sampled = null; + /** + * @var string + */ + public $baggage = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'ObservedSpan'; + } + + public function read($input) + { + return $this->_read('ObservedSpan', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('ObservedSpan', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/StartTraceRequest.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/StartTraceRequest.php new file mode 100644 index 000000000..50b9c6668 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/StartTraceRequest.php @@ -0,0 +1,84 @@ + array( + 'var' => 'serverRole', + 'isRequired' => true, + 'type' => TType::STRING, + ), + 2 => array( + 'var' => 'sampled', + 'isRequired' => true, + 'type' => TType::BOOL, + ), + 3 => array( + 'var' => 'baggage', + 'isRequired' => true, + 'type' => TType::STRING, + ), + 4 => array( + 'var' => 'downstream', + 'isRequired' => true, + 'type' => TType::STRUCT, + 'class' => '\Jaeger\Thrift\Crossdock\Downstream', + ), + ); + + /** + * @var string + */ + public $serverRole = null; + /** + * @var bool + */ + public $sampled = null; + /** + * @var string + */ + public $baggage = null; + /** + * @var \Jaeger\Thrift\Crossdock\Downstream + */ + public $downstream = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'StartTraceRequest'; + } + + public function read($input) + { + return $this->_read('StartTraceRequest', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('StartTraceRequest', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/TraceResponse.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/TraceResponse.php new file mode 100644 index 000000000..107d4e26d --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/TraceResponse.php @@ -0,0 +1,82 @@ + array( + 'var' => 'span', + 'isRequired' => false, + 'type' => TType::STRUCT, + 'class' => '\Jaeger\Thrift\Crossdock\ObservedSpan', + ), + 2 => array( + 'var' => 'downstream', + 'isRequired' => false, + 'type' => TType::STRUCT, + 'class' => '\Jaeger\Thrift\Crossdock\TraceResponse', + ), + 3 => array( + 'var' => 'notImplementedError', + 'isRequired' => true, + 'type' => TType::STRING, + ), + ); + + /** + * @var \Jaeger\Thrift\Crossdock\ObservedSpan + */ + public $span = null; + /** + * @var \Jaeger\Thrift\Crossdock\TraceResponse + */ + public $downstream = null; + /** + * @var string + */ + public $notImplementedError = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'TraceResponse'; + } + + public function read($input) + { + return $this->_read('TraceResponse', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('TraceResponse', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/TracedServiceClient.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/TracedServiceClient.php new file mode 100644 index 000000000..2fd8b4fc9 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/TracedServiceClient.php @@ -0,0 +1,134 @@ +input_ = $input; + $this->output_ = $output ? $output : $input; + } + + public function startTrace(\Jaeger\Thrift\Crossdock\StartTraceRequest $request) + { + $this->send_startTrace($request); + return $this->recv_startTrace(); + } + + public function send_startTrace(\Jaeger\Thrift\Crossdock\StartTraceRequest $request) + { + $args = new \Jaeger\Thrift\Crossdock\TracedService_startTrace_args(); + $args->request = $request; + $bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary'); + if ($bin_accel) + { + thrift_protocol_write_binary($this->output_, 'startTrace', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite()); + } + else + { + $this->output_->writeMessageBegin('startTrace', TMessageType::CALL, $this->seqid_); + $args->write($this->output_); + $this->output_->writeMessageEnd(); + $this->output_->getTransport()->flush(); + } + } + + public function recv_startTrace() + { + $bin_accel = ($this->input_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_read_binary'); + if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, '\Jaeger\Thrift\Crossdock\TracedService_startTrace_result', $this->input_->isStrictRead()); + else + { + $rseqid = 0; + $fname = null; + $mtype = 0; + + $this->input_->readMessageBegin($fname, $mtype, $rseqid); + if ($mtype == TMessageType::EXCEPTION) { + $x = new TApplicationException(); + $x->read($this->input_); + $this->input_->readMessageEnd(); + throw $x; + } + $result = new \Jaeger\Thrift\Crossdock\TracedService_startTrace_result(); + $result->read($this->input_); + $this->input_->readMessageEnd(); + } + if ($result->success !== null) { + return $result->success; + } + throw new \Exception("startTrace failed: unknown result"); + } + + public function joinTrace(\Jaeger\Thrift\Crossdock\JoinTraceRequest $request) + { + $this->send_joinTrace($request); + return $this->recv_joinTrace(); + } + + public function send_joinTrace(\Jaeger\Thrift\Crossdock\JoinTraceRequest $request) + { + $args = new \Jaeger\Thrift\Crossdock\TracedService_joinTrace_args(); + $args->request = $request; + $bin_accel = ($this->output_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_write_binary'); + if ($bin_accel) + { + thrift_protocol_write_binary($this->output_, 'joinTrace', TMessageType::CALL, $args, $this->seqid_, $this->output_->isStrictWrite()); + } + else + { + $this->output_->writeMessageBegin('joinTrace', TMessageType::CALL, $this->seqid_); + $args->write($this->output_); + $this->output_->writeMessageEnd(); + $this->output_->getTransport()->flush(); + } + } + + public function recv_joinTrace() + { + $bin_accel = ($this->input_ instanceof TBinaryProtocolAccelerated) && function_exists('thrift_protocol_read_binary'); + if ($bin_accel) $result = thrift_protocol_read_binary($this->input_, '\Jaeger\Thrift\Crossdock\TracedService_joinTrace_result', $this->input_->isStrictRead()); + else + { + $rseqid = 0; + $fname = null; + $mtype = 0; + + $this->input_->readMessageBegin($fname, $mtype, $rseqid); + if ($mtype == TMessageType::EXCEPTION) { + $x = new TApplicationException(); + $x->read($this->input_); + $this->input_->readMessageEnd(); + throw $x; + } + $result = new \Jaeger\Thrift\Crossdock\TracedService_joinTrace_result(); + $result->read($this->input_); + $this->input_->readMessageEnd(); + } + if ($result->success !== null) { + return $result->success; + } + throw new \Exception("joinTrace failed: unknown result"); + } + +} + + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/TracedServiceIf.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/TracedServiceIf.php new file mode 100644 index 000000000..e2dd9a8eb --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/TracedServiceIf.php @@ -0,0 +1,40 @@ + array( + 'var' => 'request', + 'isRequired' => false, + 'type' => TType::STRUCT, + 'class' => '\Jaeger\Thrift\Crossdock\JoinTraceRequest', + ), + ); + + /** + * @var \Jaeger\Thrift\Crossdock\JoinTraceRequest + */ + public $request = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'TracedService_joinTrace_args'; + } + + public function read($input) + { + return $this->_read('TracedService_joinTrace_args', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('TracedService_joinTrace_args', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/TracedService_joinTrace_result.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/TracedService_joinTrace_result.php new file mode 100644 index 000000000..26ebd7124 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/TracedService_joinTrace_result.php @@ -0,0 +1,56 @@ + array( + 'var' => 'success', + 'isRequired' => false, + 'type' => TType::STRUCT, + 'class' => '\Jaeger\Thrift\Crossdock\TraceResponse', + ), + ); + + /** + * @var \Jaeger\Thrift\Crossdock\TraceResponse + */ + public $success = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'TracedService_joinTrace_result'; + } + + public function read($input) + { + return $this->_read('TracedService_joinTrace_result', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('TracedService_joinTrace_result', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/TracedService_startTrace_args.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/TracedService_startTrace_args.php new file mode 100644 index 000000000..cabc260ea --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/TracedService_startTrace_args.php @@ -0,0 +1,56 @@ + array( + 'var' => 'request', + 'isRequired' => false, + 'type' => TType::STRUCT, + 'class' => '\Jaeger\Thrift\Crossdock\StartTraceRequest', + ), + ); + + /** + * @var \Jaeger\Thrift\Crossdock\StartTraceRequest + */ + public $request = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'TracedService_startTrace_args'; + } + + public function read($input) + { + return $this->_read('TracedService_startTrace_args', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('TracedService_startTrace_args', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/TracedService_startTrace_result.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/TracedService_startTrace_result.php new file mode 100644 index 000000000..f4b114e64 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/TracedService_startTrace_result.php @@ -0,0 +1,56 @@ + array( + 'var' => 'success', + 'isRequired' => false, + 'type' => TType::STRUCT, + 'class' => '\Jaeger\Thrift\Crossdock\TraceResponse', + ), + ); + + /** + * @var \Jaeger\Thrift\Crossdock\TraceResponse + */ + public $success = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'TracedService_startTrace_result'; + } + + public function read($input) + { + return $this->_read('TracedService_startTrace_result', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('TracedService_startTrace_result', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/Transport.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/Transport.php new file mode 100644 index 000000000..1b71e686b --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Crossdock/Transport.php @@ -0,0 +1,30 @@ + 'HTTP', + 1 => 'TCHANNEL', + 2 => 'DUMMY', + ); +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Log.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Log.php new file mode 100644 index 000000000..809a92d7c --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Log.php @@ -0,0 +1,70 @@ + array( + 'var' => 'timestamp', + 'isRequired' => true, + 'type' => TType::I64, + ), + 2 => array( + 'var' => 'fields', + 'isRequired' => true, + 'type' => TType::LST, + 'etype' => TType::STRUCT, + 'elem' => array( + 'type' => TType::STRUCT, + 'class' => '\Jaeger\Thrift\Tag', + ), + ), + ); + + /** + * @var int + */ + public $timestamp = null; + /** + * @var \Jaeger\Thrift\Tag[] + */ + public $fields = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'Log'; + } + + public function read($input) + { + return $this->_read('Log', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('Log', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Process.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Process.php new file mode 100644 index 000000000..3b925220a --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Process.php @@ -0,0 +1,70 @@ + array( + 'var' => 'serviceName', + 'isRequired' => true, + 'type' => TType::STRING, + ), + 2 => array( + 'var' => 'tags', + 'isRequired' => false, + 'type' => TType::LST, + 'etype' => TType::STRUCT, + 'elem' => array( + 'type' => TType::STRUCT, + 'class' => '\Jaeger\Thrift\Tag', + ), + ), + ); + + /** + * @var string + */ + public $serviceName = null; + /** + * @var \Jaeger\Thrift\Tag[] + */ + public $tags = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'Process'; + } + + public function read($input) + { + return $this->_read('Process', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('Process', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Span.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Span.php new file mode 100644 index 000000000..cff0c324d --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Span.php @@ -0,0 +1,161 @@ + array( + 'var' => 'traceIdLow', + 'isRequired' => true, + 'type' => TType::I64, + ), + 2 => array( + 'var' => 'traceIdHigh', + 'isRequired' => true, + 'type' => TType::I64, + ), + 3 => array( + 'var' => 'spanId', + 'isRequired' => true, + 'type' => TType::I64, + ), + 4 => array( + 'var' => 'parentSpanId', + 'isRequired' => true, + 'type' => TType::I64, + ), + 5 => array( + 'var' => 'operationName', + 'isRequired' => true, + 'type' => TType::STRING, + ), + 6 => array( + 'var' => 'references', + 'isRequired' => false, + 'type' => TType::LST, + 'etype' => TType::STRUCT, + 'elem' => array( + 'type' => TType::STRUCT, + 'class' => '\Jaeger\Thrift\SpanRef', + ), + ), + 7 => array( + 'var' => 'flags', + 'isRequired' => true, + 'type' => TType::I32, + ), + 8 => array( + 'var' => 'startTime', + 'isRequired' => true, + 'type' => TType::I64, + ), + 9 => array( + 'var' => 'duration', + 'isRequired' => true, + 'type' => TType::I64, + ), + 10 => array( + 'var' => 'tags', + 'isRequired' => false, + 'type' => TType::LST, + 'etype' => TType::STRUCT, + 'elem' => array( + 'type' => TType::STRUCT, + 'class' => '\Jaeger\Thrift\Tag', + ), + ), + 11 => array( + 'var' => 'logs', + 'isRequired' => false, + 'type' => TType::LST, + 'etype' => TType::STRUCT, + 'elem' => array( + 'type' => TType::STRUCT, + 'class' => '\Jaeger\Thrift\Log', + ), + ), + ); + + /** + * @var int + */ + public $traceIdLow = null; + /** + * @var int + */ + public $traceIdHigh = null; + /** + * @var int + */ + public $spanId = null; + /** + * @var int + */ + public $parentSpanId = null; + /** + * @var string + */ + public $operationName = null; + /** + * @var \Jaeger\Thrift\SpanRef[] + */ + public $references = null; + /** + * @var int + */ + public $flags = null; + /** + * @var int + */ + public $startTime = null; + /** + * @var int + */ + public $duration = null; + /** + * @var \Jaeger\Thrift\Tag[] + */ + public $tags = null; + /** + * @var \Jaeger\Thrift\Log[] + */ + public $logs = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'Span'; + } + + public function read($input) + { + return $this->_read('Span', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('Span', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/SpanRef.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/SpanRef.php new file mode 100644 index 000000000..cb5ee78db --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/SpanRef.php @@ -0,0 +1,83 @@ + array( + 'var' => 'refType', + 'isRequired' => true, + 'type' => TType::I32, + ), + 2 => array( + 'var' => 'traceIdLow', + 'isRequired' => true, + 'type' => TType::I64, + ), + 3 => array( + 'var' => 'traceIdHigh', + 'isRequired' => true, + 'type' => TType::I64, + ), + 4 => array( + 'var' => 'spanId', + 'isRequired' => true, + 'type' => TType::I64, + ), + ); + + /** + * @var int + */ + public $refType = null; + /** + * @var int + */ + public $traceIdLow = null; + /** + * @var int + */ + public $traceIdHigh = null; + /** + * @var int + */ + public $spanId = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'SpanRef'; + } + + public function read($input) + { + return $this->_read('SpanRef', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('SpanRef', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/SpanRefType.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/SpanRefType.php new file mode 100644 index 000000000..d6d6f20c3 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/SpanRefType.php @@ -0,0 +1,28 @@ + 'CHILD_OF', + 1 => 'FOLLOWS_FROM', + ); +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Tag.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Tag.php new file mode 100644 index 000000000..06af59939 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/Tag.php @@ -0,0 +1,110 @@ + array( + 'var' => 'key', + 'isRequired' => true, + 'type' => TType::STRING, + ), + 2 => array( + 'var' => 'vType', + 'isRequired' => true, + 'type' => TType::I32, + ), + 3 => array( + 'var' => 'vStr', + 'isRequired' => false, + 'type' => TType::STRING, + ), + 4 => array( + 'var' => 'vDouble', + 'isRequired' => false, + 'type' => TType::DOUBLE, + ), + 5 => array( + 'var' => 'vBool', + 'isRequired' => false, + 'type' => TType::BOOL, + ), + 6 => array( + 'var' => 'vLong', + 'isRequired' => false, + 'type' => TType::I64, + ), + 7 => array( + 'var' => 'vBinary', + 'isRequired' => false, + 'type' => TType::STRING, + ), + ); + + /** + * @var string + */ + public $key = null; + /** + * @var int + */ + public $vType = null; + /** + * @var string + */ + public $vStr = null; + /** + * @var double + */ + public $vDouble = null; + /** + * @var bool + */ + public $vBool = null; + /** + * @var int + */ + public $vLong = null; + /** + * @var string + */ + public $vBinary = null; + + public function __construct($vals=null) { + if (is_array($vals)) { + parent::__construct(self::$_TSPEC, $vals); + } + } + + public function getName() { + return 'Tag'; + } + + public function read($input) + { + return $this->_read('Tag', self::$_TSPEC, $input); + } + + public function write($output) { + return $this->_write('Tag', self::$_TSPEC, $output); + } + +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/TagType.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/TagType.php new file mode 100644 index 000000000..3b1f69f9f --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Thrift/TagType.php @@ -0,0 +1,34 @@ + 'STRING', + 1 => 'DOUBLE', + 2 => 'BOOL', + 3 => 'LONG', + 4 => 'BINARY', + ); +} + diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/ThriftUdpTransport.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/ThriftUdpTransport.php new file mode 100644 index 000000000..babc689dc --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/ThriftUdpTransport.php @@ -0,0 +1,151 @@ +setLogger($logger); + + $this->config = $config; + + $ipProtocol = $this->ipProtocolVersion(); + $this->socket = $this->createSocket($ipProtocol); + + $this->host = $host; + $this->port = $port; + } + + protected function setLogger($logger) + { + $this->logger = $logger ?? new NullLogger(); + } + + protected function createSocket(string $ipProtocol) + { + $socketDomain = AF_INET; + if ($ipProtocol === Config::IPV6) { + $socketDomain = AF_INET6; + } + + $socket = @socket_create($socketDomain, SOCK_DGRAM, SOL_UDP); + if ($socket === false) { + $this->handleSocketError("socket_create failed"); + } + return $socket; + } + + protected function ipProtocolVersion() + { + if (!empty($this->config)) { + return $this->config->ipProtocolVersion(); + } + return ""; + } + + /** + * Whether this transport is open. + * + * @return boolean true if open + */ + public function isOpen() + { + return $this->socket !== null; + } + + /** + * Open the transport for reading/writing + */ + public function open() + { + $ok = @socket_connect($this->socket, $this->host, $this->port); + if ($ok === false) { + $this->handleSocketError('socket_connect failed'); + } + } + + /** + * Close the transport. + */ + public function close() + { + if (is_null($this->socket)) { + $this->logger->warning("can't close empty socket"); + return ; + } + + @socket_close($this->socket); + $this->socket = null; + } + + /** + * Read some data into the array. + * + * @todo + * + * @param int $len How much to read + * @return string The data that has been read + */ + public function read($len) + { + } + + /** + * Writes the given data out. + * + * @param string $buf The data to write + */ + public function write($buf) + { + if (!$this->isOpen()) { + $this->logger->warning('transport is closed'); + return ; + } + + $ok = @socket_write($this->socket, $buf); + if ($ok === false) { + $this->handleSocketError("socket_write failed"); + } + } + + public function handleSocketError($msg) + { + $errorCode = socket_last_error($this->socket); + $errorMsg = socket_strerror($errorCode); + + $this->logger->warning(sprintf('%s: [code - %d] %s', $msg, $errorCode, $errorMsg)); + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Tracer.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Tracer.php new file mode 100644 index 000000000..bb0649a0b --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Tracer.php @@ -0,0 +1,420 @@ +serviceName = $serviceName; + $this->reporter = $reporter; + $this->sampler = $sampler; + $this->oneSpanPerRpc = $oneSpanPerRpc; + + $this->logger = $logger ?? new NullLogger(); + $this->scopeManager = $scopeManager ?? new ScopeManager(); + + $this->debugIdHeader = $debugIdHeader; + + $this->codecs = [ + TEXT_MAP => new TextCodec( + false, + $traceIdHeader, + $baggageHeaderPrefix, + $debugIdHeader + ), + HTTP_HEADERS => new TextCodec( + true, + $traceIdHeader, + $baggageHeaderPrefix, + $debugIdHeader + ), + BINARY => new BinaryCodec(), + ZIPKIN_SPAN_FORMAT => new ZipkinCodec(), + ]; + + $this->tags = [ + JAEGER_VERSION_TAG_KEY => JAEGER_CLIENT_VERSION, + ]; + if ($tags !== null) { + $this->tags = array_merge($this->tags, $tags); + } + + $hostname = $this->getHostName(); + $this->ipAddress = $this->getHostByName($hostname); + + if (!empty($hostname)) { + $this->tags[JAEGER_HOSTNAME_TAG_KEY] = $hostname; + } + } + + /** + * @return string[] + */ + public function getTags(): array + { + return $this->tags; + } + + /** + * {@inheritdoc} + */ + public function startSpan(string $operationName, $options = []): OTSpan + { + if (!($options instanceof StartSpanOptions)) { + $options = StartSpanOptions::create($options); + } + + $parent = $this->getParentSpanContext($options); + $tags = $options->getTags(); + + $rpcServer = ($tags[SPAN_KIND] ?? null) == SPAN_KIND_RPC_SERVER; + + if ($parent == null || $parent->isDebugIdContainerOnly()) { + $traceId = $this->randomId(); + $spanId = $traceId; + $parentId = null; + $flags = 0; + $baggage = null; + if ($parent == null) { + list($sampled, $samplerTags) = $this->sampler->isSampled($traceId, $operationName); + if ($sampled) { + $flags = SAMPLED_FLAG; + $tags = $tags ?? []; + foreach ($samplerTags as $key => $value) { + $tags[$key] = $value; + } + } + } else { // have debug id + $flags = SAMPLED_FLAG | DEBUG_FLAG; + $tags = $tags ?? []; + $tags[$this->debugIdHeader] = $parent->getDebugId(); + } + } else { + $traceId = $parent->getTraceId(); + if ($rpcServer && $this->oneSpanPerRpc) { + // Zipkin-style one-span-per-RPC + $spanId = $parent->getSpanId(); + $parentId = $parent->getParentId(); + } else { + $spanId = $this->randomId(); + $parentId = $parent->getSpanId(); + } + + $flags = $parent->getFlags(); + $baggage = $parent->getBaggage(); + } + + $spanContext = new SpanContext( + $traceId, + $spanId, + $parentId, + $flags, + $baggage + ); + + $span = new Span( + $spanContext, + $this, + $operationName, + $tags ?? [], + $options->getStartTime() + ); + + $mergedTags = array_merge($this->tags, $tags); + $span->setTags($mergedTags); + + return $span; + } + + /** + * {@inheritdoc} + * + * @param SpanContext $spanContext + * @param string $format + * @param mixed $carrier + * @return void + * + * @throws UnsupportedFormat + */ + public function inject(OTSpanContext $spanContext, string $format, &$carrier): void + { + if ($spanContext instanceof SpanContext) { + $codec = $this->codecs[$format] ?? null; + + if ($codec == null) { + throw UnsupportedFormatException::forFormat(is_scalar($format) ? $format : gettype($format)); + } + + + $codec->inject($spanContext, $carrier); + return; + } + + $message = sprintf( + 'Invalid span context. Expected Jaeger\SpanContext, got %s.', + is_object($spanContext) ? get_class($spanContext) : gettype($spanContext) + ); + + $this->logger->warning($message); + } + + /** + * {@inheritdoc} + * + * @param mixed $carrier + * @return SpanContext|null + * + * @throws UnsupportedFormat + */ + public function extract(string $format, $carrier): ?OTSpanContext + { + $codec = $this->codecs[$format] ?? null; + + if ($codec == null) { + throw UnsupportedFormatException::forFormat(is_scalar($format) ? $format : gettype($format)); + } + + try { + return $codec->extract($carrier); + } catch (\Throwable $e) { + $this->logger->warning($e->getMessage()); + + return null; + } + } + + /** + * {@inheritdoc} + */ + public function flush(): void + { + $this->sampler->close(); + $this->reporter->close(); + } + + public function reportSpan(Span $span) + { + $this->reporter->reportSpan($span); + } + + /** + * {@inheritdoc} + */ + public function getScopeManager(): OTScopeManager + { + return $this->scopeManager; + } + + /** + * {@inheritdoc} + */ + public function getActiveSpan(): ?OTSpan + { + $activeScope = $this->getScopeManager()->getActive(); + if ($activeScope === null) { + return null; + } + + return $activeScope->getSpan(); + } + + /** + * {@inheritdoc} + */ + public function startActiveSpan(string $operationName, $options = []): OTScope + { + if (!$options instanceof StartSpanOptions) { + $options = StartSpanOptions::create($options); + } + + if (!$this->getParentSpanContext($options) && $this->getActiveSpan() !== null) { + $parent = $this->getActiveSpan()->getContext(); + $options = $options->withParent($parent); + } + + $span = $this->startSpan($operationName, $options); + $scope = $this->scopeManager->activate($span, $options->shouldFinishSpanOnClose()); + + return $scope; + } + + /** + * Gets parent span context (if any). + * + * @param StartSpanOptions $options + * @return null|OTSpanContext|SpanContext + */ + private function getParentSpanContext(StartSpanOptions $options) + { + $references = $options->getReferences(); + foreach ($references as $ref) { + if ($ref->isType(Reference::CHILD_OF)) { + return $ref->getSpanContext(); + } + } + + return null; + } + + /** + * @return string + * @throws Exception + */ + private function randomId(): string + { + return (string) random_int(0, PHP_INT_MAX); + } + + /** + * The facade to get the host name. + * + * @return string + */ + protected function getHostName() + { + return gethostname(); + } + + /** + * The facade to get IPv4 address corresponding to a given Internet host name. + * + * NOTE: DNS Resolution may take too long, and during this time your script is NOT being executed. + * + * @param string|null $hostname + * @return string + */ + protected function getHostByName($hostname) + { + if (empty($hostname)) { + $this->logger->error('Unable to determine host name'); + return '127.0.0.1'; + } + + return gethostbyname($hostname); + } + + /** + * @param SamplerInterface $sampler + * @return $this + */ + public function setSampler(SamplerInterface $sampler) + { + $this->sampler = $sampler; + + return $this; + } + + /** + * @return string + */ + public function getServiceName() + { + return $this->serviceName; + } + + /** + * @return string + */ + public function getIpAddress() + { + return $this->ipAddress; + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Util/RateLimiter.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Util/RateLimiter.php new file mode 100644 index 000000000..d767ad40f --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/Util/RateLimiter.php @@ -0,0 +1,128 @@ +cache = $cache; + $this->balance = $this->cache->getItem($currentBalanceKey); + $this->lastTick = $this->cache->getItem($lastTickKey); + } + + /** + * @param $itemCost + * @return bool + */ + public function checkCredit($itemCost) + { + if (!$this->creditsPerNanosecond) { + return false; + } + + list($lastTick, $balance) = $this->getState(); + + if (!$lastTick) { + $this->saveState(hrtime(true), 0); + return true; + } + + $currentTick = hrtime(true); + $elapsedTime = $currentTick - $lastTick; + $balance += $elapsedTime * $this->creditsPerNanosecond; + if ($balance > $this->maxBalance) { + $balance = $this->maxBalance; + } + + $result = false; + if ($balance >= $itemCost) { + $balance -= $itemCost; + $result = true; + } + + $this->saveState($currentTick, $balance); + + return $result; + } + + + /** + * Initializes limiter costs and boundaries + * + * @param float $creditsPerNanosecond + * @param float $maxBalance + */ + public function initialize(float $creditsPerNanosecond, float $maxBalance) + { + $this->creditsPerNanosecond = $creditsPerNanosecond; + $this->maxBalance = $maxBalance; + } + + /** + * Method loads last tick and current balance from cache + * + * @return array [$lastTick, $balance] + */ + private function getState() : array + { + return [ + $this->lastTick->get(), + $this->balance->get() + ]; + } + + /** + * Method saves last tick and current balance into cache + * + * @param integer $lastTick + * @param float $balance + */ + private function saveState($lastTick, $balance) + { + $this->lastTick->set($lastTick); + $this->balance->set($balance); + $this->cache->saveDeferred($this->lastTick); + $this->cache->saveDeferred($this->balance); + $this->cache->commit(); + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Codec/TextCodecTest.php b/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Codec/TextCodecTest.php new file mode 100644 index 000000000..79a1dd96f --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Codec/TextCodecTest.php @@ -0,0 +1,170 @@ +textCodec = new TextCodec(); + } + + public function testCanInjectSimpleContextInCarrier(): void + { + $context = new SpanContext('trace-id', 'span-id', null, null); + $carrier = []; + + $this->textCodec->inject($context, $carrier); + + $this->assertCount(1 , $carrier); + $this->assertArrayHasKey(TRACE_ID_HEADER, $carrier); + } + + /** + * @dataProvider contextDataProvider + * @param bool $urlEncode + * @param $baggage + */ + public function testCanInjectContextBaggageInCarrier(bool $urlEncode, $baggage, $injectedBaggage): void + { + $carrier = []; + + $context = new SpanContext('trace-id', 'span-id', null, null, $baggage); + $textCodec = new TextCodec($urlEncode); + $textCodec->inject($context, $carrier); + + $this->assertCount(1 + count($baggage) , $carrier); + $this->assertArrayHasKey(TRACE_ID_HEADER, $carrier); + foreach ($injectedBaggage as $key => $value) { + $this->assertArrayHasKey(BAGGAGE_HEADER_PREFIX . $key, $carrier); + $this->assertEquals($carrier[BAGGAGE_HEADER_PREFIX . $key], $value); + } + } + + public function contextDataProvider() + { + return [ + [false, ['baggage-1' => 'baggage value'], ['baggage-1' => 'baggage value']], + [false, ['baggage-1' => 'https://testdomain.sk'], ['baggage-1' => 'https://testdomain.sk']], + [true, ['baggage-1' => 'https://testdomain.sk'], ['baggage-1' => 'https%3A%2F%2Ftestdomain.sk']], + ]; + } + + /** + * @dataProvider carrierDataProvider + * @param $urlEncode + * @param $carrier + * @param $traceId + * @param $spanId + * @param $parentId + * @param $flags + * @param $baggage + * @throws \Exception + */ + public function testSpanContextParsingFromHeader($urlEncode, $carrier, $traceId, $spanId, $parentId, $flags, $baggage): void + { + $textCodec = new TextCodec($urlEncode); + $spanContext = $textCodec->extract($carrier); + + $this->assertEquals($traceId, $spanContext->getTraceId()); + $this->assertEquals($spanId, $spanContext->getSpanId()); + $this->assertEquals($parentId, $spanContext->getParentId()); + $this->assertEquals($flags, $spanContext->getFlags()); + $this->assertCount(count($baggage), $spanContext->getBaggage() ? $spanContext->getBaggage() : []); + foreach ($baggage as $key => $value) { + $this->assertEquals($value, $spanContext->getBaggageItem($key)); + } + } + + public function carrierDataProvider(): array + { + return [ + [ + false, + [ + TRACE_ID_HEADER => '32834e4115071776:f7802330248418d:f123456789012345:1' + ], + "3639838965278119798", + "1114643325879075213", + "-1070935975401544891", + 1, + [] + ], + [ + false, + [ + TRACE_ID_HEADER => '32834e4115071776:f7802330248418d:f123456789012345:1', + BAGGAGE_HEADER_PREFIX . 'baggage-1' => 'https://testdomain.sk', + ], + "3639838965278119798", + "1114643325879075213", + "-1070935975401544891", + 1, + ['baggage-1' => 'https://testdomain.sk'] + ], + [ + true, + [ + TRACE_ID_HEADER => '32834e4115071776:f7802330248418d:f123456789012345:1', + BAGGAGE_HEADER_PREFIX . 'baggage-1' => 'https%3A%2F%2Ftestdomain.sk', + ], + "3639838965278119798", + "1114643325879075213", + "-1070935975401544891", + 1, + ['baggage-1' => 'https://testdomain.sk'] + ] + ]; + } + + public function testBaggageWithoutTraceContext(): void + { + $carrier = [BAGGAGE_HEADER_PREFIX.'test' => 'some data']; + + $this->expectException(Exception::class); + $this->expectExceptionMessage('baggage without trace ctx'); + + $this->textCodec->extract($carrier); + } + + public function testInvalidSpanContextParsingFromHeader(): void + { + $carrier = [TRACE_ID_HEADER => 'invalid_data']; + + $this->expectException(Exception::class); + $this->expectExceptionMessage('Malformed tracer state string.'); + + $this->textCodec->extract($carrier); + } + + public function testExtractDebugSpanContext(): void + { + $carrier = [DEBUG_ID_HEADER_KEY => 'debugId']; + + $spanContext = $this->textCodec->extract($carrier); + + $this->assertEquals('debugId', $spanContext->getDebugId()); + $this->assertNull($spanContext->getTraceId()); + $this->assertNull($spanContext->getSpanId()); + $this->assertNull($spanContext->getParentId()); + $this->assertNull($spanContext->getFlags()); + } + + + public function testExtractEmptySpanContext(): void + { + $spanContext = $this->textCodec->extract([]); + $this->assertNull($spanContext); + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Codec/ZipkinCodecTest.php b/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Codec/ZipkinCodecTest.php new file mode 100644 index 000000000..047caac2e --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Codec/ZipkinCodecTest.php @@ -0,0 +1,104 @@ +codec = new ZipkinCodec; + } + + function testInject() + { + // Given + $traceId = 123; + $spanId = 456; + $parentId = 789; + + $spanContext = new SpanContext( + $traceId, + $spanId, + $parentId, + SAMPLED_FLAG + ); + $carrier = []; + + // When + $this->codec->inject($spanContext, $carrier); + + // Then + $this->assertEquals('7b', $carrier['X-B3-TraceId']); + $this->assertEquals('1c8', $carrier['X-B3-SpanId']); + $this->assertEquals('315', $carrier['X-B3-ParentSpanId']); + $this->assertSame(1, $carrier['X-B3-Flags']); + } + + function testExtract() + { + // Given + $carrier = [ + 'x-b3-traceid' => 'a53bf337d7e455e1', + 'x-b3-spanid' => '153bf227d1f455a1', + 'x-b3-parentspanid' => 'a53bf337d7e455e1', + 'x-b3-flags' => '1', + ]; + + // When + $spanContext = $this->codec->extract($carrier); + + // Then + $this->assertEquals(new SpanContext( + '-6540366612654696991', + '1530082751262512545', + '-6540366612654696991', + DEBUG_FLAG + ), $spanContext); + } + + function testExtractWithoutParentSpanId() + { + // Given + $carrier = [ + 'x-b3-traceid' => '8d824d69da5f50d9', + 'x-b3-spanid' => '8d824d69da5f50d9', + 'x-b3-flags' => '1', + ]; + + // When + $spanContext = $this->codec->extract($carrier); + + // Then + $this->assertEquals(new SpanContext( + '-8249946450358742823', + '-8249946450358742823', + '0', + DEBUG_FLAG + ), $spanContext); + } + + function testExtractInvalidHeader() + { + // Given + $carrier = [ + 'x-b3-traceid' => 'zzzz', + 'x-b3-spanid' => '463ac35c9f6413ad48485a3953bb6124', + 'x-b3-flags' => '1', + ]; + + // When + $spanContext = $this->codec->extract($carrier); + + // Then + $this->assertEquals(null, $spanContext); + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/ConfigTest.php b/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/ConfigTest.php new file mode 100644 index 000000000..da1a9781e --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/ConfigTest.php @@ -0,0 +1,257 @@ +config = new Config([], $this->serviceName); + $this->reporter = $this->createMock(ReporterInterface::class); + $this->sampler = $this->createmock(SamplerInterface::class); + } + + function testCreateTracer() + { + $tracer = $this->config->createTracer($this->reporter, $this->sampler); + + $this->assertEquals(Tracer::class, get_class($tracer)); + $this->assertEquals($this->serviceName, $tracer->getServiceName()); + } + + function testThrowExceptionWhenServiceNameIsNotDefined() + { + $this->expectException(Exception::class); + $this->expectExceptionMessage('service_name required in the config or param.'); + + new Config([]); + } + + function testSetServiceNameFromConfig() + { + $config = new Config(['service_name' => 'test-service-name-from-config']); + + $serviceName = $config->getServiceName(); + + $this->assertEquals('test-service-name-from-config', $serviceName); + } + + /** + * @test + */ + public function shouldSetGlobalTracerAfterInitialize() + { + //given + $config = new Config(['service_name' => 'test-service-name']); + + //when + $config->initializeTracer(); + + //then + $tracer = GlobalTracer::get(); + $this->assertInstanceOf(Tracer::class, $tracer); + } + + /** @test */ + public function shouldThrowExceptionWhenCreatingNotSupportedSampler() + { + $config = new Config(['service_name' => 'test-service-name', 'sampler' => ['type' => 'unsupportedSampler']]); + + $this->expectException(Exception::class); + $this->expectExceptionMessage('Unknown sampler type unsupportedSampler'); + + $config->initializeTracer(); + } + + /** @test */ + public function shouldThrowExceptionWhenCreatingRateLimitingSamplerWithoutCacheComponent() + { + $config = new Config([ + 'service_name' => 'test-service-name', + 'sampler' => ['type' => \Jaeger\SAMPLER_TYPE_RATE_LIMITING] + ]); + + $this->expectException(Exception::class); + $this->expectExceptionMessage('You cannot use RateLimitingSampler without cache component'); + + $config->initializeTracer(); + } + + /** @test */ + public function shouldPassDifferentDispatchMode() { + foreach (Config::getAvailableDispatchModes() as $dispatchMode) { + $config = new Config( + [ + 'sampler' => [ + 'type' => SAMPLER_TYPE_CONST, + 'param' => true, + ], + 'logging' => false, + "local_agent" => [ + "reporting_host" => "localhost", + ], + 'dispatch_mode' => $dispatchMode, + ], + 'your-app-name' + ); + $config->initializeTracer(); + $this->expectNotToPerformAssertions(); + } + } + + /** @test */ + public function shouldPassConfiguredTagsToTracer() + { + $tags = [ + 'bar' => 'a-value', + 'other.tag' => 'foo', + ]; + + $config = new Config([ + 'sampler' => [ + 'type' => SAMPLER_TYPE_CONST, + 'param' => true, + ], + 'service_name' => 'test-service-name', + 'tags' => $tags, + ]); + + $tracer = $config->initializeTracer(); + $span = $tracer->startSpan('test-span'); + $spanTags = $span->getTags(); + + foreach ($tags as $name => $value) { + $this->assertArrayHasKey($name, $spanTags, "Tag '$name' should be set on span"); + $this->assertEquals($value, $spanTags[$name]->value, "Tag '$name' should have configured value"); + } + } + + /** + * @test + * @dataProvider shouldSetConfigPropertiesFromEnvVarsProvider + */ + public function shouldSetConfigPropertiesFromEnvVars($varName, $varVal, $initialConfig, $valueGetter, $expectedVal) + { + $_ENV[$varName] = $varVal; + + $config = new Config([]); + $configProperty = (new \ReflectionObject($config))->getProperty('config'); + $configProperty->setAccessible('true'); + $configArray = $configProperty->getValue($config); + + $this->assertSame($expectedVal, $valueGetter($configArray)); + } + + /** + * @test + * @dataProvider shouldSetConfigPropertiesFromEnvVarsProvider + */ + public function shouldNotSetConfigPropertiesFromEnvVars($varName, $varVal, $initialConfig, $valueGetter, $expectedVal) + { + $_ENV[$varName] = $varVal; + + $config = new Config($initialConfig); + $configProperty = (new \ReflectionObject($config))->getProperty('config'); + $configProperty->setAccessible('true'); + $configArray = $configProperty->getValue($config); + + $this->assertNotEquals($expectedVal, $valueGetter($configArray)); + } + + /** + * 0 -> varName + * 1 -> varVal + * 2 -> initialConfig + * 3 -> valueGetter + * 4 -> expectedVal + */ + public function shouldSetConfigPropertiesFromEnvVarsProvider() { + return [ + [ + 'JAEGER_SERVICE_NAME', + 'some-str', + ['service_name' => 'some-other-str'], + function ($a) { return $a['service_name']; }, + 'some-str', + ], + [ + 'JAEGER_TAGS', + 'some-str', + ['tags' => 'some-other-str'], + function ($a) { return $a['tags']; }, + 'some-str', + ], + [ + 'JAEGER_AGENT_HOST', + 'some-str', + ['local_agent' => ['reporting_host' => 'some-other-str']], + function ($a) { return $a['local_agent']['reporting_host'];}, + 'some-str', + ], + [ + 'JAEGER_AGENT_PORT', + '2222', + ['local_agent' => ['reporting_port' => 1111]], + function ($a) { return $a['local_agent']['reporting_port']; }, + 2222, + ], + [ + 'JAEGER_REPORTER_LOG_SPANS', + 'true', + ['logging' => false], + function ($a) { return $a['logging']; }, + true, + ], + [ + 'JAEGER_REPORTER_MAX_QUEUE_SIZE', + '2222', + ['max_buffer_length' => 1111], + function ($a) { return $a['max_buffer_length']; }, + 2222, + ], + [ + 'JAEGER_SAMPLER_TYPE', + 'some-str', + ['sampler' => ['type' => 'some-other-str']], + function ($a) { return $a['sampler']['type']; }, + 'some-str', + ], + [ + 'JAEGER_SAMPLER_PARAM', + 'some-str', + ['sampler' => ['param' => 'some-other-str']], + function ($a) { return $a['sampler']['param']; }, + 'some-str', + ], + ]; + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Logger/StackLogger.php b/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Logger/StackLogger.php new file mode 100644 index 000000000..fd8789dc3 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Logger/StackLogger.php @@ -0,0 +1,30 @@ +messagesStack[] = $message; + } + + public function getLastMessage() { + return array_pop($this->messagesStack); + } + + public function getMessagesCount() { + return count($this->messagesStack); + } + + public function clear() { + $this->messagesStack = []; + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Mapper/SpanToJaegerMapperTest.php b/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Mapper/SpanToJaegerMapperTest.php new file mode 100644 index 000000000..d536cb63a --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Mapper/SpanToJaegerMapperTest.php @@ -0,0 +1,169 @@ +tracer = new Tracer($this->serviceName, new NullReporter, new ConstSampler); + $this->context = new SpanContext(0, 0, 0, SAMPLED_FLAG); + } + + /** + * {@inheritdoc} + */ + protected function tearDown(): void + { + $this->tracer = null; + $this->context = null; + } + + /** @test */ + public function shouldProperlyInitializeAtConstructTime(): void + { + $span = new Span($this->context, $this->tracer, 'test-operation'); + $span->setTags([ + "tag-bool1" => true, + "tag-bool2" => false, + "tag-int" => 1234567, + "tag-float" => 1.23456, + "tag-string" => "hello-world" + ]); + + $mapper = new SpanToJaegerMapper(); + $thriftSpan = $mapper->mapSpanToJaeger($span); + + $index = 0; + $this->assertEquals($thriftSpan->tags[$index]->key, "component"); + $this->assertEquals($thriftSpan->tags[$index]->vType, TagType::STRING); + $this->assertEquals($thriftSpan->tags[$index]->vStr, $this->serviceName); + $index++; + + $this->assertEquals($thriftSpan->tags[$index]->key, "tag-bool1"); + $this->assertEquals($thriftSpan->tags[$index]->vType, TagType::BOOL); + $this->assertEquals($thriftSpan->tags[$index]->vBool, true); + $index++; + + $this->assertEquals($thriftSpan->tags[$index]->key, "tag-bool2"); + $this->assertEquals($thriftSpan->tags[$index]->vType, TagType::BOOL); + $this->assertEquals($thriftSpan->tags[$index]->vBool, false); + $index++; + + $this->assertEquals($thriftSpan->tags[$index]->key, "tag-int"); + $this->assertEquals($thriftSpan->tags[$index]->vType, TagType::LONG); + $this->assertEquals($thriftSpan->tags[$index]->vLong, 1234567); + $index++; + + $this->assertEquals($thriftSpan->tags[$index]->key, "tag-float"); + $this->assertEquals($thriftSpan->tags[$index]->vType, TagType::DOUBLE); + $this->assertEquals($thriftSpan->tags[$index]->vDouble, 1.23456); + $index++; + + $this->assertEquals($thriftSpan->tags[$index]->key, "tag-string"); + $this->assertEquals($thriftSpan->tags[$index]->vType, TagType::STRING); + $this->assertEquals($thriftSpan->tags[$index]->vStr, "hello-world"); + $index++; + } + + /** + * @dataProvider specialTagProvider + * @param array $tags + * @return void + */ + public function testSpecialTagsAreAdded(array $tags): void + { + $span = new Span($this->context, $this->tracer, 'test-operation'); + $span->setTags($tags); + + // The component tag is always added, even if it's not specified in tags + $expectedTagValues = array_merge([COMPONENT => $this->serviceName], $tags); + + $mapper = new SpanToJaegerMapper(); + $thriftSpan = $mapper->mapSpanToJaeger($span); + + $foundTags = []; + + foreach ($thriftSpan->tags as $tag) { + $foundTags[] = $tag->key; + + switch ($tag->key) { + case PEER_SERVICE: + case PEER_HOST_IPV4: + case SPAN_KIND: + case COMPONENT: + $this->assertEquals(TagType::STRING, $tag->vType, 'Incorrect tag value type'); + $this->assertEquals($expectedTagValues[$tag->key], $tag->vStr, 'Incorrect tag value'); + break; + case PEER_PORT: + $this->assertEquals(TagType::LONG, $tag->vType, 'Incorrect tag value type'); + $this->assertEquals($expectedTagValues[$tag->key], $tag->vLong, 'Incorrect tag value'); + break; + } + } + + $this->assertEqualsCanonicalizing(array_keys($expectedTagValues), $foundTags, 'Some of the tags are missing'); + } + + public function specialTagProvider(): array + { + return [ + [ + [ + 'bool_tag' => true, + PEER_SERVICE => 'my_service', + PEER_HOST_IPV4 => '127.0.0.1', + PEER_PORT => 443, + SPAN_KIND => SPAN_KIND_RPC_CLIENT, + COMPONENT => 'grpc', + ], + ], + [ + [ + 'int_tag' => 5, + PEER_HOST_IPV4 => '192.168.0.1', + PEER_PORT => 80, + ], + ], + [ + [ + 'string_tag' => 'testing-tag', + PEER_PORT => 80, + COMPONENT => 'grpc', + ], + ], + [ + [ + 'string_tag' => 'testing-tag', + ], + ], + ]; + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Reporter/CompositeReporterTest.php b/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Reporter/CompositeReporterTest.php new file mode 100644 index 000000000..ef95ebfe7 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Reporter/CompositeReporterTest.php @@ -0,0 +1,52 @@ +childReporter1 = $this->createMock(ReporterInterface::class); + $this->childReporter2 = $this->createMock(ReporterInterface::class); + + $this->reporter = new CompositeReporter($this->childReporter1, $this->childReporter2); + } + + /** @test */ + public function shouldReportSpan() + { + /** @var \Jaeger\Span|\PHPUnit\Framework\MockObject\MockObject $span */ + $span = $this->createMock(Span::class); + + $this->childReporter1->expects($this->once())->method('reportSpan')->with($span); + $this->childReporter2->expects($this->once())->method('reportSpan')->with($span); + + $this->reporter->reportSpan($span); + } + + /** @test */ + public function shouldCloseReporter() + { + $this->childReporter1->expects($this->once())->method('close'); + $this->childReporter2->expects($this->once())->method('close'); + + $this->reporter->close(); + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Reporter/InMemoryReporterTest.php b/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Reporter/InMemoryReporterTest.php new file mode 100644 index 000000000..966a62fa4 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Reporter/InMemoryReporterTest.php @@ -0,0 +1,24 @@ +createMock(Span::class); + $reporter = new InMemoryReporter(); + + $reporter->reportSpan($span); + $reporter->close(); + + $spans = $reporter->getSpans(); + $this->assertEquals([$span], $spans); + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Reporter/LoggingReporterTest.php b/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Reporter/LoggingReporterTest.php new file mode 100644 index 000000000..dc7c490d2 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Reporter/LoggingReporterTest.php @@ -0,0 +1,31 @@ +createMock(NullLogger::class); + $span = $this->createMock(Span::class); + + $reporter = new LoggingReporter($logger); + + $logger->expects($this->once()) + ->method('debug') + ->with($this->stringStartsWith('Reporting span')); + + $reporter->reportSpan($span); + $reporter->close(); + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Reporter/NullReporterTest.php b/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Reporter/NullReporterTest.php new file mode 100644 index 000000000..e6a66cb8a --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Reporter/NullReporterTest.php @@ -0,0 +1,29 @@ +createMock(Span::class); + + $reporter = new NullReporter(); + + $reporter->reportSpan($span); + $reporter->close(); + + // Only needed to avoid PhpUnit message: "This test did not perform any assertions" + $this->assertTrue(true); + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Reporter/RemoteReporterTest.php b/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Reporter/RemoteReporterTest.php new file mode 100644 index 000000000..0b85f06d0 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Reporter/RemoteReporterTest.php @@ -0,0 +1,46 @@ +transport = $this->createMock(UdpSender::class); + $this->reporter = new RemoteReporter($this->transport); + } + + /** @test */ + public function shouldReportSpan() + { + /** @var Span|\PHPUnit\Framework\MockObject\MockObject $span */ + $span = $this->createMock(Span::class); + + $this->transport->expects($this->once())->method('append')->with($span); + + $this->reporter->reportSpan($span); + } + + /** @test */ + public function shouldCloseReporter() + { + $this->transport->expects($this->once())->method('flush'); + $this->transport->expects($this->once())->method('close'); + + $this->reporter->close(); + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Sampler/ConstSamplerTest.php b/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Sampler/ConstSamplerTest.php new file mode 100644 index 000000000..85cb80504 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Sampler/ConstSamplerTest.php @@ -0,0 +1,43 @@ +isSampled($traceId); + + $this->assertEquals($decision, $sampled); + $this->assertEquals([ + SAMPLER_TYPE_TAG_KEY => SAMPLER_TYPE_CONST, + SAMPLER_PARAM_TAG_KEY => $decision, + ], $tags); + + $sampler->close(); + } + + public function samplerProvider() + { + return [ + [true, 1], + [true, PHP_INT_MAX], + [false, 1], + [false, PHP_INT_MAX], + ]; + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Sampler/ProbablisticSamplerTest.php b/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Sampler/ProbablisticSamplerTest.php new file mode 100644 index 000000000..2840ebf8c --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Sampler/ProbablisticSamplerTest.php @@ -0,0 +1,68 @@ +isSampled($traceId); + + $this->assertEquals($decision, $sampled); + $this->assertEquals([ + SAMPLER_TYPE_TAG_KEY => SAMPLER_TYPE_PROBABILISTIC, + SAMPLER_PARAM_TAG_KEY => $rate, + ], $tags); + + $sampler->close(); + } + + public function samplerProvider() + { + return [ + [1.0, PHP_INT_MAX-1, true], + [0, 0, false], + [0.5, PHP_INT_MIN + 10, true], + [0.5, PHP_INT_MAX - 10, false], + ]; + } + + /** + * @test + * @dataProvider rateProvider + * @param mixed $rate + */ + public function shouldThrowOutOfBoundsExceptionInCaseOfInvalidRate($rate) + { + $this->expectException(OutOfBoundsException::class); + $this->expectExceptionMessage('Sampling rate must be between 0.0 and 1.0.'); + + new ProbabilisticSampler($rate); + } + + public function rateProvider() + { + return [ + [1.1], + [-0.1], + [PHP_INT_MAX], + [PHP_INT_MIN], + ]; + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Sampler/RateLimitSamplerTest.php b/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Sampler/RateLimitSamplerTest.php new file mode 100644 index 000000000..4f6b8a632 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Sampler/RateLimitSamplerTest.php @@ -0,0 +1,48 @@ +isSampled(); + list($sampled, $tags) = $sampler->isSampled(); + $this->assertEquals($decision, $sampled); + $this->assertEquals([ + SAMPLER_TYPE_TAG_KEY => SAMPLER_TYPE_RATE_LIMITING, + SAMPLER_PARAM_TAG_KEY => $maxTracesPerSecond, + ], $tags); + + $sampler->close(); + } + + public function maxRateProvider() + { + return [ + [1000000, true], + [1, false], + [0, false], + ]; + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/ScopeManagerTest.php b/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/ScopeManagerTest.php new file mode 100644 index 000000000..43a303642 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/ScopeManagerTest.php @@ -0,0 +1,49 @@ +scopeManager = new ScopeManager(); + } + + function testActivate() + { + $span = $this->createMock(Span::class); + + $scope = $this->scopeManager->activate($span, true); + + $this->assertEquals($scope->getSpan(), $span); + } + + function testAbleGetActiveScope() + { + $span = $this->createMock(Span::class); + + $this->assertNull($this->scopeManager->getActive()); + $scope = $this->scopeManager->activate($span, false); + + $this->assertEquals($scope, $this->scopeManager->getActive()); + } + + function testScopeClosingDeactivates() + { + $span = $this->createMock(Span::class); + + $scope = $this->scopeManager->activate($span, false); + $scope->close(); + + $this->assertNull($this->scopeManager->getActive()); + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/ScopeTest.php b/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/ScopeTest.php new file mode 100644 index 000000000..e36a8de3d --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/ScopeTest.php @@ -0,0 +1,58 @@ +scopeManager = $this->createMock(ScopeManager::class); + $this->span = $this->createMock(Span::class); + } + + function testCloseDoNotFinishSpanOnClose() + { + $scope = new Scope($this->scopeManager, $this->span, false); + + $this->scopeManager->method('getActive')->willReturn($scope); + $this->scopeManager->expects($this->once())->method('getActive'); + $this->span->expects($this->never())->method('finish'); + $this->scopeManager->expects($this->once())->method('setActive'); + + $scope->close(); + } + + function testCloseFinishSpanOnClose() + { + $scope = new Scope($this->scopeManager, $this->span, true); + + $this->scopeManager->method('getActive')->willReturn($scope); + $this->scopeManager->expects($this->once())->method('getActive'); + $this->span->expects($this->once())->method('finish'); + $this->scopeManager->expects($this->once())->method('setActive'); + + $scope->close(); + } + + function testGetSpan() + { + $scope = new Scope($this->scopeManager, $this->span, false); + + $this->assertEquals($this->span, $scope->getSpan()); + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Sender/JaegerThriftSenderTest.php b/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Sender/JaegerThriftSenderTest.php new file mode 100644 index 000000000..5bd6d0a7b --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Sender/JaegerThriftSenderTest.php @@ -0,0 +1,126 @@ +createMock(Tracer::class); + $tracer->method('getIpAddress')->willReturn(''); + $tracer->method('getServiceName')->willReturn(''); + + $this->tracer = $tracer; + + $context = $this->createMock(SpanContext::class); + $this->context = $context; + } + + public function testFlush(): void + { + + $span = $this->createMock(Span::class); + $span->method('getOperationName')->willReturn('dummy-operation'); + $span->method('getTracer')->willReturn($this->tracer); + $span->method('getContext')->willReturn($this->context); + + $client = $this->createMock(AgentClient::class); + $sender = new JaegerSender($client); + $sender->setMaxBufferLength(64000); + + $client + ->expects(self::exactly(1)) + ->method('emitBatch'); + + $sender->append($span); + $sender->append($span); + $sender->append($span); + + self::assertEquals(3, $sender->flush()); + } + + public function testEmitBatch() { + $client = $this->createMock(AgentClient::class); + $sender = new JaegerSender($client); + $sender->setMaxBufferLength(64000); + + $span = $this->createMock(Span::class); + $span->method('getOperationName')->willReturn('dummy-operation'); + $span->method('getTracer')->willReturn($this->tracer); + $span->method('getContext')->willReturn($this->context); + + $client + ->expects($this->once()) + ->method('emitBatch') + ->with($this->callback(function ($batch) { + /** @var Batch $batch */ + $this->assertInstanceOf(Batch::class, $batch); + $this->assertCount(1, $batch->spans); + + /** @var \Jaeger\Thrift\Span $span */ + $span = $batch->spans[0]; + $this->assertInstanceOf(\Jaeger\Thrift\Span::class, $span); + $this->assertSame("dummy-operation", $span->operationName); + + return true; + + })); + + $sender->append($span); + $this->assertEquals(1, $sender->flush()); + } + + public function testMaxBufferLength() { + $tracer = $this->createMock(Tracer::class); + $tracer->method('getIpAddress')->willReturn(''); + $tracer->method('getServiceName')->willReturn(''); + + $context = $this->createMock(SpanContext::class); + + $span = $this->createMock(Span::class); + $span->method('getOperationName')->willReturn('dummy-operation'); + $span->method('getTracer')->willReturn($tracer); + $span->method('getContext')->willReturn($context); + + $client = $this->createMock(AgentClient::class); + + $mockBuilder = $this->getMockBuilder(JaegerSender::class); + $mockMethods = ['emitJaegerBatch']; + if (method_exists($mockBuilder, "onlyMethods")) { + $mockBuilder = $mockBuilder->onlyMethods($mockMethods); + } else { + $mockBuilder = $mockBuilder->setMethods($mockMethods); + } + $sender = $mockBuilder->setConstructorArgs([$client])->getMock(); + $sender->setMaxBufferLength(800); + $sender->expects(self::exactly(2)) + ->method('emitJaegerBatch') + ->withConsecutive( + [self::countOf(2)], + [self::countOf(1)] + ); + + // jaeger batch overhead parameter = 512 + $sender->append($span); // 512 + 143 < 800 - chunk 1 + $sender->append($span); // 512 + 143*2 => 798 < 800 - chunk 1 + $sender->append($span); // 512 + 143*3 > 800 - chunk 2 + + self::assertEquals(3, $sender->flush()); + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Sender/UdpSenderTest.php b/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Sender/UdpSenderTest.php new file mode 100644 index 000000000..9011d00e3 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/Sender/UdpSenderTest.php @@ -0,0 +1,116 @@ +client = $this->createMock(AgentClient::class); + $this->sender = new UdpSender($this->client, 64000); + } + + public function testMaxBufferLength(): void + { + $tracer = $this->createMock(Tracer::class); + $tracer->method('getIpAddress')->willReturn(''); + $tracer->method('getServiceName')->willReturn(''); + + $context = $this->createMock(SpanContext::class); + + $span = $this->createMock(Span::class); + $span->method('getOperationName')->willReturn('dummy-operation'); + $span->method('getTracer')->willReturn($tracer); + $span->method('getContext')->willReturn($context); + + $sender = new UdpSender($this->client, 100); + + $this->client + ->expects(self::exactly(2)) + ->method('emitZipkinBatch') + ->withConsecutive( + [self::countOf(2)], + [self::countOf(1)] + ); + + // one span has a length of ~25 + $sender->append($span); // 30 + 25 < 100 - chunk 1 + $sender->append($span); // 30 + 25 * 2 < 100 - chunk 1 + $sender->append($span); // 30 + 25 * 3 > 100 - chunk 2 + + self::assertEquals(3, $sender->flush()); + } + + public function testFlush(): void + { + $this->assertEquals(0, $this->sender->flush()); + + $logTimeStamp = (int) (microtime(true) * 1000000); + + $tracer = $this->createMock(Tracer::class); + $tracer->method('getIpAddress')->willReturn(''); + $tracer->method('getServiceName')->willReturn(''); + $context = $this->createMock(SpanContext::class); + $span = $this->createMock(Span::class); + $span->method('getTracer')->willReturn($tracer); + $span->method('getContext')->willReturn($context); + $span + ->expects($this->atLeastOnce()) + ->method('getLogs') + ->willReturn([ + [ + 'timestamp' => $logTimeStamp, + 'fields' => [ + 'foo' => 'bar', + ], + ], + ]); + + $this->client + ->expects($this->once()) + ->method('emitZipkinBatch') + ->with($this->callback(function ($spans) use ($logTimeStamp) { + $this->assertCount(1, $spans); + + /* @var $annotation ZipkinSpan */ + $span = $spans[0]; + $this->assertInstanceOf(ZipkinSpan::class, $span); + $this->assertCount(1, $span->annotations); + + /* @var $annotation ZipkinAnnotation */ + $annotation = $span->annotations[0]; + $this->assertInstanceOf(ZipkinAnnotation::class, $annotation); + $this->assertSame($logTimeStamp, $annotation->timestamp); + $this->assertSame( + json_encode([ + 'foo' => 'bar', + ]), + $annotation->value + ); + + return true; + })); + + $this->sender->append($span); + $this->assertEquals(1, $this->sender->flush()); + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/SpanContextTest.php b/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/SpanContextTest.php new file mode 100644 index 000000000..998061088 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/SpanContextTest.php @@ -0,0 +1,37 @@ +assertTrue($ctx->isDebugIdContainerOnly()); + $this->assertEquals($ctx->getDebugId(), 'value1'); + + $ctx = new SpanContext(1, 2, 3, 1); + $this->assertFalse($ctx->isDebugIdContainerOnly()); + } + + /** + * @dataProvider contextDataProvider + */ + public function testBaggageInit($traceId, $spanId, $parentId, $flags, $baggage, $expected) + { + $ctx = new SpanContext($traceId, $spanId, $parentId, $flags, $baggage); + $this->assertEquals($expected, $ctx->getBaggage()); + } + + public function contextDataProvider() + { + return [ + [null, null, null, null, [], []], + [null, null, null, null, null, []], + [null, null, null, null, ['key' => 'val'], ['key' => 'val']], + ]; + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/SpanTest.php b/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/SpanTest.php new file mode 100644 index 000000000..d23879680 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/SpanTest.php @@ -0,0 +1,293 @@ +tracer = new Tracer('test-service', new NullReporter, new ConstSampler); + $this->context = new SpanContext(0, 0,0, SAMPLED_FLAG); + } + + /** + * {@inheritdoc} + */ + protected function tearDown(): void + { + $this->tracer = null; + $this->context = null; + } + + /** @test */ + public function shouldProperlyInitializeAtConstructTime(): void + { + $tags = [ + 'foo-1' => 'test-component-1', + 'foo-2' => 'test-component-2', + 'foo-3' => 'test-component-3', + ]; + + $span = new Span($this->context, $this->tracer, 'test-operation', $tags); + + $this->assertEquals( 3, count($span->getTags())); + $this->assertEquals($this->tracer, $span->getTracer()); + $this->assertEquals(false, $span->isDebug()); + $this->assertEquals(null, $span->getEndTime()); + } + + /** @test */ + public function shouldSetComponentThroughTag(): void + { + $span = new Span($this->context, $this->tracer, 'test-operation'); + + $span->setTag('component', 'libredis'); + + $spanReflection = new \ReflectionClass(Span::class); + $component = $spanReflection->getProperty('component'); + $component->setAccessible(true); + + $this->assertEquals( 0, count($span->getTags())); + $this->assertEquals( 'libredis', $component->getValue($span)); + $this->assertEquals( 'libredis', $span->getComponent()); + } + + /** @test */ + public function shouldSetTags(): void + { + $span = new Span($this->context, $this->tracer, 'test-operation'); + + $this->assertEquals( 0, count($span->getTags())); + + $span->setTags([ + 'foo-1' => 'test-component-1', + 'foo-2' => 'test-component-2', + 'foo-3' => 'test-component-3', + ]); + + $this->assertEquals( 3, count($span->getTags())); + } + + /** @test */ + public function shouldSetDifferentTypeOfTags() { + $span = new Span($this->context, $this->tracer, 'test-operation'); + + $this->assertEquals( 0, count($span->getTags())); + + $span->setTags([ + 'tag-bool1' => true, + 'tag-bool2' => false, + 'tag-int' => 1234567, + 'tag-float' => 1.23456, + 'tag-string' => "hello-world" + ]); + + $tags = array_values($span->getTags()); + $this->assertEquals( 5, count($tags)); + + $index = 0; + $this->assertTrue($tags[$index]->annotation_type === AnnotationType::BOOL); + $this->assertTrue($tags[$index]->value === true); + $this->assertTrue($tags[$index]->key === 'tag-bool1'); + $index++; + + $this->assertTrue($tags[$index]->annotation_type === AnnotationType::BOOL); + $this->assertTrue($tags[$index]->value === false); + $this->assertTrue($tags[$index]->key === 'tag-bool2'); + $index++; + + $this->assertTrue($tags[$index]->annotation_type === AnnotationType::I64); + $this->assertTrue($tags[$index]->value === 1234567); + $this->assertTrue($tags[$index]->key === 'tag-int'); + $index++; + + $this->assertTrue($tags[$index]->annotation_type === AnnotationType::DOUBLE); + $this->assertTrue($tags[$index]->value === 1.23456); + $this->assertTrue($tags[$index]->key === 'tag-float'); + $index++; + + $this->assertTrue($tags[$index]->annotation_type === AnnotationType::STRING); + $this->assertTrue($tags[$index]->value === "hello-world"); + $this->assertTrue($tags[$index]->key === 'tag-string'); + } + + /** @test */ + public function shouldOverwriteTheSameTag(): void + { + // Given + $span = new Span($this->context, $this->tracer, 'test-operation'); + + // When + $span->setTag('foo', 'test-component-1'); + $span->setTag('foo', 'test-component-2'); + + // Then + $this->assertEquals( 1, count($span->getTags())); + $this->assertEquals( 'test-component-2', $span->getTags()['foo']->value); + } + /** @test */ + public function shouldAddLogRecordsToTheSpan(): void + { + $span = new Span($this->context, $this->tracer, 'test-operation'); + + $fields01 = [ + 'event' => 'error', + 'message' => 'dummy error message', + ]; + $fields02 = [ + 'foo' => 'bar', + ]; + + $dateTime01 = new \DateTime('+5 seconds'); + $dateTime02 = $dateTime01->getTimestamp(); + $dateTime03 = microtime(true) + 5; + + $span->log($fields01, $dateTime01); + $span->log($fields02, $dateTime01->getTimestamp()*1000000); + $span->log($fields02, $dateTime03); + $span->log($fields02); + + $logs = $span->getLogs(); + + $this->assertCount(4, $logs); + + $this->assertIsInt($logs[0]['timestamp']); + $this->assertEquals((int)($dateTime01->format('U.u')*1000000), $logs[0]['timestamp']); + $this->assertSame($fields01, $logs[0]['fields']); + + $this->assertIsInt($logs[1]['timestamp']); + $this->assertSame($dateTime02*1000000, $logs[1]['timestamp']); + $this->assertSame($fields02, $logs[1]['fields']); + + $this->assertIsInt($logs[2]['timestamp']); + $this->assertSame((int) ($dateTime03 * 1000000), $logs[2]['timestamp']); + $this->assertSame($fields02, $logs[2]['fields']); + + $this->assertIsInt($logs[3]['timestamp']); + $this->assertSame($fields02, $logs[3]['fields']); + } + + /** @test */ + public function timingDefaultTimes(): void + { + $span = new Span($this->context, $this->tracer, 'test-operation'); + $span->finish(); + + $this->assertEquals(0.0, round(($span->getEndTime() - $span->getStartTime()) / 1000000)); + } + + /** @test */ + public function timingSetStartTimeAsDateTime(): void + { + $span = new Span($this->context, $this->tracer, 'test-operation', [], new \DateTime('-2 seconds')); + $span->finish(); + + $this->assertSpanDuration($span); + } + + /** @test */ + public function timingSetEndTimeAsDateTime(): void + { + $span = new Span($this->context, $this->tracer, 'test-operation'); + + $endTime = new \DateTime('+2 seconds'); + // add microseconds because php < 7.1 has a bug + // https://bugs.php.net/bug.php?id=48225 + if (version_compare(phpversion(), '7.1', '<')) { + list($usec) = explode(' ', microtime()); + $endTime = \DateTime::createFromFormat('U.u', $endTime->format('U')+$usec); + } + $span->finish($endTime); + + $this->assertSpanDuration($span); + } + + /** @test */ + public function timingSetStartTimeAsInt(): void + { + $span = new Span($this->context, $this->tracer, 'test-operation', [], (int) round((microtime(true) - 2) * 1000000)); + $span->finish(); + + $this->assertSpanDuration($span); + } + + /** @test */ + public function timingSetEndTimeAsInt(): void + { + $span = new Span($this->context, $this->tracer, 'test-operation'); + $span->finish((int) round((microtime(true) + 2) * 1000000)); + + $this->assertSpanDuration($span); + } + + /** @test */ + public function timingSetStartTimeAsFloat(): void + { + $span = new Span($this->context, $this->tracer, 'test-operation', [], microtime(true) - 2); + $span->finish(); + + $this->assertSpanDuration($span); + } + + /** @test */ + public function timingSetEndTimeAsFloat(): void + { + $span = new Span($this->context, $this->tracer, 'test-operation'); + $span->finish(microtime(true) + 2); + + $this->assertSpanDuration($span); + } + + /** @test */ + public function timingSetMixedTimes(): void + { + $span = new Span($this->context, $this->tracer, 'test-operation', [], new \DateTime()); + $span->finish(microtime(true) + 2); + + $this->assertSpanDuration($span); + } + + protected function assertSpanDuration(Span $span): void + { + $this->assertEquals(2, (int)(($span->getEndTime() - $span->getStartTime()) / 1000000)); + } + + /** @test */ + public function invalidStartTime(): void + { + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Time should be one of the types int|float|DateTime|null, got string.'); + $span = new Span($this->context, $this->tracer, 'test-operation', [], 'string'); + } + + /** @test */ + public function invalidEndTime(): void + { + $span = new Span($this->context, $this->tracer, 'test-operation'); + $this->expectException(\InvalidArgumentException::class); + $this->expectExceptionMessage('Time should be one of the types int|float|DateTime|null, got array.'); + $span->finish([]); + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/ThriftUdpTransportTest.php b/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/ThriftUdpTransportTest.php new file mode 100644 index 000000000..abc4e32aa --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/ThriftUdpTransportTest.php @@ -0,0 +1,166 @@ +logger = new StackLogger(); + $this->transport = new ThriftUdpTransport('127.0.0.1', 12345, $this->logger); + } + + public function testisOpenWhenOpen() + { + $this->assertEquals($this->logger->getMessagesCount(), 0); + $this->assertTrue($this->transport->isOpen()); + $this->assertEquals($this->logger->getMessagesCount(), 0); + } + + public function testisOpenWhenClosed() + { + $this->assertEquals($this->logger->getMessagesCount(), 0); + $this->transport->close(); + $this->assertFalse($this->transport->isOpen()); + $this->assertEquals($this->logger->getMessagesCount(), 0); + } + + public function testClose() + { + $this->assertEquals($this->logger->getMessagesCount(), 0); + $this->transport->close(); + + $this->assertEquals($this->logger->getMessagesCount(), 0); + $this->transport->write('hello'); + $this->assertEquals($this->logger->getMessagesCount(), 1); + $this->assertEquals($this->logger->getLastMessage(), 'transport is closed'); + $this->assertEquals($this->logger->getMessagesCount(), 0); + } + + public function testDoubleClose() + { + $this->assertEquals($this->logger->getMessagesCount(), 0); + $this->transport->close(); + $this->assertEquals($this->logger->getMessagesCount(), 0); + $this->transport->close(); + $this->assertEquals($this->logger->getMessagesCount(), 1); + $this->assertEquals( + $this->logger->getLastMessage(), + "can't close empty socket" + ); + } + + public function testException() + { + $this->assertEquals($this->logger->getMessagesCount(), 0); + $this->transport->open(); + $this->assertEquals($this->logger->getMessagesCount(), 0); + + $this->transport->write(str_repeat("some string", 10000)); + + $this->assertEquals($this->logger->getMessagesCount(), 1); + $msg = $this->logger->getLastMessage(); + $pattern = "/socket_write failed: \[code - \d+\] Message too long/"; + + if (method_exists($this, "assertMatchesRegularExpression")) { + $this->assertMatchesRegularExpression($pattern, $msg); + } else { + $this->assertRegExp($pattern, $msg); + } + } + + public function testProtocolVersionIPv4() + { + $config = new Config([ + Config::IP_VERSION => Config::IPV4 + ], "testServiceName"); + + $transport = new ThriftUdpTransport('127.0.0.1', 12345, $this->logger, $config); + + $reflectionTransport = new \ReflectionClass($transport); + $ipProtocolVersionMethod = $reflectionTransport->getMethod("ipProtocolVersion"); + $ipProtocolVersionMethod->setAccessible(true); + + $this->assertEquals(Config::IPV4, $ipProtocolVersionMethod->invoke($transport)); + } + + public function testProtocolVersionIPv6() + { + $config = new Config([ + Config::IP_VERSION => Config::IPV6 + ], "testServiceName"); + + $transport = new ThriftUdpTransport('127.0.0.1', 12345, $this->logger, $config); +// + $reflectionTransport = new \ReflectionClass($transport); + $ipProtocolVersionMethod = $reflectionTransport->getMethod("ipProtocolVersion"); + $ipProtocolVersionMethod->setAccessible(true); +// + $this->assertEquals(Config::IPV6, $ipProtocolVersionMethod->invoke($transport)); + } + + public function testProtocolVersionDefault() + { + $config = new Config([ + ], "testServiceName"); + + $transport = new ThriftUdpTransport('127.0.0.1', 12345, $this->logger, $config); + + $reflectionTransport = new \ReflectionClass($transport); + $ipProtocolVersionMethod = $reflectionTransport->getMethod("ipProtocolVersion"); + $ipProtocolVersionMethod->setAccessible(true); + + $this->assertEquals(Config::IPV4, $ipProtocolVersionMethod->invoke($transport)); + } + + public function testCreateSocket() + { + $transport = $this->getMockBuilder(ThriftUdpTransport::class) + ->disableOriginalConstructor() + ->getMock(); + + $reflectionClass = new \ReflectionClass($transport); + $method = $reflectionClass->getMethod("setLogger"); + $method->setAccessible(true); + $method->invokeArgs($transport, [$this->logger]); + + $method = $reflectionClass->getMethod("createSocket"); + $method->setAccessible(true); + $res = $method->invokeArgs($transport, [Config::IPV6]); + + $this->assertNotFalse($res); + + + $transport = $this->getMockBuilder(ThriftUdpTransport::class) + ->disableOriginalConstructor() + ->getMock(); + + $reflectionClass = new \ReflectionClass($transport); + $method = $reflectionClass->getMethod("setLogger"); + $method->setAccessible(true); + $method->invokeArgs($transport, [$this->logger]); + + $method = $reflectionClass->getMethod("createSocket"); + $method->setAccessible(true); + $res = $method->invokeArgs($transport, [Config::IPV4]); + + $this->assertNotFalse($res); + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/TracerTest.php b/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/TracerTest.php new file mode 100644 index 000000000..3e7b4c05f --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/tests/Jaeger/TracerTest.php @@ -0,0 +1,262 @@ +scopeManager = $this->createMock(ScopeManager::class); + $this->sampler = $this->createMock(SamplerInterface::class); + $this->reporter = $this->createMock(ReporterInterface::class); + $this->logger = new NullLogger(); + + $this->tracer = new Tracer($this->serviceName, $this->reporter, $this->sampler, true, $this->logger, $this->scopeManager); + } + + public function testStartSpan(): void + { + $span = $this->tracer->startSpan($this->operationName); + + $this->assertEquals($this->operationName, $span->getOperationName()); + } + + public function testStartActiveSpan(): void + { + $tracer = new Tracer($this->serviceName, $this->reporter, $this->sampler); + + $tracer->startActiveSpan('test-operation1'); + $this->assertEquals('test-operation1', $tracer->getActiveSpan()->getOperationName()); + + $scope = $tracer->startActiveSpan('test-operation2'); + $this->assertEquals('test-operation2', $tracer->getActiveSpan()->getOperationName()); + $scope->close(); + + $this->assertEquals('test-operation1', $tracer->getActiveSpan()->getOperationName()); + } + + /** @test */ + public function shouldAddConfiguredTagsToStartedSpanWhenSampled(): void + { + $this->sampler->expects($this->any()) + ->method('isSampled') + ->willReturn([true, []]); + + $tags = [ + 'bar' => 'a-value', + 'other.tag' => 'foo', + ]; + + $tracer = new Tracer( + $this->serviceName, + $this->reporter, + $this->sampler, + true, + $this->logger, + $this->scopeManager, + TRACE_ID_HEADER, + BAGGAGE_HEADER_PREFIX, + DEBUG_ID_HEADER_KEY, + $tags + ); + + $span = $tracer->startSpan('test-span'); + $spanTags = $span->getTags(); + + foreach ($tags as $name => $value) { + $this->assertArrayHasKey($name, $spanTags, "Tag '$name' should be set on span"); + $this->assertEquals($value, $spanTags[$name]->value, "Tag '$name' should have configured value"); + } + } + + /** @test */ + public function shouldAddNoConfiguredTagsToStartedSpanWhenNotSampled(): void + { + $this->sampler->expects($this->any()) + ->method('isSampled') + ->willReturn([false, []]); + + $tags = [ + 'bar' => 'a-value', + 'other.tag' => 'foo', + ]; + + $tracer = new Tracer( + $this->serviceName, + $this->reporter, + $this->sampler, + true, + $this->logger, + $this->scopeManager, + TRACE_ID_HEADER, + BAGGAGE_HEADER_PREFIX, + DEBUG_ID_HEADER_KEY, + $tags + ); + + $span = $tracer->startSpan('test-span'); + + $this->assertEquals([], $span->getTags(), 'No tags should be set when not sampled'); + } + + /** @test */ + public function shouldThrowExceptionOnInvalidFormat(): void + { + $spanContext = new SpanContext(0, 0, 0, 0); + $carrier = []; + + $this->expectException(UnsupportedFormatException::class); + $this->expectExceptionMessage('The format "bad-format" is not supported.'); + + $this->tracer->inject($spanContext, 'bad-format', $carrier); + $this->assertSame([], $carrier); + } + + /** @test */ + public function shouldNotThrowExceptionOnInvalidContext(): void + { + $spanContext = new NoopSpanContext(); + $carrier = []; + + $this->tracer->inject($spanContext, ZIPKIN_SPAN_FORMAT, $carrier); + $this->assertSame([], $carrier); + } + + /** @test */ + public function shouldInjectSpanContextToCarrier(): void + { + $spanContext = new SpanContext(0, 0, 0, 0); + $carrier = []; + + $this->tracer->inject($spanContext, TEXT_MAP, $carrier); + + $this->assertCount(1, $carrier); + $this->assertEquals('0:0:0:0', $carrier[TRACE_ID_HEADER]); + } + + /** @test */ + public function shouldThrowExceptionOnExtractInvalidFormat(): void + { + $this->expectException(UnsupportedFormatException::class); + $this->expectExceptionMessage('The format "bad-format" is not supported.'); + + $this->tracer->extract('bad-format', []); + } + + /** @test */ + public function shouldNotThrowExceptionOnExtractFromMalformedState(): void + { + $this->assertNull($this->tracer->extract(TEXT_MAP, ['uber-trace-id' => ''])); + } + + /** @test */ + public function shouldExtractSpanContextFromCarrier(): void + { + $carrier = ['uber-trace-id' => '32834e4115071776:f7802330248418d:f123456789012345:1']; + + $this->assertInstanceOf(SpanContext::class, $this->tracer->extract(TEXT_MAP, $carrier)); + } + + public function testGetScopeManager() + { + $this->assertEquals($this->scopeManager, $this->tracer->getScopeManager()); + } + + public function testGetActiveSpan(): void + { + $span = $this->createMock(Span::class); + $scope = $this->createMock(Scope::class); + $scope->expects($this->once())->method('getSpan')->willReturn($span); + + $this->scopeManager->expects($this->once())->method('getActive')->willReturn($scope); + + $this->assertEquals($span, $this->tracer->getActiveSpan()); + } + + public function testGetActiveSpanNull(): void + { + $this->scopeManager->expects($this->once())->method('getActive')->willReturn(null); + + $this->assertEquals(null, $this->tracer->getActiveSpan()); + } + + public function testFlush(): void + { + $this->reporter->expects($this->once())->method('close'); + + $this->tracer->flush(); + } + + /** @test */ + public function shouldHandleEmptyHostName(): void + { + $tracer = new \ReflectionClass(Tracer::class); + + $getHostByName = $tracer->getMethod('getHostByName'); + $getHostByName->setAccessible(true); + + $stub = $this->getMockBuilder(Tracer::class) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + + $logger = $tracer->getProperty('logger'); + $logger->setAccessible(true); + $logger->setValue($stub, $this->logger); + + $this->assertEquals('127.0.0.1', $getHostByName->invokeArgs($stub, [null])); + } +} diff --git a/vendor/jonahgeorge/jaeger-client-php/tests/README.md b/vendor/jonahgeorge/jaeger-client-php/tests/README.md new file mode 100644 index 000000000..aa828030f --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/tests/README.md @@ -0,0 +1,48 @@ +# Jaeger Bindings for PHP OpenTracing API: Unit Tests + +Welcome to the Jaeger Testing Suite. + +This folder includes all the unit tests that test Jaeger components, ensuring that you enjoy a bug free library. + +## Current PHP Support + +| version | status | +|---------|--------| +| 7.0 | ✔ | +| 7.1 | ✔ | +| 7.2 | ✔ | + + +## Getting Started + +This testing suite uses [Travis CI](https://travis-ci.org/) for each run. +Every commit pushed to this repository will queue a build into the continuous integration service and will run all tests +to ensure that everything is going well and the project is stable. + +The testing suite can be run on your own machine. The main dependency is [PHPUnit](https://phpunit.de/) +which can be installed using [Composer](https://getcomposer.org/): + +```bash +# run this command from project root +$ composer install +``` + +Then run the tests by calling command from the terminal as follows: + +```bash +$ composer test +``` + +## Run Tests for Supported Versions + +There is also an ability to run tests for different PHP versions. To achieve this we offer use +[docker](https://docs.docker.com/install/)-based approach: + +```bash + +$ docker run --rm -it -v $(pwd):/usr/app php:7.0 ./usr/app/tests/php-test.sh + +$ docker run --rm -it -v $(pwd):/usr/app php:7.1 ./usr/app/tests/php-test.sh + +$ docker run --rm -it -v $(pwd):/usr/app php:7.2 ./usr/app/tests/php-test.sh +``` diff --git a/vendor/jonahgeorge/jaeger-client-php/tests/php-test.sh b/vendor/jonahgeorge/jaeger-client-php/tests/php-test.sh new file mode 100644 index 000000000..99a522856 --- /dev/null +++ b/vendor/jonahgeorge/jaeger-client-php/tests/php-test.sh @@ -0,0 +1,64 @@ +#!/usr/bin/env bash + +# trace ERR through pipes +set -o pipefail + +# trace ERR through 'time command' and other functions +set -o errtrace + +# set -u : exit the script if you try to use an uninitialised variable +set -o nounset + +# set -e : exit the script if any statement returns a non-true return value +set -o errexit + +# to avoid message: +# "Do not run Composer as root/super user! See https://getcomposer.org/root for details" +export COMPOSER_ALLOW_SUPERUSER=1 + +export TERM=xterm-256color + +echo "[INFO]: Install OS dependencies..." +apt-get update -yq > /dev/null 2>&1 +apt-get install -yq git wget unzip zip > /dev/null 2>&1 + +echo "[INFO]: Install PHP extensions..." +docker-php-ext-install bcmath sockets > /dev/null 2>&1 +pecl install hrtime > /dev/null 2>&1 +docker-php-ext-enable hrtime > /dev/null 2>&1 + +echo "[INFO]: Install Xdebug to enable code coverage..." +pecl install xdebug > /dev/null 2>&1 +docker-php-ext-enable xdebug > /dev/null 2>&1 + +cd /tmp + +echo "[INFO]: Install Composer..." +EXPECTED_SIGNATURE="$(wget -q -O - https://composer.github.io/installer.sig)" +php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" +ACTUAL_SIGNATURE="$(php -r "echo hash_file('SHA384', 'composer-setup.php');")" + +if [ "$EXPECTED_SIGNATURE" != "$ACTUAL_SIGNATURE" ]; then + >&2 echo '[ERROR]: Invalid installer signature' + rm composer-setup.php + exit 1 +fi + +php composer-setup.php --quiet +rm composer-setup.php + +# this step is required to be able to overwrite composer.lock +cp -R /usr/app /usr/tests + +cd /usr/tests +rm -f composer.lock + +echo "[INFO]: Install library dependencies..." +php /tmp/composer.phar install \ + --no-interaction \ + --no-ansi \ + --no-progress \ + --no-suggest + +echo -e "[INFO]: Run tests...\n" +/tmp/composer.phar test diff --git a/vendor/opentracing/opentracing/.github/ISSUE_TEMPLATE.md b/vendor/opentracing/opentracing/.github/ISSUE_TEMPLATE.md new file mode 100644 index 000000000..f99dd606b --- /dev/null +++ b/vendor/opentracing/opentracing/.github/ISSUE_TEMPLATE.md @@ -0,0 +1,21 @@ + + + +## Background +Something that gives context about why this is an issue. + +## Problem +Describe the problem. If the issue is about an improvement you can skip this. If possible, include a description of the impact of the problem. + +## Proposal +A proposal that from your POV would solve the problem or improve the existing situation. It should also include the impact. + +## Questions to address +Questions that should be answered as outcome of this issue. diff --git a/vendor/opentracing/opentracing/.github/PULL_REQUEST_TEMPLATE.md b/vendor/opentracing/opentracing/.github/PULL_REQUEST_TEMPLATE.md new file mode 100644 index 000000000..d81c08379 --- /dev/null +++ b/vendor/opentracing/opentracing/.github/PULL_REQUEST_TEMPLATE.md @@ -0,0 +1,24 @@ + + +### Short description of what this PR does: +- +- + +### Checklist +- [ ] I have made a material change to the repo (functionality, testing, spelling, grammar) +- [ ] I have read the [Contribution Guide] and my PR follows them. +- [ ] I updated my branch with the master branch. +- [ ] I have added tests that prove my fix is effective or that my feature works +- [ ] I have added necessary documentation about the functionality in the appropriate .md file +- [ ] I have added in line documentation to the code I modified + +Closes # \ No newline at end of file diff --git a/vendor/opentracing/opentracing/.github/workflows/ci.yml b/vendor/opentracing/opentracing/.github/workflows/ci.yml new file mode 100644 index 000000000..8fba7baf8 --- /dev/null +++ b/vendor/opentracing/opentracing/.github/workflows/ci.yml @@ -0,0 +1,44 @@ +name: Build +on: + push: + branches: + - master + paths-ignore: + - "**/*.md" + - "LICENSE" + pull_request: +jobs: + test: + name: OpenTracing (PHP version ${{ matrix.php-versions }} on ${{ matrix.operating-system }}) + runs-on: ${{ matrix.operating-system }} + strategy: + fail-fast: false + matrix: + operating-system: [ubuntu-latest, windows-latest, macos-latest] + php-versions: ["7.1", "7.2", "7.3", "7.4", "8.0", "8.1"] + steps: + - name: Checkout + uses: actions/checkout@v2 + - name: Setup PHP, with composer and extensions + uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php + with: + php-version: ${{ matrix.php-versions }} + - name: Get composer cache directory + id: composer-cache + run: echo "::set-output name=dir::$(composer config cache-files-dir)" + - name: Cache composer dependencies + uses: actions/cache@v2 + with: + path: ${{ steps.composer-cache.outputs.dir }} + key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }} + restore-keys: ${{ runner.os }}-composer- + - name: Install Composer dependencies + run: | + composer install --no-progress --prefer-dist --optimize-autoloader + - name: Run lint + if: matrix.operating-system != 'windows-latest' + run: composer lint + - name: Run static check + run: composer static-check + - name: Run tests + run: composer test diff --git a/vendor/opentracing/opentracing/.gitignore b/vendor/opentracing/opentracing/.gitignore new file mode 100644 index 000000000..56e80855d --- /dev/null +++ b/vendor/opentracing/opentracing/.gitignore @@ -0,0 +1,4 @@ +.idea/ +.phpunit.result.cache +composer.lock +vendor \ No newline at end of file diff --git a/vendor/opentracing/opentracing/CONTRIBUTING.md b/vendor/opentracing/opentracing/CONTRIBUTING.md new file mode 100644 index 000000000..a13c0fe1d --- /dev/null +++ b/vendor/opentracing/opentracing/CONTRIBUTING.md @@ -0,0 +1,75 @@ +Contributing +============ + +Thank you for contributing to this project! + +Bug reports +----------- + +If you find a bug, please submit an issue. Try to be as detailed as possible +in your problem description to help us fix the bug. + +Feature requests +---------------- + +If you wish to propose a feature, please submit an issue. Try to explain your +use case as fully as possible to help us understand why you think the feature +should be added. + +License +------- + +By contributing your code, you agree to license your contribution under the terms of the APLv2: +https://github.com/opentracing/opentracing-php/blob/master/LICENSE + +All files are released with the Apache 2.0 license. + +Creating a pull request (PR) +---------------------------- + +First [fork the repository](https://help.github.com/articles/fork-a-repo/) on +GitHub. + +Then clone your fork: + +```bash +$ git clone https://github.com/your-name/opentracing-php.git +$ git checkout -b bug-or-feature-description +``` + +And install the dependencies: + +```bash +$ composer install +``` + +Write your code and add tests. Then run the static check and the tests: + +```bash +$ composer run static-check +$ composer run test +``` + +Commit your changes and push them to GitHub: + +```bash +$ git commit -m "Fix nasty bug" +$ git push -u origin bug-or-feature-description +``` + +Then [create a pull request](https://help.github.com/articles/creating-a-pull-request/) +on GitHub. + +If you need to make some changes, commit and push them as you like. When asked +to squash your commits, do so as follows: + +```bash +git rebase -i +git push origin bug-or-feature-description -f +``` + +Coding standard +--------------- + +This project follows the [PSR-2](http://www.php-fig.org/psr/psr-2/) coding style. +Please make sure your pull requests adhere to this standard. diff --git a/vendor/opentracing/opentracing/LICENSE b/vendor/opentracing/opentracing/LICENSE new file mode 100644 index 000000000..8dada3eda --- /dev/null +++ b/vendor/opentracing/opentracing/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/vendor/opentracing/opentracing/README.md b/vendor/opentracing/opentracing/README.md new file mode 100644 index 000000000..ce03bc951 --- /dev/null +++ b/vendor/opentracing/opentracing/README.md @@ -0,0 +1,306 @@ +# OpenTracing API for PHP + +[![Build](https://github.com/opentracing/opentracing-php/actions/workflows/ci.yml/badge.svg)](https://github.com/opentracing/opentracing-php/actions/workflows/ci.yml) +[![OpenTracing Badge](https://img.shields.io/badge/OpenTracing-enabled-blue.svg)](http://opentracing.io) +[![Total Downloads](https://poser.pugx.org/opentracing/opentracing/downloads)](https://packagist.org/packages/opentracing/opentracing) +[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%205.6-8892BF.svg)](https://php.net/) +[![License](https://img.shields.io/github/license/opentracing/opentracing-php.svg)](https://github.com/opentracing/opentracing-php/blob/master/LICENSE) +[![Join the chat at https://gitter.im/opentracing/opentracing-php](https://badges.gitter.im/opentracing/opentracing-php.svg)](https://gitter.im/opentracing/opentracing-php?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + +PHP library for the OpenTracing's API. + +## Required Reading + +In order to understand the library, one must first be familiar with the +[OpenTracing project](http://opentracing.io) and +[specification](http://opentracing.io/documentation/pages/spec.html) more specifically. + +## Installation + +OpenTracing-PHP can be installed via Composer: + +```bash +composer require opentracing/opentracing +``` + +## Usage + +When consuming this library one really only need to worry about a couple of key +abstractions: the `Tracer::startActiveSpan` and `Tracer::startSpan` method, +the `Span` interface, the `Scope` interface and binding a `Tracer` at bootstrap time. Here are code snippets +demonstrating some important use cases: + +### Singleton initialization + +The simplest starting point is to set the global tracer. As early as possible, do: + +```php +use OpenTracing\GlobalTracer; + +GlobalTracer::set(new MyTracerImplementation()); +``` + +### Creating a Span given an existing Request + +To start a new `Span`, you can use the `startSpan` method. + +```php +use OpenTracing\Formats; +use OpenTracing\GlobalTracer; + +... + +// extract the span context +$spanContext = GlobalTracer::get()->extract( + Formats\HTTP_HEADERS, + getallheaders() +); + +function doSomething() { + ... + + // start a new span called 'my_span' and make it a child of the $spanContext + $span = GlobalTracer::get()->startSpan('my_span', ['child_of' => $spanContext]); + + ... + + // add some logs to the span + $span->log([ + 'event' => 'soft error', + 'type' => 'cache timeout', + 'waiter.millis' => 1500, + ]) + + // finish the the span + $span->finish(); +} +``` + +### Starting a new trace by creating a "root span" + +It's always possible to create a "root" `Span` with no parent or other causal reference. + +```php +$span = $tracer->startSpan('my_first_span'); +... +$span->finish(); +``` + +### Active Spans and Scope Manager + +For most use cases, it is recommended that you use the `Tracer::startActiveSpan` function for +creating new spans. + +An example of a linear, two level deep span tree using active spans looks like +this in PHP code: +```php +// At dispatcher level +$scope = $tracer->startActiveSpan('request'); +... +$scope->close(); +``` +```php +// At controller level +$scope = $tracer->startActiveSpan('controller'); +... +$scope->close(); +``` + +```php +// At RPC calls level +$scope = $tracer->startActiveSpan('http'); +file_get_contents('http://php.net'); +$scope->close(); +``` + +When using the `Tracer::startActiveSpan` function the underlying tracer uses an +abstraction called scope manager to keep track of the currently active span. + +Starting an active span will always use the currently active span as a parent. +If no parent is available, then the newly created span is considered to be the +root span of the trace. + +Unless you are using asynchronous code that tracks multiple spans at the same +time, such as when using cURL Multi Exec or MySQLi Polling it is recommended that you +use `Tracer::startActiveSpan` everywhere in your application. + +The currently active span gets automatically finished when you call `$scope->close()` +as you can see in the previous examples. + +If you don't want a span to automatically close when `$scope->close()` is called +then you must specify `'finish_span_on_close'=> false,` in the `$options` +argument of `startActiveSpan`. + +#### Creating a child span assigning parent manually + +```php +$parent = GlobalTracer::get()->startSpan('parent'); + +$child = GlobalTracer::get()->startSpan('child', [ + 'child_of' => $parent +]); + +... + +$child->finish(); + +... + +$parent->finish(); +``` + +#### Creating a child span using automatic active span management + +Every new span will take the active span as parent and it will take its spot. + +```php +$parent = GlobalTracer::get()->startActiveSpan('parent'); + +... + +/* + * Since the parent span has been created by using startActiveSpan we don't need + * to pass a reference for this child span + */ +$child = GlobalTracer::get()->startActiveSpan('my_second_span'); + +... + +$child->close(); + +... + +$parent->close(); +``` + +### Serializing to the wire + +```php +use GuzzleHttp\Client; +use OpenTracing\Formats; + +... + +$tracer = GlobalTracer::get(); + +$spanContext = $tracer->extract( + Formats\HTTP_HEADERS, + getallheaders() +); + +try { + $span = $tracer->startSpan('my_span', ['child_of' => $spanContext]); + + $client = new Client; + + $headers = []; + + $tracer->inject( + $span->getContext(), + Formats\HTTP_HEADERS, + $headers + ); + + $request = new \GuzzleHttp\Psr7\Request('GET', 'http://myservice', $headers); + $client->send($request); + ... + +} catch (\Exception $e) { + ... +} +... +``` + +### Deserializing from the wire + +When using http header for context propagation you can use either the `Request` or the `$_SERVER` +variable: + +```php +use OpenTracing\GlobalTracer; +use OpenTracing\Formats; + +$tracer = GlobalTracer::get(); +$spanContext = $tracer->extract(Formats\HTTP_HEADERS, getallheaders()); +$tracer->startSpan('my_span', [ + 'child_of' => $spanContext, +]); +``` + +### Flushing Spans + +PHP as a request scoped language has no simple means to pass the collected spans +data to a background process without blocking the main request thread/process. +The OpenTracing API makes no assumptions about this, but for PHP that might +cause problems for Tracer implementations. This is why the PHP API contains a +`flush` method that allows to trigger a span sending out of process. + +```php +use OpenTracing\GlobalTracer; + +$application->run(); + +register_shutdown_function(function() { + /* Flush the tracer to the backend */ + $tracer = GlobalTracer::get(); + $tracer->flush(); +}); +``` + +This is optional, tracers can decide to immediately send finished spans to a +backend. The flush call can be implemented as a NO-OP for these tracers. + +### Using `StartSpanOptions` + +Passing options to the pass can be done using either an array or the +SpanOptions wrapper object. The following keys are valid: + +- `start_time` is a float, int or `\DateTime` representing a timestamp with arbitrary precision. +- `child_of` is an object of type `OpenTracing\SpanContext` or `OpenTracing\Span`. +- `references` is an array of `OpenTracing\Reference`. +- `tags` is an array with string keys and scalar values that represent OpenTracing tags. +- `finish_span_on_close` is a boolean that determines whether a span should be finished or not when the +scope is closed. + +```php +$span = $tracer->startActiveSpan('my_span', [ + 'child_of' => $spanContext, + 'tags' => ['foo' => 'bar'], + 'start_time' => time(), +]); +``` + +### Propagation Formats + +The propagation formats should be implemented consistently across all tracers. +If you want to implement your own format, then don't reuse the existing constants. +Tracers will throw an exception if the requested format is not handled by them. + +- `Tracer::FORMAT_TEXT_MAP` should represent the span context as a key value map. There is no + assumption about the semantics where the context is coming from and sent to. + +- `Tracer::FORMAT_HTTP_HEADERS` should represent the span context as HTTP header lines + in an array list. For two context details "Span-Id" and "Trace-Id", the + result would be `['Span-Id: abc123', 'Trace-Id: def456']`. This definition can be + passed directly to `curl` and `file_get_contents`. + +- `Tracer::FORMAT_BINARY` makes no assumptions about the data format other than it is + proprietary and each Tracer can handle it as it wants. + +## Mock implementation + +OpenTracing PHP comes with a mock implementation, it has three purposes: + +1. Helps to iron the API. +2. Works as a reference implementation. +3. Enhances vendor agnostic unit testing as it allows developers to inspect the tracing objects +in order to do assertions about them. + +## Coding Style + +OpenTracing PHP follows the [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md) +coding standard and the [PSR-4](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader.md) autoloading standard. + +## License + +All the open source contributions are under the terms of the [Apache-2.0 License](https://opensource.org/licenses/Apache-2.0). diff --git a/vendor/opentracing/opentracing/composer.json b/vendor/opentracing/opentracing/composer.json new file mode 100644 index 000000000..b00b67381 --- /dev/null +++ b/vendor/opentracing/opentracing/composer.json @@ -0,0 +1,44 @@ +{ + "name": "opentracing/opentracing", + "type": "library", + "description": "OpenTracing API for PHP", + "license": "Apache-2.0", + "minimum-stability": "stable", + "authors": [ + { + "name": "José Carlos Chávez", + "email": "jcchavezs@gmail.com" + } + ], + "require": { + "php": "^7.1 || ^8.0" + }, + "require-dev": { + "phpstan/phpstan": "~0.12", + "phpunit/phpunit": "^7.0 || ^9.0", + "squizlabs/php_codesniffer": "3.*" + }, + "config": { + "sort-packages": true + }, + "autoload": { + "psr-4": { + "OpenTracing\\": "src/OpenTracing/" + }, + "files": [ + "src/OpenTracing/Tags.php", + "src/OpenTracing/Formats.php" + ] + }, + "autoload-dev": { + "psr-4": { + "OpenTracing\\Tests\\": "tests/OpenTracing" + } + }, + "scripts": { + "fix-lint": "phpcbf --standard=ZEND --standard=PSR2 --ignore=*/vendor/* ./", + "lint": "phpcs --standard=ZEND --standard=PSR2 --ignore=*/vendor/* ./", + "test": "phpunit tests", + "static-check": "phpstan analyse" + } +} diff --git a/vendor/opentracing/opentracing/phpstan.neon b/vendor/opentracing/opentracing/phpstan.neon new file mode 100644 index 000000000..c9e64bf1f --- /dev/null +++ b/vendor/opentracing/opentracing/phpstan.neon @@ -0,0 +1,5 @@ +parameters: + paths: + - src + + level: 5 diff --git a/vendor/opentracing/opentracing/phpunit.xml b/vendor/opentracing/opentracing/phpunit.xml new file mode 100644 index 000000000..2083a425c --- /dev/null +++ b/vendor/opentracing/opentracing/phpunit.xml @@ -0,0 +1,27 @@ + + + + + tests + + + diff --git a/vendor/opentracing/opentracing/src/OpenTracing/Formats.php b/vendor/opentracing/opentracing/src/OpenTracing/Formats.php new file mode 100644 index 000000000..f26c5ecf1 --- /dev/null +++ b/vendor/opentracing/opentracing/src/OpenTracing/Formats.php @@ -0,0 +1,49 @@ +inject($span->getContext(), Formats\HTTP_HEADERS, $headers) + * $request = new GuzzleHttp\Psr7\Request($uri, $body, $headers); + * + * Or Tracer::extract(): + * + * $headers = $request->getHeaders() + * $clientContext = $tracer->extract(Formats\HTTP_HEADERS, $headers) + * + * @see http://www.php-fig.org/psr/psr-7/#12-http-headers + * @see http://php.net/manual/en/function.getallheaders.php + */ +const HTTP_HEADERS = 'http_headers'; diff --git a/vendor/opentracing/opentracing/src/OpenTracing/GlobalTracer.php b/vendor/opentracing/opentracing/src/OpenTracing/GlobalTracer.php new file mode 100644 index 000000000..aafdba121 --- /dev/null +++ b/vendor/opentracing/opentracing/src/OpenTracing/GlobalTracer.php @@ -0,0 +1,60 @@ +scopeManager = $scopeManager; + $this->span = $span; + $this->finishSpanOnClose = $finishSpanOnClose; + } + + /** + * {@inheritdoc} + */ + public function close(): void + { + if ($this->finishSpanOnClose) { + $this->span->finish(); + } + + $this->scopeManager->deactivate($this); + } + + /** + * {@inheritdoc} + * @return Span|MockSpan + */ + public function getSpan(): Span + { + return $this->span; + } +} diff --git a/vendor/opentracing/opentracing/src/OpenTracing/Mock/MockScopeManager.php b/vendor/opentracing/opentracing/src/OpenTracing/Mock/MockScopeManager.php new file mode 100644 index 000000000..c75c71942 --- /dev/null +++ b/vendor/opentracing/opentracing/src/OpenTracing/Mock/MockScopeManager.php @@ -0,0 +1,49 @@ +scopes[] = $scope; + + return $scope; + } + + /** + * {@inheritdoc} + */ + public function getActive(): ?Scope + { + if (empty($this->scopes)) { + return null; + } + + return $this->scopes[count($this->scopes) - 1]; + } + + public function deactivate(MockScope $scope): void + { + foreach ($this->scopes as $scopeIndex => $scopeItem) { + if ($scope === $scopeItem) { + unset($this->scopes[$scopeIndex]); + } + } + } +} diff --git a/vendor/opentracing/opentracing/src/OpenTracing/Mock/MockSpan.php b/vendor/opentracing/opentracing/src/OpenTracing/Mock/MockSpan.php new file mode 100644 index 000000000..db53649bf --- /dev/null +++ b/vendor/opentracing/opentracing/src/OpenTracing/Mock/MockSpan.php @@ -0,0 +1,145 @@ +operationName = $operationName; + $this->context = $context; + $this->startTime = $startTime ?: time(); + } + + /** + * {@inheritdoc} + */ + public function getOperationName(): string + { + return $this->operationName; + } + + /** + * {@inheritdoc} + * @return SpanContext|MockSpanContext + */ + public function getContext(): SpanContext + { + return $this->context; + } + + public function getStartTime(): ?int + { + return $this->startTime; + } + + /** + * {@inheritdoc} + */ + public function finish($finishTime = null): void + { + $finishTime = ($finishTime ?: time()); + $this->duration = $finishTime - $this->startTime; + } + + public function isFinished(): bool + { + return $this->duration !== null; + } + + public function getDuration(): ?int + { + return $this->duration; + } + + /** + * {@inheritdoc} + */ + public function overwriteOperationName(string $newOperationName): void + { + $this->operationName = (string)$newOperationName; + } + + /** + * {@inheritdoc} + */ + public function setTag(string $key, $value): void + { + $this->tags[$key] = $value; + } + + public function getTags(): array + { + return $this->tags; + } + + /** + * {@inheritdoc} + */ + public function log(array $fields = [], $timestamp = null): void + { + $this->logs[] = [ + 'timestamp' => $timestamp ?: time(), + 'fields' => $fields, + ]; + } + + public function getLogs(): array + { + return $this->logs; + } + + /** + * {@inheritdoc} + */ + public function addBaggageItem(string $key, string $value): void + { + $this->context = $this->context->withBaggageItem($key, $value); + } + + /** + * {@inheritdoc} + */ + public function getBaggageItem(string $key): ?string + { + return $this->context->getBaggageItem($key); + } +} diff --git a/vendor/opentracing/opentracing/src/OpenTracing/Mock/MockSpanContext.php b/vendor/opentracing/opentracing/src/OpenTracing/Mock/MockSpanContext.php new file mode 100644 index 000000000..d094ea0e0 --- /dev/null +++ b/vendor/opentracing/opentracing/src/OpenTracing/Mock/MockSpanContext.php @@ -0,0 +1,100 @@ +traceId = $traceId; + $this->spanId = $spanId; + $this->isSampled = $isSampled; + $this->items = $items; + } + + public static function create(int $traceId, int $spanId, bool $sampled = true, array $items = []): SpanContext + { + return new self($traceId, $spanId, $sampled, $items); + } + + public static function createAsRoot(bool $sampled = true, array $items = []): SpanContext + { + $traceId = $spanId = self::nextId(); + return new self($traceId, $spanId, $sampled, $items); + } + + public static function createAsChildOf(MockSpanContext $spanContext): SpanContext + { + $spanId = self::nextId(); + return new self($spanContext->traceId, $spanId, $spanContext->isSampled, $spanContext->items); + } + + public function getTraceId(): int + { + return $this->traceId; + } + + public function getSpanId(): int + { + return $this->spanId; + } + + public function isSampled(): bool + { + return $this->isSampled; + } + + /** + * {@inheritdoc} + */ + public function getIterator(): ArrayIterator + { + return new ArrayIterator($this->items); + } + + /** + * {@inheritdoc} + */ + public function getBaggageItem(string $key): ?string + { + return array_key_exists($key, $this->items) ? $this->items[$key] : null; + } + + /** + * {@inheritdoc} + */ + public function withBaggageItem(string $key, string $value): SpanContext + { + return new self($this->traceId, $this->spanId, $this->isSampled, array_merge($this->items, [$key => $value])); + } + + private static function nextId(): int + { + return mt_rand(0, 99999); + } +} diff --git a/vendor/opentracing/opentracing/src/OpenTracing/Mock/MockTracer.php b/vendor/opentracing/opentracing/src/OpenTracing/Mock/MockTracer.php new file mode 100644 index 000000000..f4f4577a1 --- /dev/null +++ b/vendor/opentracing/opentracing/src/OpenTracing/Mock/MockTracer.php @@ -0,0 +1,152 @@ +injectors = $injectors; + $this->extractors = $extractors; + $this->scopeManager = new MockScopeManager(); + } + + /** + * {@inheritdoc} + */ + public function startActiveSpan(string $operationName, $options = []): Scope + { + if (!($options instanceof StartSpanOptions)) { + $options = StartSpanOptions::create($options); + } + + if (($activeSpan = $this->getActiveSpan()) !== null) { + $options = $options->withParent($activeSpan); + } + + $span = $this->startSpan($operationName, $options); + + return $this->scopeManager->activate($span, $options->shouldFinishSpanOnClose()); + } + + /** + * {@inheritdoc} + */ + public function startSpan(string $operationName, $options = []): Span + { + if (!($options instanceof StartSpanOptions)) { + $options = StartSpanOptions::create($options); + } + + if (empty($options->getReferences())) { + $spanContext = MockSpanContext::createAsRoot(); + } else { + $referenceContext = $options->getReferences()[0]->getSpanContext(); + if (!$referenceContext instanceof MockSpanContext) { + throw InvalidReferenceArgumentException::forInvalidContext($referenceContext); + } + $spanContext = MockSpanContext::createAsChildOf($referenceContext); + } + + $span = new MockSpan($operationName, $spanContext, $options->getStartTime()); + + foreach ($options->getTags() as $key => $value) { + $span->setTag($key, $value); + } + + $this->spans[] = $span; + + return $span; + } + + /** + * {@inheritdoc} + */ + public function inject(SpanContext $spanContext, string $format, &$carrier): void + { + if (!array_key_exists($format, $this->injectors)) { + throw UnsupportedFormatException::forFormat($format); + } + + $this->injectors[$format]($spanContext, $carrier); + } + + /** + * {@inheritdoc} + */ + public function extract(string $format, $carrier): ?SpanContext + { + if (!array_key_exists($format, $this->extractors)) { + throw UnsupportedFormatException::forFormat($format); + } + + return $this->extractors[$format]($carrier); + } + + /** + * {@inheritdoc} + */ + public function flush(): void + { + $this->spans = []; + } + + /** + * @return array|MockSpan[] + */ + public function getSpans(): array + { + return $this->spans; + } + + /** + * {@inheritdoc} + */ + public function getScopeManager(): ScopeManager + { + return $this->scopeManager; + } + + /** + * {@inheritdoc} + */ + public function getActiveSpan(): ?Span + { + if (null !== ($activeScope = $this->scopeManager->getActive())) { + return $activeScope->getSpan(); + } + + return null; + } +} diff --git a/vendor/opentracing/opentracing/src/OpenTracing/NoopScope.php b/vendor/opentracing/opentracing/src/OpenTracing/NoopScope.php new file mode 100644 index 000000000..7170c846a --- /dev/null +++ b/vendor/opentracing/opentracing/src/OpenTracing/NoopScope.php @@ -0,0 +1,23 @@ +type = $type; + $this->spanContext = $spanContext; + } + + /** + * @param string $type + * @param Span $span + * @return Reference when context is invalid + * @throws InvalidReferenceArgumentException on empty type + */ + public static function createForSpan(string $type, Span $span): Reference + { + return new self($type, $span->getContext()); + } + + /** + * @return SpanContext + */ + public function getSpanContext(): SpanContext + { + return $this->spanContext; + } + + /** + * Checks whether a Reference is of one type. + * + * @param string $type the type for the reference + * @return bool + */ + public function isType(string $type): bool + { + return $this->type === $type; + } +} diff --git a/vendor/opentracing/opentracing/src/OpenTracing/Scope.php b/vendor/opentracing/opentracing/src/OpenTracing/Scope.php new file mode 100644 index 000000000..174495434 --- /dev/null +++ b/vendor/opentracing/opentracing/src/OpenTracing/Scope.php @@ -0,0 +1,32 @@ +is scheduled and on the path. + */ +interface Scope +{ + /** + * Mark the end of the active period for the current thread and {@link Scope}, + * updating the {@link ScopeManager#active()} in the process. + * + * NOTE: Calling {@link #close} more than once on a single {@link Scope} instance leads to undefined + * behavior. + * + * @return void + */ + public function close(): void; + + /** + * @return Span the {@link Span} that's been scoped by this {@link Scope} + */ + public function getSpan(): Span; +} diff --git a/vendor/opentracing/opentracing/src/OpenTracing/ScopeManager.php b/vendor/opentracing/opentracing/src/OpenTracing/ScopeManager.php new file mode 100644 index 000000000..db5fcaa47 --- /dev/null +++ b/vendor/opentracing/opentracing/src/OpenTracing/ScopeManager.php @@ -0,0 +1,40 @@ + value format, key must be a string and tag must be either + * a string, a boolean value, or a numeric type. + * + * If the span is already finished, a warning should be logged. + * + * @param array $fields + * @param int|float|DateTimeInterface $timestamp + * @return void + */ + public function log(array $fields = [], $timestamp = null): void; + + /** + * Adds a baggage item to the SpanContext which is immutable so it is required to use + * SpanContext::withBaggageItem to get a new one. + * + * If the span is already finished, a warning should be logged. + * + * @param string $key + * @param string $value + * @return void + */ + public function addBaggageItem(string $key, string $value): void; + + /** + * @param string $key + * @return string|null returns null when there is not a item under the provided key + */ + public function getBaggageItem(string $key): ?string; +} diff --git a/vendor/opentracing/opentracing/src/OpenTracing/SpanContext.php b/vendor/opentracing/opentracing/src/OpenTracing/SpanContext.php new file mode 100644 index 000000000..ca05ff9ac --- /dev/null +++ b/vendor/opentracing/opentracing/src/OpenTracing/SpanContext.php @@ -0,0 +1,37 @@ + value string pairs that apply to the given Span, + * its SpanContext, and all Spans which directly or transitively reference + * the local Span. That is, baggage items propagate in-band along with the + * trace itself. + */ +interface SpanContext extends IteratorAggregate +{ + /** + * Returns the value of a baggage item based on its key. If there is no + * value with such key it will return null. + * + * @param string $key + * @return string|null + */ + public function getBaggageItem(string $key): ?string; + + /** + * Creates a new SpanContext out of the existing one and the new key => value pair. + * + * @param string $key + * @param string $value + * @return SpanContext + */ + public function withBaggageItem(string $key, string $value): SpanContext; +} diff --git a/vendor/opentracing/opentracing/src/OpenTracing/StartSpanOptions.php b/vendor/opentracing/opentracing/src/OpenTracing/StartSpanOptions.php new file mode 100644 index 000000000..28b73ff0a --- /dev/null +++ b/vendor/opentracing/opentracing/src/OpenTracing/StartSpanOptions.php @@ -0,0 +1,206 @@ + $value) { + switch ($key) { + case 'child_of': + if (!empty($spanOptions->references)) { + throw InvalidSpanOptionException::forIncludingBothChildOfAndReferences(); + } + + $spanOptions->references[] = self::buildChildOf($value); + break; + + case 'references': + if (!empty($spanOptions->references)) { + throw InvalidSpanOptionException::forIncludingBothChildOfAndReferences(); + } + + if ($value instanceof Reference) { + $spanOptions->references = [$value]; + } elseif (is_array($value)) { + $spanOptions->references = self::buildReferences($value); + } else { + throw InvalidSpanOptionException::forInvalidReferenceSet($value); + } + + break; + + case 'tags': + if (!is_array($value)) { + throw InvalidSpanOptionException::forInvalidTags($value); + } + + foreach ($value as $tag => $tagValue) { + if ($tag !== (string)$tag) { + throw InvalidSpanOptionException::forInvalidTag($tag); + } + + $spanOptions->tags[$tag] = $tagValue; + } + break; + + case 'start_time': + if (is_scalar($value) && !is_numeric($value)) { + throw InvalidSpanOptionException::forInvalidStartTime(); + } + + $spanOptions->startTime = $value; + break; + + case 'finish_span_on_close': + if (!is_bool($value)) { + throw InvalidSpanOptionException::forFinishSpanOnClose($value); + } + + $spanOptions->finishSpanOnClose = $value; + break; + + case 'ignore_active_span': + if (!is_bool($value)) { + throw InvalidSpanOptionException::forIgnoreActiveSpan($value); + } + + $spanOptions->ignoreActiveSpan = $value; + break; + + default: + throw InvalidSpanOptionException::forUnknownOption($key); + } + } + + return $spanOptions; + } + + /** + * @param Span|SpanContext $parent + * @return StartSpanOptions + */ + public function withParent($parent): StartSpanOptions + { + $newSpanOptions = new StartSpanOptions(); + $newSpanOptions->references[] = self::buildChildOf($parent); + $newSpanOptions->tags = $this->tags; + $newSpanOptions->startTime = $this->startTime; + $newSpanOptions->finishSpanOnClose = $this->finishSpanOnClose; + $newSpanOptions->ignoreActiveSpan = $this->ignoreActiveSpan; + + return $newSpanOptions; + } + + /** + * @return Reference[] + */ + public function getReferences(): array + { + return $this->references; + } + + /** + * @return array + */ + public function getTags(): array + { + return $this->tags; + } + + /** + * @return int|float|DateTime|null if returning float or int it should represent + * the timestamp (including as many decimal places as you need) + */ + public function getStartTime() + { + return $this->startTime; + } + + /** + * @return bool + */ + public function shouldFinishSpanOnClose(): bool + { + return $this->finishSpanOnClose; + } + + /** + * @return bool + */ + public function shouldIgnoreActiveSpan(): bool + { + return $this->ignoreActiveSpan; + } + + private static function buildChildOf($value): Reference + { + if ($value instanceof Span) { + return Reference::createForSpan(Reference::CHILD_OF, $value); + } + + if ($value instanceof SpanContext) { + return new Reference(Reference::CHILD_OF, $value); + } + + throw InvalidSpanOptionException::forInvalidChildOf($value); + } + + private static function buildReferences(array $referencesArray): array + { + $references = []; + + foreach ($referencesArray as $reference) { + if (!($reference instanceof Reference)) { + throw InvalidSpanOptionException::forInvalidReference($reference); + } + + $references[] = $reference; + } + + return $references; + } +} diff --git a/vendor/opentracing/opentracing/src/OpenTracing/Tags.php b/vendor/opentracing/opentracing/src/OpenTracing/Tags.php new file mode 100644 index 000000000..5d06627de --- /dev/null +++ b/vendor/opentracing/opentracing/src/OpenTracing/Tags.php @@ -0,0 +1,124 @@ +getActive()->getSpan(), + * and null will be returned if {@link Scope#active()} is null. + * + * @return Span|null + */ + public function getActiveSpan(): ?Span; + + /** + * Starts a new span that is activated on a scope manager. + * + * It's also possible to not finish the {@see \OpenTracing\Span} when + * {@see \OpenTracing\Scope} context expires: + * + * $scope = $tracer->startActiveSpan('...', [ + * 'finish_span_on_close' => false, + * ]); + * $span = $scope->getSpan(); + * try { + * $span->setTag(Tags\HTTP_METHOD, 'GET'); + * // ... + * } finally { + * $scope->close(); + * } + * // $span->finish() is not called as part of Scope deactivation as + * // finish_span_on_close is false + * + * @param string $operationName + * @param array|StartSpanOptions $options Same as for startSpan() with + * additional option of `finish_span_on_close` that enables finishing + * of span whenever a scope is closed. It is true by default. + * + * @return Scope A Scope that holds newly created Span and is activated on + * a ScopeManager. + */ + public function startActiveSpan(string $operationName, $options = []): Scope; + + /** + * Starts and returns a new span representing a unit of work. + * + * Whenever `child_of` reference is not passed then + * {@see \OpenTracing\ScopeManager::getActive()} span is used as `child_of` + * reference. In order to ignore implicit parent span pass in + * `ignore_active_span` option set to true. + * + * Starting a span with explicit parent: + * + * $tracer->startSpan('...', [ + * 'child_of' => $parentSpan, + * ]); + * + * @param string $operationName + * @param array|StartSpanOptions $options See StartSpanOptions for + * available options. + * + * @return Span + * + * @throws InvalidSpanOptionException for invalid option + * @throws InvalidReferencesSetException for invalid references set + * @see \OpenTracing\StartSpanOptions + */ + public function startSpan(string $operationName, $options = []): Span; + + /** + * @param SpanContext $spanContext + * @param string $format + * @param mixed $carrier + * @return void + * + * @throws UnsupportedFormatException when the format is not recognized by the tracer + * implementation + * @see Formats + */ + public function inject(SpanContext $spanContext, string $format, &$carrier): void; + + /** + * @param string $format + * @param mixed $carrier + * @return SpanContext|null + * + * @throws UnsupportedFormatException when the format is not recognized by the tracer + * implementation + * @see Formats + */ + public function extract(string $format, $carrier): ?SpanContext; + + /** + * Allow tracer to send span data to be instrumented. + * + * This method might not be needed depending on the tracing implementation + * but one should make sure this method is called after the request is delivered + * to the client. + * + * As an implementor, a good idea would be to use {@see register_shutdown_function} + * or {@see fastcgi_finish_request} in order to not to delay the end of the request + * to the client. + */ + public function flush(): void; +} diff --git a/vendor/opentracing/opentracing/src/OpenTracing/UnsupportedFormatException.php b/vendor/opentracing/opentracing/src/OpenTracing/UnsupportedFormatException.php new file mode 100644 index 000000000..dd4ef56a3 --- /dev/null +++ b/vendor/opentracing/opentracing/src/OpenTracing/UnsupportedFormatException.php @@ -0,0 +1,22 @@ +assertNull($scopeManager->getActive()); + } + + public function testActivateSuccess() + { + $tracer = new MockTracer(); + $span = $tracer->startSpan(self::OPERATION_NAME); + $scopeManager = new MockScopeManager(); + $scopeManager->activate($span); + + $this->assertSame($span, $scopeManager->getActive()->getSpan()); + } + + public function testGetScopeReturnsNull() + { + $tracer = new MockTracer(); + $tracer->startSpan(self::OPERATION_NAME); + $scopeManager = new MockScopeManager(); + + $this->assertNull($scopeManager->getActive()); + } + + public function testGetScopeSuccess() + { + $tracer = new MockTracer(); + $span = $tracer->startSpan(self::OPERATION_NAME); + $scopeManager = new MockScopeManager(); + $scopeManager->activate($span); + $scope = $scopeManager->getActive(); + + $this->assertSame($span, $scope->getSpan()); + } + + public function testDeactivateSuccess() + { + $tracer = new MockTracer(); + $span = $tracer->startSpan(self::OPERATION_NAME); + $scopeManager = new MockScopeManager(); + $scopeManager->activate($span); + $scope = $scopeManager->getActive(); + $scopeManager->deactivate($scope); + + $this->assertNull($scopeManager->getActive()); + } +} diff --git a/vendor/opentracing/opentracing/tests/OpenTracing/Mock/MockSpanContextTest.php b/vendor/opentracing/opentracing/tests/OpenTracing/Mock/MockSpanContextTest.php new file mode 100644 index 000000000..501450b24 --- /dev/null +++ b/vendor/opentracing/opentracing/tests/OpenTracing/Mock/MockSpanContextTest.php @@ -0,0 +1,54 @@ +assertEquals($parentContext->getTraceId(), $childContext->getTraceId()); + } + + public function testCreateMockSpanContextSuccess() + { + $spanContext = MockSpanContext::create( + self::TRACE_ID, + self::SPAN_ID, + self::IS_SAMPLED, + [self::BAGGAGE_ITEM_KEY => self::BAGGAGE_ITEM_VALUE] + ); + + $this->assertEquals($spanContext->getTraceId(), self::TRACE_ID); + $this->assertEquals($spanContext->getSpanId(), self::SPAN_ID); + $this->assertEquals($spanContext->isSampled(), self::IS_SAMPLED); + $this->assertEquals([self::BAGGAGE_ITEM_KEY => self::BAGGAGE_ITEM_VALUE], iterator_to_array($spanContext)); + $this->assertEquals(self::BAGGAGE_ITEM_VALUE, $spanContext->getBaggageItem(self::BAGGAGE_ITEM_KEY)); + } + + public function testAddBaggageItemSuccess() + { + $spanContext = MockSpanContext::create( + self::TRACE_ID, + self::SPAN_ID, + self::IS_SAMPLED + ); + $this->assertEmpty(iterator_to_array($spanContext)); + + $spanContext = $spanContext->withBaggageItem(self::BAGGAGE_ITEM_KEY, self::BAGGAGE_ITEM_VALUE); + $this->assertEquals([self::BAGGAGE_ITEM_KEY => self::BAGGAGE_ITEM_VALUE], iterator_to_array($spanContext)); + } +} diff --git a/vendor/opentracing/opentracing/tests/OpenTracing/Mock/MockSpanTest.php b/vendor/opentracing/opentracing/tests/OpenTracing/Mock/MockSpanTest.php new file mode 100644 index 000000000..51e4b66f8 --- /dev/null +++ b/vendor/opentracing/opentracing/tests/OpenTracing/Mock/MockSpanTest.php @@ -0,0 +1,52 @@ +assertEquals($startTime, $span->getStartTime()); + $this->assertEmpty($span->getTags()); + $this->assertEmpty($span->getLogs()); + } + + public function testAddTagsAndLogsToSpanSuccess() + { + $span = new MockSpan(self::OPERATION_NAME, MockSpanContext::createAsRoot()); + + $span->setTag(self::TAG_KEY, self::TAG_VALUE); + $span->log([self::LOG_FIELD]); + + $this->assertEquals([self::TAG_KEY => self::TAG_VALUE], $span->getTags()); + $this->assertEquals(self::LOG_FIELD, $span->getLogs()[0]['fields'][0]); + } + + public function testSpanIsFinished() + { + $startTime = time(); + $span = new MockSpan(self::OPERATION_NAME, MockSpanContext::createAsRoot(), $startTime); + $span->finish($startTime + self::DURATION); + + $this->assertTrue($span->isFinished()); + $this->assertEquals(self::DURATION, $span->getDuration()); + } +} diff --git a/vendor/opentracing/opentracing/tests/OpenTracing/Mock/MockTracerTest.php b/vendor/opentracing/opentracing/tests/OpenTracing/Mock/MockTracerTest.php new file mode 100644 index 000000000..ab2faf159 --- /dev/null +++ b/vendor/opentracing/opentracing/tests/OpenTracing/Mock/MockTracerTest.php @@ -0,0 +1,139 @@ +startActiveSpan(self::OPERATION_NAME); + $activeSpan = $tracer->getActiveSpan(); + + $this->assertEquals($scope->getSpan(), $activeSpan); + } + + public function testStartSpanSuccess() + { + $tracer = new MockTracer(); + $tracer->startSpan(self::OPERATION_NAME); + $activeSpan = $tracer->getActiveSpan(); + + $this->assertNull($activeSpan); + } + + public function testStartSpanWithReference(): void + { + $tracer = new MockTracer(); + $tracer->startSpan('parent_name'); + /** @var Span $parentSpan */ + $parentSpan = $tracer->getSpans()[0]; + $tracer->startSpan( + self::OPERATION_NAME, + ['references' => [Reference::createForSpan(Reference::CHILD_OF, $parentSpan)]] + ); + $activeSpan = $tracer->getActiveSpan(); + + self::assertNull($activeSpan); + } + + public function testStartSpanWithReferenceWithoutExpectedContextType(): void + { + $tracer = new MockTracer(); + $notAMockContext = new NoopSpanContext(); + + $this->expectException(InvalidReferenceArgumentException::class); + + $tracer->startSpan( + self::OPERATION_NAME, + ['references' => [new Reference(Reference::CHILD_OF, $notAMockContext)]] + ); + } + + public function testInjectWithNoInjectorsFails() + { + $tracer = new MockTracer(); + $span = $tracer->startSpan(self::OPERATION_NAME); + $carrier = []; + + $this->expectException(UnsupportedFormatException::class); + $tracer->inject($span->getContext(), self::FORMAT, $carrier); + } + + public function testInjectSuccess() + { + $actualSpanContext = null; + $actualCarrier = null; + + $injector = function ($spanContext, &$carrier) use (&$actualSpanContext, &$actualCarrier) { + $actualSpanContext = $spanContext; + $actualCarrier = $carrier; + }; + + $tracer = new MockTracer([self::FORMAT => $injector]); + $span = $tracer->startSpan(self::OPERATION_NAME); + $carrier = []; + $tracer->inject($span->getContext(), self::FORMAT, $carrier); + + $this->assertSame($span->getContext(), $actualSpanContext); + $this->assertSame($carrier, $actualCarrier); + } + + public function testExtractWithNoExtractorsFails() + { + $tracer = new MockTracer(); + $carrier = []; + + $this->expectException(UnsupportedFormatException::class); + $tracer->extract(self::FORMAT, $carrier); + } + + public function testExtractSuccess() + { + $actualSpanContext = null; + $actualCarrier = null; + + $extractor = function ($carrier) use (&$actualCarrier) { + $actualCarrier = $carrier; + return new NoopSpanContext(); + }; + + $tracer = new MockTracer([], [self::FORMAT => $extractor]); + $carrier = [ + 'TRACE_ID' => 'trace_id' + ]; + + $spanContext = $tracer->extract(self::FORMAT, $carrier); + + $this->assertInstanceOf(SpanContext::class, $spanContext); + } + + public function testFlushSuccess() + { + $tracer = new MockTracer(); + $tracer->startSpan(self::OPERATION_NAME); + + $this->assertCount(1, $tracer->getSpans()); + + $tracer->flush(); + + $this->assertCount(0, $tracer->getSpans()); + } +} diff --git a/vendor/opentracing/opentracing/tests/OpenTracing/ReferenceTest.php b/vendor/opentracing/opentracing/tests/OpenTracing/ReferenceTest.php new file mode 100644 index 000000000..cb971a20c --- /dev/null +++ b/vendor/opentracing/opentracing/tests/OpenTracing/ReferenceTest.php @@ -0,0 +1,45 @@ +expectException(TypeError::class); + new Reference('child_of', $context); + } + + public function testCreateAReferenceFailsOnEmptyType() + { + $context = new NoopSpanContext(); + + $this->expectException(InvalidReferenceArgumentException::class); + $this->expectExceptionMessage('Reference type can not be an empty string'); + new Reference('', $context); + } + + public function testAReferenceCanBeCreatedAsACustomType() + { + $context = new NoopSpanContext(); + $reference = new Reference(self::REFERENCE_TYPE, $context); + + $this->assertSame($context, $reference->getSpanContext()); + $this->assertTrue($reference->isType(self::REFERENCE_TYPE)); + } +} diff --git a/vendor/opentracing/opentracing/tests/OpenTracing/StartSpanOptionsTest.php b/vendor/opentracing/opentracing/tests/OpenTracing/StartSpanOptionsTest.php new file mode 100644 index 000000000..d7e1504a8 --- /dev/null +++ b/vendor/opentracing/opentracing/tests/OpenTracing/StartSpanOptionsTest.php @@ -0,0 +1,129 @@ +expectException(InvalidSpanOptionException::class); + + StartSpanOptions::create([ + 'unknown_option' => 'value' + ]); + } + + public function testSpanOptionsWithInvalidCloseOnFinishOption() + { + $this->expectException(InvalidSpanOptionException::class); + + StartSpanOptions::create([ + 'finish_span_on_close' => 'value' + ]); + } + + public function testSpanOptionsCanNotBeCreatedBecauseInvalidStartTime() + { + $this->expectException(InvalidSpanOptionException::class); + + StartSpanOptions::create([ + 'start_time' => 'abc' + ]); + } + + /** @dataProvider validStartTime */ + public function testSpanOptionsCanBeCreatedBecauseWithValidStartTime($startTime) + { + $spanOptions = StartSpanOptions::create([ + 'start_time' => $startTime + ]); + + $this->assertEquals($spanOptions->getStartTime(), $startTime); + } + + public function validStartTime() + { + return [ + [new DateTime()], + ['1499355363'], + [1499355363], + [1499355363.123456] + ]; + } + + public function testSpanOptionsCanBeCreatedWithValidReference() + { + $context = new NoopSpanContext(); + + $options = [ + 'references' => new Reference(self::REFERENCE_TYPE, $context), + ]; + + $spanOptions = StartSpanOptions::create($options); + $references = $spanOptions->getReferences()[0]; + + $this->assertTrue($references->isType(self::REFERENCE_TYPE)); + $this->assertSame($context, $references->getSpanContext()); + } + + public function testSpanOptionsDefaultCloseOnFinishValue() + { + $options = StartSpanOptions::create([]); + + $this->assertTrue($options->shouldFinishSpanOnClose()); + } + + public function testSpanOptionsWithValidFinishSpanOnClose() + { + $options = StartSpanOptions::create([ + 'finish_span_on_close' => false, + ]); + + $this->assertFalse($options->shouldFinishSpanOnClose()); + } + + public function testSpanOptionsAddsANewReference() + { + $context1 = new NoopSpanContext(); + $spanOptions = StartSpanOptions::create([ + 'child_of' => $context1, + ]); + $this->assertCount(1, $spanOptions->getReferences()); + + $context2 = new NoopSpanContext(); + $spanOptions = $spanOptions->withParent($context2); + + $this->assertCount(1, $spanOptions->getReferences()); + $this->assertSame($context2, $spanOptions->getReferences()[0]->getSpanContext()); + } + + public function testDefaultIgnoreActiveSpan() + { + $options = StartSpanOptions::create([]); + + $this->assertFalse($options->shouldIgnoreActiveSpan()); + } + + public function testSpanOptionsWithValidIgnoreActiveSpan() + { + $options = StartSpanOptions::create([ + 'ignore_active_span' => true, + ]); + + $this->assertTrue($options->shouldIgnoreActiveSpan()); + } +} diff --git a/vendor/packaged/thrift/.gitignore b/vendor/packaged/thrift/.gitignore new file mode 100644 index 000000000..ff72e2d08 --- /dev/null +++ b/vendor/packaged/thrift/.gitignore @@ -0,0 +1,2 @@ +/composer.lock +/vendor diff --git a/vendor/packaged/thrift/README.md b/vendor/packaged/thrift/README.md new file mode 100644 index 000000000..c35ca057e --- /dev/null +++ b/vendor/packaged/thrift/README.md @@ -0,0 +1,44 @@ +Apache Thrift +===== + +The code provided by this library is from: +https://github.com/apache/thrift/tree/master/lib/php/lib + +This repo has been created to provide the thrift protocol via composer + + +Thrift PHP Software Library + +License +======= + +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. + +Dependencies +============ + +PHP_INT_SIZE + + This built-in signals whether your architecture is 32 or 64 bit and is + used by the TBinaryProtocol to properly use pack() and unpack() to + serialize data. + +apc_fetch(), apc_store() + + APC cache is used by the TSocketPool class. If you do not have APC installed, + Thrift will fill in null stub function definitions. diff --git a/vendor/packaged/thrift/composer.json b/vendor/packaged/thrift/composer.json new file mode 100644 index 000000000..8a8227dd3 --- /dev/null +++ b/vendor/packaged/thrift/composer.json @@ -0,0 +1,16 @@ +{ + "name": "packaged/thrift", + "description": "Apache Thrift", + "keywords": ["thrift", "apache"], + "homepage": "http://thrift.apache.org/", + "minimum-stability": "stable", + "license": "Apache-2.0", + "require": { + "php": "^5.5 || ^7.0 || ^8.0" + }, + "autoload": { + "psr-4": { + "Thrift\\": "src/" + } + } +} diff --git a/vendor/packaged/thrift/src/Base/TBase.php b/vendor/packaged/thrift/src/Base/TBase.php new file mode 100644 index 000000000..c61b631af --- /dev/null +++ b/vendor/packaged/thrift/src/Base/TBase.php @@ -0,0 +1,382 @@ + 'Bool', + TType::BYTE => 'Byte', + TType::I16 => 'I16', + TType::I32 => 'I32', + TType::I64 => 'I64', + TType::DOUBLE => 'Double', + TType::STRING => 'String' + ); + + abstract public function read($input); + + abstract public function write($output); + + public function __construct($spec = null, $vals = null) + { + if (is_array($spec) && is_array($vals)) { + foreach ($spec as $fid => $fspec) { + $var = $fspec['var']; + if (isset($vals[$var])) { + $this->$var = $vals[$var]; + } + } + } + } + + public function __wakeup() + { + $this->__construct(get_object_vars($this)); + } + + private function _readMap(&$var, $spec, $input) + { + $xfer = 0; + $ktype = $spec['ktype']; + $vtype = $spec['vtype']; + $kread = $vread = null; + if (isset(TBase::$tmethod[$ktype])) { + $kread = 'read' . TBase::$tmethod[$ktype]; + } else { + $kspec = $spec['key']; + } + if (isset(TBase::$tmethod[$vtype])) { + $vread = 'read' . TBase::$tmethod[$vtype]; + } else { + $vspec = $spec['val']; + } + $var = array(); + $_ktype = $_vtype = $size = 0; + $xfer += $input->readMapBegin($_ktype, $_vtype, $size); + for ($i = 0; $i < $size; ++$i) { + $key = $val = null; + if ($kread !== null) { + $xfer += $input->$kread($key); + } else { + switch ($ktype) { + case TType::STRUCT: + $class = $kspec['class']; + $key = new $class(); + $xfer += $key->read($input); + break; + case TType::MAP: + $xfer += $this->_readMap($key, $kspec, $input); + break; + case TType::LST: + $xfer += $this->_readList($key, $kspec, $input, false); + break; + case TType::SET: + $xfer += $this->_readList($key, $kspec, $input, true); + break; + } + } + if ($vread !== null) { + $xfer += $input->$vread($val); + } else { + switch ($vtype) { + case TType::STRUCT: + $class = $vspec['class']; + $val = new $class(); + $xfer += $val->read($input); + break; + case TType::MAP: + $xfer += $this->_readMap($val, $vspec, $input); + break; + case TType::LST: + $xfer += $this->_readList($val, $vspec, $input, false); + break; + case TType::SET: + $xfer += $this->_readList($val, $vspec, $input, true); + break; + } + } + $var[$key] = $val; + } + $xfer += $input->readMapEnd(); + + return $xfer; + } + + private function _readList(&$var, $spec, $input, $set = false) + { + $xfer = 0; + $etype = $spec['etype']; + $eread = $vread = null; + if (isset(TBase::$tmethod[$etype])) { + $eread = 'read' . TBase::$tmethod[$etype]; + } else { + $espec = $spec['elem']; + } + $var = array(); + $_etype = $size = 0; + if ($set) { + $xfer += $input->readSetBegin($_etype, $size); + } else { + $xfer += $input->readListBegin($_etype, $size); + } + for ($i = 0; $i < $size; ++$i) { + $elem = null; + if ($eread !== null) { + $xfer += $input->$eread($elem); + } else { + $espec = $spec['elem']; + switch ($etype) { + case TType::STRUCT: + $class = $espec['class']; + $elem = new $class(); + $xfer += $elem->read($input); + break; + case TType::MAP: + $xfer += $this->_readMap($elem, $espec, $input); + break; + case TType::LST: + $xfer += $this->_readList($elem, $espec, $input, false); + break; + case TType::SET: + $xfer += $this->_readList($elem, $espec, $input, true); + break; + } + } + if ($set) { + $var[$elem] = true; + } else { + $var [] = $elem; + } + } + if ($set) { + $xfer += $input->readSetEnd(); + } else { + $xfer += $input->readListEnd(); + } + + return $xfer; + } + + protected function _read($class, $spec, $input) + { + $xfer = 0; + $fname = null; + $ftype = 0; + $fid = 0; + $xfer += $input->readStructBegin($fname); + while (true) { + $xfer += $input->readFieldBegin($fname, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + if (isset($spec[$fid])) { + $fspec = $spec[$fid]; + $var = $fspec['var']; + if ($ftype == $fspec['type']) { + $xfer = 0; + if (isset(TBase::$tmethod[$ftype])) { + $func = 'read' . TBase::$tmethod[$ftype]; + $xfer += $input->$func($this->$var); + } else { + switch ($ftype) { + case TType::STRUCT: + $class = $fspec['class']; + $this->$var = new $class(); + $xfer += $this->$var->read($input); + break; + case TType::MAP: + $xfer += $this->_readMap($this->$var, $fspec, $input); + break; + case TType::LST: + $xfer += $this->_readList($this->$var, $fspec, $input, false); + break; + case TType::SET: + $xfer += $this->_readList($this->$var, $fspec, $input, true); + break; + } + } + } else { + $xfer += $input->skip($ftype); + } + } else { + $xfer += $input->skip($ftype); + } + $xfer += $input->readFieldEnd(); + } + $xfer += $input->readStructEnd(); + + return $xfer; + } + + private function _writeMap($var, $spec, $output) + { + $xfer = 0; + $ktype = $spec['ktype']; + $vtype = $spec['vtype']; + $kwrite = $vwrite = null; + if (isset(TBase::$tmethod[$ktype])) { + $kwrite = 'write' . TBase::$tmethod[$ktype]; + } else { + $kspec = $spec['key']; + } + if (isset(TBase::$tmethod[$vtype])) { + $vwrite = 'write' . TBase::$tmethod[$vtype]; + } else { + $vspec = $spec['val']; + } + $xfer += $output->writeMapBegin($ktype, $vtype, count($var)); + foreach ($var as $key => $val) { + if (isset($kwrite)) { + $xfer += $output->$kwrite($key); + } else { + switch ($ktype) { + case TType::STRUCT: + $xfer += $key->write($output); + break; + case TType::MAP: + $xfer += $this->_writeMap($key, $kspec, $output); + break; + case TType::LST: + $xfer += $this->_writeList($key, $kspec, $output, false); + break; + case TType::SET: + $xfer += $this->_writeList($key, $kspec, $output, true); + break; + } + } + if (isset($vwrite)) { + $xfer += $output->$vwrite($val); + } else { + switch ($vtype) { + case TType::STRUCT: + $xfer += $val->write($output); + break; + case TType::MAP: + $xfer += $this->_writeMap($val, $vspec, $output); + break; + case TType::LST: + $xfer += $this->_writeList($val, $vspec, $output, false); + break; + case TType::SET: + $xfer += $this->_writeList($val, $vspec, $output, true); + break; + } + } + } + $xfer += $output->writeMapEnd(); + + return $xfer; + } + + private function _writeList($var, $spec, $output, $set = false) + { + $xfer = 0; + $etype = $spec['etype']; + $ewrite = null; + if (isset(TBase::$tmethod[$etype])) { + $ewrite = 'write' . TBase::$tmethod[$etype]; + } else { + $espec = $spec['elem']; + } + if ($set) { + $xfer += $output->writeSetBegin($etype, count($var)); + } else { + $xfer += $output->writeListBegin($etype, count($var)); + } + foreach ($var as $key => $val) { + $elem = $set ? $key : $val; + if (isset($ewrite)) { + $xfer += $output->$ewrite($elem); + } else { + switch ($etype) { + case TType::STRUCT: + $xfer += $elem->write($output); + break; + case TType::MAP: + $xfer += $this->_writeMap($elem, $espec, $output); + break; + case TType::LST: + $xfer += $this->_writeList($elem, $espec, $output, false); + break; + case TType::SET: + $xfer += $this->_writeList($elem, $espec, $output, true); + break; + } + } + } + if ($set) { + $xfer += $output->writeSetEnd(); + } else { + $xfer += $output->writeListEnd(); + } + + return $xfer; + } + + protected function _write($class, $spec, $output) + { + $xfer = 0; + $xfer += $output->writeStructBegin($class); + foreach ($spec as $fid => $fspec) { + $var = $fspec['var']; + if ($this->$var !== null) { + $ftype = $fspec['type']; + $xfer += $output->writeFieldBegin($var, $ftype, $fid); + if (isset(TBase::$tmethod[$ftype])) { + $func = 'write' . TBase::$tmethod[$ftype]; + $xfer += $output->$func($this->$var); + } else { + switch ($ftype) { + case TType::STRUCT: + $xfer += $this->$var->write($output); + break; + case TType::MAP: + $xfer += $this->_writeMap($this->$var, $fspec, $output); + break; + case TType::LST: + $xfer += $this->_writeList($this->$var, $fspec, $output, false); + break; + case TType::SET: + $xfer += $this->_writeList($this->$var, $fspec, $output, true); + break; + } + } + $xfer += $output->writeFieldEnd(); + } + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + + return $xfer; + } +} diff --git a/vendor/packaged/thrift/src/ClassLoader/ThriftClassLoader.php b/vendor/packaged/thrift/src/ClassLoader/ThriftClassLoader.php new file mode 100644 index 000000000..4361bd84e --- /dev/null +++ b/vendor/packaged/thrift/src/ClassLoader/ThriftClassLoader.php @@ -0,0 +1,206 @@ +apc = $apc; + $this->apc_prefix = $apc_prefix; + } + + /** + * Registers a namespace. + * + * @param string $namespace The namespace + * @param array|string $paths The location(s) of the namespace + */ + public function registerNamespace($namespace, $paths) + { + $this->namespaces[$namespace] = (array)$paths; + } + + /** + * Registers a Thrift definition namespace. + * + * @param string $namespace The definition namespace + * @param array|string $paths The location(s) of the definition namespace + */ + public function registerDefinition($namespace, $paths) + { + $this->definitions[$namespace] = (array)$paths; + } + + /** + * Registers this instance as an autoloader. + * + * @param Boolean $prepend Whether to prepend the autoloader or not + */ + public function register($prepend = false) + { + spl_autoload_register(array($this, 'loadClass'), true, $prepend); + } + + /** + * Loads the given class, definition or interface. + * + * @param string $class The name of the class + */ + public function loadClass($class) + { + if ((true === $this->apc && ($file = $this->findFileInApc($class))) or + ($file = $this->findFile($class)) + ) { + require_once $file; + } + } + + /** + * Loads the given class or interface in APC. + * @param string $class The name of the class + * @return string + */ + protected function findFileInApc($class) + { + if (false === $file = apc_fetch($this->apc_prefix . $class)) { + apc_store($this->apc_prefix . $class, $file = $this->findFile($class)); + } + + return $file; + } + + /** + * Find class in namespaces or definitions directories + * @param string $class + * @return string + */ + public function findFile($class) + { + // Remove first backslash + if ('\\' == $class[0]) { + $class = substr($class, 1); + } + + if (false !== $pos = strrpos($class, '\\')) { + // Namespaced class name + $namespace = substr($class, 0, $pos); + + // Iterate in normal namespaces + foreach ($this->namespaces as $ns => $dirs) { + //Don't interfere with other autoloaders + if (0 !== strpos($namespace, $ns)) { + continue; + } + + foreach ($dirs as $dir) { + $className = substr($class, $pos + 1); + + $file = $dir . DIRECTORY_SEPARATOR . + str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . + DIRECTORY_SEPARATOR . + $className . '.php'; + + if (file_exists($file)) { + return $file; + } + } + } + + // Iterate in Thrift namespaces + + // Remove first part of namespace + $m = explode('\\', $class); + + // Ignore wrong call + if (count($m) <= 1) { + return; + } + + $class = array_pop($m); + $namespace = implode('\\', $m); + + foreach ($this->definitions as $ns => $dirs) { + //Don't interfere with other autoloaders + if (0 !== strpos($namespace, $ns)) { + continue; + } + + foreach ($dirs as $dir) { + /** + * Available in service: Interface, Client, Processor, Rest + * And every service methods (_.+) + */ + if (0 === preg_match('#(.+)(if|client|processor|rest)$#i', $class, $n) and + 0 === preg_match('#(.+)_[a-z0-9]+_(args|result)$#i', $class, $n) + ) { + $className = 'Types'; + } else { + $className = $n[1]; + } + + $file = $dir . DIRECTORY_SEPARATOR . + str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . + DIRECTORY_SEPARATOR . + $className . '.php'; + + if (file_exists($file)) { + return $file; + } + } + } + } + } +} diff --git a/vendor/packaged/thrift/src/Exception/TApplicationException.php b/vendor/packaged/thrift/src/Exception/TApplicationException.php new file mode 100644 index 000000000..ebb6a6a89 --- /dev/null +++ b/vendor/packaged/thrift/src/Exception/TApplicationException.php @@ -0,0 +1,76 @@ + array('var' => 'message', + 'type' => TType::STRING), + 2 => array('var' => 'code', + 'type' => TType::I32)); + + const UNKNOWN = 0; + const UNKNOWN_METHOD = 1; + const INVALID_MESSAGE_TYPE = 2; + const WRONG_METHOD_NAME = 3; + const BAD_SEQUENCE_ID = 4; + const MISSING_RESULT = 5; + const INTERNAL_ERROR = 6; + const PROTOCOL_ERROR = 7; + const INVALID_TRANSFORM = 8; + const INVALID_PROTOCOL = 9; + const UNSUPPORTED_CLIENT_TYPE = 10; + + public function __construct($message = null, $code = 0) + { + parent::__construct($message, $code); + } + + public function read($output) + { + return $this->_read('TApplicationException', self::$_TSPEC, $output); + } + + public function write($output) + { + $xfer = 0; + $xfer += $output->writeStructBegin('TApplicationException'); + if ($message = $this->getMessage()) { + $xfer += $output->writeFieldBegin('message', TType::STRING, 1); + $xfer += $output->writeString($message); + $xfer += $output->writeFieldEnd(); + } + if ($code = $this->getCode()) { + $xfer += $output->writeFieldBegin('type', TType::I32, 2); + $xfer += $output->writeI32($code); + $xfer += $output->writeFieldEnd(); + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + + return $xfer; + } +} diff --git a/vendor/packaged/thrift/src/Exception/TException.php b/vendor/packaged/thrift/src/Exception/TException.php new file mode 100644 index 000000000..7dbf83293 --- /dev/null +++ b/vendor/packaged/thrift/src/Exception/TException.php @@ -0,0 +1,384 @@ + $fspec) { + $var = $fspec['var']; + if (isset($vals[$var])) { + $this->$var = $vals[$var]; + } + } + } else { + parent::__construct($p1, $p2); + } + } + + public static $tmethod = array( + TType::BOOL => 'Bool', + TType::BYTE => 'Byte', + TType::I16 => 'I16', + TType::I32 => 'I32', + TType::I64 => 'I64', + TType::DOUBLE => 'Double', + TType::STRING => 'String' + ); + + private function _readMap(&$var, $spec, $input) + { + $xfer = 0; + $ktype = $spec['ktype']; + $vtype = $spec['vtype']; + $kread = $vread = null; + if (isset(TBase::$tmethod[$ktype])) { + $kread = 'read' . TBase::$tmethod[$ktype]; + } else { + $kspec = $spec['key']; + } + if (isset(TBase::$tmethod[$vtype])) { + $vread = 'read' . TBase::$tmethod[$vtype]; + } else { + $vspec = $spec['val']; + } + $var = array(); + $_ktype = $_vtype = $size = 0; + $xfer += $input->readMapBegin($_ktype, $_vtype, $size); + for ($i = 0; $i < $size; ++$i) { + $key = $val = null; + if ($kread !== null) { + $xfer += $input->$kread($key); + } else { + switch ($ktype) { + case TType::STRUCT: + $class = $kspec['class']; + $key = new $class(); + $xfer += $key->read($input); + break; + case TType::MAP: + $xfer += $this->_readMap($key, $kspec, $input); + break; + case TType::LST: + $xfer += $this->_readList($key, $kspec, $input, false); + break; + case TType::SET: + $xfer += $this->_readList($key, $kspec, $input, true); + break; + } + } + if ($vread !== null) { + $xfer += $input->$vread($val); + } else { + switch ($vtype) { + case TType::STRUCT: + $class = $vspec['class']; + $val = new $class(); + $xfer += $val->read($input); + break; + case TType::MAP: + $xfer += $this->_readMap($val, $vspec, $input); + break; + case TType::LST: + $xfer += $this->_readList($val, $vspec, $input, false); + break; + case TType::SET: + $xfer += $this->_readList($val, $vspec, $input, true); + break; + } + } + $var[$key] = $val; + } + $xfer += $input->readMapEnd(); + + return $xfer; + } + + private function _readList(&$var, $spec, $input, $set = false) + { + $xfer = 0; + $etype = $spec['etype']; + $eread = $vread = null; + if (isset(TBase::$tmethod[$etype])) { + $eread = 'read' . TBase::$tmethod[$etype]; + } else { + $espec = $spec['elem']; + } + $var = array(); + $_etype = $size = 0; + if ($set) { + $xfer += $input->readSetBegin($_etype, $size); + } else { + $xfer += $input->readListBegin($_etype, $size); + } + for ($i = 0; $i < $size; ++$i) { + $elem = null; + if ($eread !== null) { + $xfer += $input->$eread($elem); + } else { + $espec = $spec['elem']; + switch ($etype) { + case TType::STRUCT: + $class = $espec['class']; + $elem = new $class(); + $xfer += $elem->read($input); + break; + case TType::MAP: + $xfer += $this->_readMap($elem, $espec, $input); + break; + case TType::LST: + $xfer += $this->_readList($elem, $espec, $input, false); + break; + case TType::SET: + $xfer += $this->_readList($elem, $espec, $input, true); + break; + } + } + if ($set) { + $var[$elem] = true; + } else { + $var [] = $elem; + } + } + if ($set) { + $xfer += $input->readSetEnd(); + } else { + $xfer += $input->readListEnd(); + } + + return $xfer; + } + + protected function _read($class, $spec, $input) + { + $xfer = 0; + $fname = null; + $ftype = 0; + $fid = 0; + $xfer += $input->readStructBegin($fname); + while (true) { + $xfer += $input->readFieldBegin($fname, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + if (isset($spec[$fid])) { + $fspec = $spec[$fid]; + $var = $fspec['var']; + if ($ftype == $fspec['type']) { + $xfer = 0; + if (isset(TBase::$tmethod[$ftype])) { + $func = 'read' . TBase::$tmethod[$ftype]; + $xfer += $input->$func($this->$var); + } else { + switch ($ftype) { + case TType::STRUCT: + $class = $fspec['class']; + $this->$var = new $class(); + $xfer += $this->$var->read($input); + break; + case TType::MAP: + $xfer += $this->_readMap($this->$var, $fspec, $input); + break; + case TType::LST: + $xfer += $this->_readList($this->$var, $fspec, $input, false); + break; + case TType::SET: + $xfer += $this->_readList($this->$var, $fspec, $input, true); + break; + } + } + } else { + $xfer += $input->skip($ftype); + } + } else { + $xfer += $input->skip($ftype); + } + $xfer += $input->readFieldEnd(); + } + $xfer += $input->readStructEnd(); + + return $xfer; + } + + private function _writeMap($var, $spec, $output) + { + $xfer = 0; + $ktype = $spec['ktype']; + $vtype = $spec['vtype']; + $kwrite = $vwrite = null; + if (isset(TBase::$tmethod[$ktype])) { + $kwrite = 'write' . TBase::$tmethod[$ktype]; + } else { + $kspec = $spec['key']; + } + if (isset(TBase::$tmethod[$vtype])) { + $vwrite = 'write' . TBase::$tmethod[$vtype]; + } else { + $vspec = $spec['val']; + } + $xfer += $output->writeMapBegin($ktype, $vtype, count($var)); + foreach ($var as $key => $val) { + if (isset($kwrite)) { + $xfer += $output->$kwrite($key); + } else { + switch ($ktype) { + case TType::STRUCT: + $xfer += $key->write($output); + break; + case TType::MAP: + $xfer += $this->_writeMap($key, $kspec, $output); + break; + case TType::LST: + $xfer += $this->_writeList($key, $kspec, $output, false); + break; + case TType::SET: + $xfer += $this->_writeList($key, $kspec, $output, true); + break; + } + } + if (isset($vwrite)) { + $xfer += $output->$vwrite($val); + } else { + switch ($vtype) { + case TType::STRUCT: + $xfer += $val->write($output); + break; + case TType::MAP: + $xfer += $this->_writeMap($val, $vspec, $output); + break; + case TType::LST: + $xfer += $this->_writeList($val, $vspec, $output, false); + break; + case TType::SET: + $xfer += $this->_writeList($val, $vspec, $output, true); + break; + } + } + } + $xfer += $output->writeMapEnd(); + + return $xfer; + } + + private function _writeList($var, $spec, $output, $set = false) + { + $xfer = 0; + $etype = $spec['etype']; + $ewrite = null; + if (isset(TBase::$tmethod[$etype])) { + $ewrite = 'write' . TBase::$tmethod[$etype]; + } else { + $espec = $spec['elem']; + } + if ($set) { + $xfer += $output->writeSetBegin($etype, count($var)); + } else { + $xfer += $output->writeListBegin($etype, count($var)); + } + foreach ($var as $key => $val) { + $elem = $set ? $key : $val; + if (isset($ewrite)) { + $xfer += $output->$ewrite($elem); + } else { + switch ($etype) { + case TType::STRUCT: + $xfer += $elem->write($output); + break; + case TType::MAP: + $xfer += $this->_writeMap($elem, $espec, $output); + break; + case TType::LST: + $xfer += $this->_writeList($elem, $espec, $output, false); + break; + case TType::SET: + $xfer += $this->_writeList($elem, $espec, $output, true); + break; + } + } + } + if ($set) { + $xfer += $output->writeSetEnd(); + } else { + $xfer += $output->writeListEnd(); + } + + return $xfer; + } + + protected function _write($class, $spec, $output) + { + $xfer = 0; + $xfer += $output->writeStructBegin($class); + foreach ($spec as $fid => $fspec) { + $var = $fspec['var']; + if ($this->$var !== null) { + $ftype = $fspec['type']; + $xfer += $output->writeFieldBegin($var, $ftype, $fid); + if (isset(TBase::$tmethod[$ftype])) { + $func = 'write' . TBase::$tmethod[$ftype]; + $xfer += $output->$func($this->$var); + } else { + switch ($ftype) { + case TType::STRUCT: + $xfer += $this->$var->write($output); + break; + case TType::MAP: + $xfer += $this->_writeMap($this->$var, $fspec, $output); + break; + case TType::LST: + $xfer += $this->_writeList($this->$var, $fspec, $output, false); + break; + case TType::SET: + $xfer += $this->_writeList($this->$var, $fspec, $output, true); + break; + } + } + $xfer += $output->writeFieldEnd(); + } + } + $xfer += $output->writeFieldStop(); + $xfer += $output->writeStructEnd(); + + return $xfer; + } +} diff --git a/vendor/packaged/thrift/src/Exception/TProtocolException.php b/vendor/packaged/thrift/src/Exception/TProtocolException.php new file mode 100644 index 000000000..3a55d45ff --- /dev/null +++ b/vendor/packaged/thrift/src/Exception/TProtocolException.php @@ -0,0 +1,50 @@ +strictRead_ = $strictRead; + $this->strictWrite_ = $strictWrite; + } + + public function getProtocol($trans) + { + return new TBinaryProtocol($trans, $this->strictRead_, $this->strictWrite_); + } +} diff --git a/vendor/packaged/thrift/src/Factory/TCompactProtocolFactory.php b/vendor/packaged/thrift/src/Factory/TCompactProtocolFactory.php new file mode 100644 index 000000000..11fb8ff33 --- /dev/null +++ b/vendor/packaged/thrift/src/Factory/TCompactProtocolFactory.php @@ -0,0 +1,40 @@ +p_ = $p; + } + + public function write() + { + if ($this->first_) { + $this->first_ = false; + } else { + $this->p_->getTransport()->write(TJSONProtocol::COMMA); + } + } + + public function read() + { + if ($this->first_) { + $this->first_ = false; + } else { + $this->p_->readJSONSyntaxChar(TJSONProtocol::COMMA); + } + } +} diff --git a/vendor/packaged/thrift/src/Protocol/JSON/LookaheadReader.php b/vendor/packaged/thrift/src/Protocol/JSON/LookaheadReader.php new file mode 100644 index 000000000..0b18c40d0 --- /dev/null +++ b/vendor/packaged/thrift/src/Protocol/JSON/LookaheadReader.php @@ -0,0 +1,57 @@ +p_ = $p; + } + + public function read() + { + if ($this->hasData_) { + $this->hasData_ = false; + } else { + $this->data_ = $this->p_->getTransport()->readAll(1); + } + + return substr($this->data_, 0, 1); + } + + public function peek() + { + if (!$this->hasData_) { + $this->data_ = $this->p_->getTransport()->readAll(1); + } + + $this->hasData_ = true; + + return substr($this->data_, 0, 1); + } +} diff --git a/vendor/packaged/thrift/src/Protocol/JSON/PairContext.php b/vendor/packaged/thrift/src/Protocol/JSON/PairContext.php new file mode 100644 index 000000000..7b353c4ad --- /dev/null +++ b/vendor/packaged/thrift/src/Protocol/JSON/PairContext.php @@ -0,0 +1,64 @@ +p_ = $p; + } + + public function write() + { + if ($this->first_) { + $this->first_ = false; + $this->colon_ = true; + } else { + $this->p_->getTransport()->write($this->colon_ ? TJSONProtocol::COLON : TJSONProtocol::COMMA); + $this->colon_ = !$this->colon_; + } + } + + public function read() + { + if ($this->first_) { + $this->first_ = false; + $this->colon_ = true; + } else { + $this->p_->readJSONSyntaxChar($this->colon_ ? TJSONProtocol::COLON : TJSONProtocol::COMMA); + $this->colon_ = !$this->colon_; + } + } + + public function escapeNum() + { + return $this->colon_; + } +} diff --git a/vendor/packaged/thrift/src/Protocol/SimpleJSON/CollectionMapKeyException.php b/vendor/packaged/thrift/src/Protocol/SimpleJSON/CollectionMapKeyException.php new file mode 100644 index 000000000..522b85a5b --- /dev/null +++ b/vendor/packaged/thrift/src/Protocol/SimpleJSON/CollectionMapKeyException.php @@ -0,0 +1,33 @@ +p_ = $p; + } + + public function write() + { + if ($this->first_) { + $this->first_ = false; + } else { + $this->p_->getTransport()->write(TSimpleJSONProtocol::COMMA); + } + } +} diff --git a/vendor/packaged/thrift/src/Protocol/SimpleJSON/MapContext.php b/vendor/packaged/thrift/src/Protocol/SimpleJSON/MapContext.php new file mode 100644 index 000000000..61c060d09 --- /dev/null +++ b/vendor/packaged/thrift/src/Protocol/SimpleJSON/MapContext.php @@ -0,0 +1,47 @@ +isKey = !$this->isKey; + } + + public function isMapKey() + { + // we want to coerce map keys to json strings regardless + // of their type + return $this->isKey; + } +} diff --git a/vendor/packaged/thrift/src/Protocol/SimpleJSON/StructContext.php b/vendor/packaged/thrift/src/Protocol/SimpleJSON/StructContext.php new file mode 100644 index 000000000..38a62d1a2 --- /dev/null +++ b/vendor/packaged/thrift/src/Protocol/SimpleJSON/StructContext.php @@ -0,0 +1,52 @@ +p_ = $p; + } + + public function write() + { + if ($this->first_) { + $this->first_ = false; + $this->colon_ = true; + } else { + $this->p_->getTransport()->write( + $this->colon_ ? + TSimpleJSONProtocol::COLON : + TSimpleJSONProtocol::COMMA + ); + $this->colon_ = !$this->colon_; + } + } +} diff --git a/vendor/packaged/thrift/src/Protocol/TBinaryProtocol.php b/vendor/packaged/thrift/src/Protocol/TBinaryProtocol.php new file mode 100644 index 000000000..cda5c0d4c --- /dev/null +++ b/vendor/packaged/thrift/src/Protocol/TBinaryProtocol.php @@ -0,0 +1,453 @@ +strictRead_ = $strictRead; + $this->strictWrite_ = $strictWrite; + } + + public function writeMessageBegin($name, $type, $seqid) + { + if ($this->strictWrite_) { + $version = self::VERSION_1 | $type; + + return + $this->writeI32($version) + + $this->writeString($name) + + $this->writeI32($seqid); + } else { + return + $this->writeString($name) + + $this->writeByte($type) + + $this->writeI32($seqid); + } + } + + public function writeMessageEnd() + { + return 0; + } + + public function writeStructBegin($name) + { + return 0; + } + + public function writeStructEnd() + { + return 0; + } + + public function writeFieldBegin($fieldName, $fieldType, $fieldId) + { + return + $this->writeByte($fieldType) + + $this->writeI16($fieldId); + } + + public function writeFieldEnd() + { + return 0; + } + + public function writeFieldStop() + { + return + $this->writeByte(TType::STOP); + } + + public function writeMapBegin($keyType, $valType, $size) + { + return + $this->writeByte($keyType) + + $this->writeByte($valType) + + $this->writeI32($size); + } + + public function writeMapEnd() + { + return 0; + } + + public function writeListBegin($elemType, $size) + { + return + $this->writeByte($elemType) + + $this->writeI32($size); + } + + public function writeListEnd() + { + return 0; + } + + public function writeSetBegin($elemType, $size) + { + return + $this->writeByte($elemType) + + $this->writeI32($size); + } + + public function writeSetEnd() + { + return 0; + } + + public function writeBool($value) + { + $data = pack('c', $value ? 1 : 0); + $this->trans_->write($data, 1); + + return 1; + } + + public function writeByte($value) + { + $data = pack('c', $value); + $this->trans_->write($data, 1); + + return 1; + } + + public function writeI16($value) + { + $data = pack('n', $value); + $this->trans_->write($data, 2); + + return 2; + } + + public function writeI32($value) + { + $data = pack('N', $value); + $this->trans_->write($data, 4); + + return 4; + } + + public function writeI64($value) + { + // If we are on a 32bit architecture we have to explicitly deal with + // 64-bit twos-complement arithmetic since PHP wants to treat all ints + // as signed and any int over 2^31 - 1 as a float + if (PHP_INT_SIZE == 4) { + $neg = $value < 0; + + if ($neg) { + $value *= -1; + } + + $hi = (int)($value / 4294967296); + $lo = (int)$value; + + if ($neg) { + $hi = ~$hi; + $lo = ~$lo; + if (($lo & (int)0xffffffff) == (int)0xffffffff) { + $lo = 0; + $hi++; + } else { + $lo++; + } + } + $data = pack('N2', $hi, $lo); + } else { + $hi = $value >> 32; + $lo = $value & 0xFFFFFFFF; + $data = pack('N2', $hi, $lo); + } + + $this->trans_->write($data, 8); + + return 8; + } + + public function writeDouble($value) + { + $data = pack('d', $value); + $this->trans_->write(strrev($data), 8); + + return 8; + } + + public function writeString($value) + { + $len = TStringFuncFactory::create()->strlen($value); + $result = $this->writeI32($len); + if ($len) { + $this->trans_->write($value, $len); + } + + return $result + $len; + } + + public function readMessageBegin(&$name, &$type, &$seqid) + { + $result = $this->readI32($sz); + if ($sz < 0) { + $version = (int)($sz & self::VERSION_MASK); + if ($version != (int)self::VERSION_1) { + throw new TProtocolException('Bad version identifier: ' . $sz, TProtocolException::BAD_VERSION); + } + $type = $sz & 0x000000ff; + $result += + $this->readString($name) + + $this->readI32($seqid); + } else { + if ($this->strictRead_) { + throw new TProtocolException( + 'No version identifier, old protocol client?', + TProtocolException::BAD_VERSION + ); + } else { + // Handle pre-versioned input + $name = $this->trans_->readAll($sz); + $result += + $sz + + $this->readByte($type) + + $this->readI32($seqid); + } + } + + return $result; + } + + public function readMessageEnd() + { + return 0; + } + + public function readStructBegin(&$name) + { + $name = ''; + + return 0; + } + + public function readStructEnd() + { + return 0; + } + + public function readFieldBegin(&$name, &$fieldType, &$fieldId) + { + $result = $this->readByte($fieldType); + if ($fieldType == TType::STOP) { + $fieldId = 0; + + return $result; + } + $result += $this->readI16($fieldId); + + return $result; + } + + public function readFieldEnd() + { + return 0; + } + + public function readMapBegin(&$keyType, &$valType, &$size) + { + return + $this->readByte($keyType) + + $this->readByte($valType) + + $this->readI32($size); + } + + public function readMapEnd() + { + return 0; + } + + public function readListBegin(&$elemType, &$size) + { + return + $this->readByte($elemType) + + $this->readI32($size); + } + + public function readListEnd() + { + return 0; + } + + public function readSetBegin(&$elemType, &$size) + { + return + $this->readByte($elemType) + + $this->readI32($size); + } + + public function readSetEnd() + { + return 0; + } + + public function readBool(&$value) + { + $data = $this->trans_->readAll(1); + $arr = unpack('c', $data); + $value = $arr[1] == 1; + + return 1; + } + + public function readByte(&$value) + { + $data = $this->trans_->readAll(1); + $arr = unpack('c', $data); + $value = $arr[1]; + + return 1; + } + + public function readI16(&$value) + { + $data = $this->trans_->readAll(2); + $arr = unpack('n', $data); + $value = $arr[1]; + if ($value > 0x7fff) { + $value = 0 - (($value - 1) ^ 0xffff); + } + + return 2; + } + + public function readI32(&$value) + { + $data = $this->trans_->readAll(4); + $arr = unpack('N', $data); + $value = $arr[1]; + if ($value > 0x7fffffff) { + $value = 0 - (($value - 1) ^ 0xffffffff); + } + + return 4; + } + + public function readI64(&$value) + { + $data = $this->trans_->readAll(8); + + $arr = unpack('N2', $data); + + // If we are on a 32bit architecture we have to explicitly deal with + // 64-bit twos-complement arithmetic since PHP wants to treat all ints + // as signed and any int over 2^31 - 1 as a float + if (PHP_INT_SIZE == 4) { + $hi = $arr[1]; + $lo = $arr[2]; + $isNeg = $hi < 0; + + // Check for a negative + if ($isNeg) { + $hi = ~$hi & (int)0xffffffff; + $lo = ~$lo & (int)0xffffffff; + + if ($lo == (int)0xffffffff) { + $hi++; + $lo = 0; + } else { + $lo++; + } + } + + // Force 32bit words in excess of 2G to pe positive - we deal wigh sign + // explicitly below + + if ($hi & (int)0x80000000) { + $hi &= (int)0x7fffffff; + $hi += 0x80000000; + } + + if ($lo & (int)0x80000000) { + $lo &= (int)0x7fffffff; + $lo += 0x80000000; + } + + $value = $hi * 4294967296 + $lo; + + if ($isNeg) { + $value = 0 - $value; + } + } else { + // Upcast negatives in LSB bit + if ($arr[2] & 0x80000000) { + $arr[2] = $arr[2] & 0xffffffff; + } + + // Check for a negative + if ($arr[1] & 0x80000000) { + $arr[1] = $arr[1] & 0xffffffff; + $arr[1] = $arr[1] ^ 0xffffffff; + $arr[2] = $arr[2] ^ 0xffffffff; + $value = 0 - $arr[1] * 4294967296 - $arr[2] - 1; + } else { + $value = $arr[1] * 4294967296 + $arr[2]; + } + } + + return 8; + } + + public function readDouble(&$value) + { + $data = strrev($this->trans_->readAll(8)); + $arr = unpack('d', $data); + $value = $arr[1]; + + return 8; + } + + public function readString(&$value) + { + $result = $this->readI32($len); + if ($len) { + $value = $this->trans_->readAll($len); + } else { + $value = ''; + } + + return $result + $len; + } +} diff --git a/vendor/packaged/thrift/src/Protocol/TBinaryProtocolAccelerated.php b/vendor/packaged/thrift/src/Protocol/TBinaryProtocolAccelerated.php new file mode 100644 index 000000000..ff799a6ab --- /dev/null +++ b/vendor/packaged/thrift/src/Protocol/TBinaryProtocolAccelerated.php @@ -0,0 +1,67 @@ +strictRead_; + } + + public function isStrictWrite() + { + return $this->strictWrite_; + } +} diff --git a/vendor/packaged/thrift/src/Protocol/TCompactProtocol.php b/vendor/packaged/thrift/src/Protocol/TCompactProtocol.php new file mode 100644 index 000000000..1af2a274a --- /dev/null +++ b/vendor/packaged/thrift/src/Protocol/TCompactProtocol.php @@ -0,0 +1,739 @@ + TCompactProtocol::COMPACT_STOP, + TType::BOOL => TCompactProtocol::COMPACT_TRUE, // used for collection + TType::BYTE => TCompactProtocol::COMPACT_BYTE, + TType::I16 => TCompactProtocol::COMPACT_I16, + TType::I32 => TCompactProtocol::COMPACT_I32, + TType::I64 => TCompactProtocol::COMPACT_I64, + TType::DOUBLE => TCompactProtocol::COMPACT_DOUBLE, + TType::STRING => TCompactProtocol::COMPACT_BINARY, + TType::STRUCT => TCompactProtocol::COMPACT_STRUCT, + TType::LST => TCompactProtocol::COMPACT_LIST, + TType::SET => TCompactProtocol::COMPACT_SET, + TType::MAP => TCompactProtocol::COMPACT_MAP, + ); + + protected static $ttypes = array( + TCompactProtocol::COMPACT_STOP => TType::STOP, + TCompactProtocol::COMPACT_TRUE => TType::BOOL, // used for collection + TCompactProtocol::COMPACT_FALSE => TType::BOOL, + TCompactProtocol::COMPACT_BYTE => TType::BYTE, + TCompactProtocol::COMPACT_I16 => TType::I16, + TCompactProtocol::COMPACT_I32 => TType::I32, + TCompactProtocol::COMPACT_I64 => TType::I64, + TCompactProtocol::COMPACT_DOUBLE => TType::DOUBLE, + TCompactProtocol::COMPACT_BINARY => TType::STRING, + TCompactProtocol::COMPACT_STRUCT => TType::STRUCT, + TCompactProtocol::COMPACT_LIST => TType::LST, + TCompactProtocol::COMPACT_SET => TType::SET, + TCompactProtocol::COMPACT_MAP => TType::MAP, + ); + + protected $state = TCompactProtocol::STATE_CLEAR; + protected $lastFid = 0; + protected $boolFid = null; + protected $boolValue = null; + protected $structs = array(); + protected $containers = array(); + + // Some varint / zigzag helper methods + public function toZigZag($n, $bits) + { + return ($n << 1) ^ ($n >> ($bits - 1)); + } + + public function fromZigZag($n) + { + return ($n >> 1) ^ -($n & 1); + } + + public function getVarint($data) + { + $out = ""; + while (true) { + if (($data & ~0x7f) === 0) { + $out .= chr($data); + break; + } else { + $out .= chr(($data & 0xff) | 0x80); + $data = $data >> 7; + } + } + + return $out; + } + + public function writeVarint($data) + { + $out = $this->getVarint($data); + $result = TStringFuncFactory::create()->strlen($out); + $this->trans_->write($out, $result); + + return $result; + } + + public function readVarint(&$result) + { + $idx = 0; + $shift = 0; + $result = 0; + while (true) { + $x = $this->trans_->readAll(1); + $arr = unpack('C', $x); + $byte = $arr[1]; + $idx += 1; + $result |= ($byte & 0x7f) << $shift; + if (($byte >> 7) === 0) { + return $idx; + } + $shift += 7; + } + + return $idx; + } + + public function __construct($trans) + { + parent::__construct($trans); + } + + public function writeMessageBegin($name, $type, $seqid) + { + $written = + $this->writeUByte(TCompactProtocol::PROTOCOL_ID) + + $this->writeUByte(TCompactProtocol::VERSION | + ($type << TCompactProtocol::TYPE_SHIFT_AMOUNT)) + + $this->writeVarint($seqid) + + $this->writeString($name); + $this->state = TCompactProtocol::STATE_VALUE_WRITE; + + return $written; + } + + public function writeMessageEnd() + { + $this->state = TCompactProtocol::STATE_CLEAR; + + return 0; + } + + public function writeStructBegin($name) + { + $this->structs[] = array($this->state, $this->lastFid); + $this->state = TCompactProtocol::STATE_FIELD_WRITE; + $this->lastFid = 0; + + return 0; + } + + public function writeStructEnd() + { + $old_values = array_pop($this->structs); + $this->state = $old_values[0]; + $this->lastFid = $old_values[1]; + + return 0; + } + + public function writeFieldStop() + { + return $this->writeByte(0); + } + + public function writeFieldHeader($type, $fid) + { + $written = 0; + $delta = $fid - $this->lastFid; + if (0 < $delta && $delta <= 15) { + $written = $this->writeUByte(($delta << 4) | $type); + } else { + $written = $this->writeByte($type) + + $this->writeI16($fid); + } + $this->lastFid = $fid; + + return $written; + } + + public function writeFieldBegin($field_name, $field_type, $field_id) + { + if ($field_type == TTYPE::BOOL) { + $this->state = TCompactProtocol::STATE_BOOL_WRITE; + $this->boolFid = $field_id; + + return 0; + } else { + $this->state = TCompactProtocol::STATE_VALUE_WRITE; + + return $this->writeFieldHeader(self::$ctypes[$field_type], $field_id); + } + } + + public function writeFieldEnd() + { + $this->state = TCompactProtocol::STATE_FIELD_WRITE; + + return 0; + } + + public function writeCollectionBegin($etype, $size) + { + $written = 0; + if ($size <= 14) { + $written = $this->writeUByte($size << 4 | + self::$ctypes[$etype]); + } else { + $written = $this->writeUByte(0xf0 | + self::$ctypes[$etype]) + + $this->writeVarint($size); + } + $this->containers[] = $this->state; + $this->state = TCompactProtocol::STATE_CONTAINER_WRITE; + + return $written; + } + + public function writeMapBegin($key_type, $val_type, $size) + { + $written = 0; + if ($size == 0) { + $written = $this->writeByte(0); + } else { + $written = $this->writeVarint($size) + + $this->writeUByte(self::$ctypes[$key_type] << 4 | + self::$ctypes[$val_type]); + } + $this->containers[] = $this->state; + + return $written; + } + + public function writeCollectionEnd() + { + $this->state = array_pop($this->containers); + + return 0; + } + + public function writeMapEnd() + { + return $this->writeCollectionEnd(); + } + + public function writeListBegin($elem_type, $size) + { + return $this->writeCollectionBegin($elem_type, $size); + } + + public function writeListEnd() + { + return $this->writeCollectionEnd(); + } + + public function writeSetBegin($elem_type, $size) + { + return $this->writeCollectionBegin($elem_type, $size); + } + + public function writeSetEnd() + { + return $this->writeCollectionEnd(); + } + + public function writeBool($value) + { + if ($this->state == TCompactProtocol::STATE_BOOL_WRITE) { + $ctype = TCompactProtocol::COMPACT_FALSE; + if ($value) { + $ctype = TCompactProtocol::COMPACT_TRUE; + } + + return $this->writeFieldHeader($ctype, $this->boolFid); + } elseif ($this->state == TCompactProtocol::STATE_CONTAINER_WRITE) { + return $this->writeByte($value ? 1 : 0); + } else { + throw new TProtocolException('Invalid state in compact protocol'); + } + } + + public function writeByte($value) + { + $data = pack('c', $value); + $this->trans_->write($data, 1); + + return 1; + } + + public function writeUByte($byte) + { + $this->trans_->write(pack('C', $byte), 1); + + return 1; + } + + public function writeI16($value) + { + $thing = $this->toZigZag($value, 16); + + return $this->writeVarint($thing); + } + + public function writeI32($value) + { + $thing = $this->toZigZag($value, 32); + + return $this->writeVarint($thing); + } + + public function writeDouble($value) + { + $data = pack('d', $value); + $this->trans_->write($data, 8); + + return 8; + } + + public function writeString($value) + { + $len = TStringFuncFactory::create()->strlen($value); + $result = $this->writeVarint($len); + if ($len) { + $this->trans_->write($value, $len); + } + + return $result + $len; + } + + public function readFieldBegin(&$name, &$field_type, &$field_id) + { + $result = $this->readUByte($compact_type_and_delta); + + $compact_type = $compact_type_and_delta & 0x0f; + + if ($compact_type == TType::STOP) { + $field_type = $compact_type; + $field_id = 0; + + return $result; + } + $delta = $compact_type_and_delta >> 4; + if ($delta == 0) { + $result += $this->readI16($field_id); + } else { + $field_id = $this->lastFid + $delta; + } + $this->lastFid = $field_id; + $field_type = $this->getTType($compact_type); + + if ($compact_type == TCompactProtocol::COMPACT_TRUE) { + $this->state = TCompactProtocol::STATE_BOOL_READ; + $this->boolValue = true; + } elseif ($compact_type == TCompactProtocol::COMPACT_FALSE) { + $this->state = TCompactProtocol::STATE_BOOL_READ; + $this->boolValue = false; + } else { + $this->state = TCompactProtocol::STATE_VALUE_READ; + } + + return $result; + } + + public function readFieldEnd() + { + $this->state = TCompactProtocol::STATE_FIELD_READ; + + return 0; + } + + public function readUByte(&$value) + { + $data = $this->trans_->readAll(1); + $arr = unpack('C', $data); + $value = $arr[1]; + + return 1; + } + + public function readByte(&$value) + { + $data = $this->trans_->readAll(1); + $arr = unpack('c', $data); + $value = $arr[1]; + + return 1; + } + + public function readZigZag(&$value) + { + $result = $this->readVarint($value); + $value = $this->fromZigZag($value); + + return $result; + } + + public function readMessageBegin(&$name, &$type, &$seqid) + { + $protoId = 0; + $result = $this->readUByte($protoId); + if ($protoId != TCompactProtocol::PROTOCOL_ID) { + throw new TProtocolException('Bad protocol id in TCompact message'); + } + $verType = 0; + $result += $this->readUByte($verType); + $type = ($verType >> TCompactProtocol::TYPE_SHIFT_AMOUNT) & TCompactProtocol::TYPE_BITS; + $version = $verType & TCompactProtocol::VERSION_MASK; + if ($version != TCompactProtocol::VERSION) { + throw new TProtocolException('Bad version in TCompact message'); + } + $result += $this->readVarint($seqid); + $result += $this->readString($name); + + return $result; + } + + public function readMessageEnd() + { + return 0; + } + + public function readStructBegin(&$name) + { + $name = ''; // unused + $this->structs[] = array($this->state, $this->lastFid); + $this->state = TCompactProtocol::STATE_FIELD_READ; + $this->lastFid = 0; + + return 0; + } + + public function readStructEnd() + { + $last = array_pop($this->structs); + $this->state = $last[0]; + $this->lastFid = $last[1]; + + return 0; + } + + public function readCollectionBegin(&$type, &$size) + { + $sizeType = 0; + $result = $this->readUByte($sizeType); + $size = $sizeType >> 4; + $type = $this->getTType($sizeType); + if ($size == 15) { + $result += $this->readVarint($size); + } + $this->containers[] = $this->state; + $this->state = TCompactProtocol::STATE_CONTAINER_READ; + + return $result; + } + + public function readMapBegin(&$key_type, &$val_type, &$size) + { + $result = $this->readVarint($size); + $types = 0; + if ($size > 0) { + $result += $this->readUByte($types); + } + $val_type = $this->getTType($types); + $key_type = $this->getTType($types >> 4); + $this->containers[] = $this->state; + $this->state = TCompactProtocol::STATE_CONTAINER_READ; + + return $result; + } + + public function readCollectionEnd() + { + $this->state = array_pop($this->containers); + + return 0; + } + + public function readMapEnd() + { + return $this->readCollectionEnd(); + } + + public function readListBegin(&$elem_type, &$size) + { + return $this->readCollectionBegin($elem_type, $size); + } + + public function readListEnd() + { + return $this->readCollectionEnd(); + } + + public function readSetBegin(&$elem_type, &$size) + { + return $this->readCollectionBegin($elem_type, $size); + } + + public function readSetEnd() + { + return $this->readCollectionEnd(); + } + + public function readBool(&$value) + { + if ($this->state == TCompactProtocol::STATE_BOOL_READ) { + $value = $this->boolValue; + + return 0; + } elseif ($this->state == TCompactProtocol::STATE_CONTAINER_READ) { + return $this->readByte($value); + } else { + throw new TProtocolException('Invalid state in compact protocol'); + } + } + + public function readI16(&$value) + { + return $this->readZigZag($value); + } + + public function readI32(&$value) + { + return $this->readZigZag($value); + } + + public function readDouble(&$value) + { + $data = $this->trans_->readAll(8); + $arr = unpack('d', $data); + $value = $arr[1]; + + return 8; + } + + public function readString(&$value) + { + $result = $this->readVarint($len); + if ($len) { + $value = $this->trans_->readAll($len); + } else { + $value = ''; + } + + return $result + $len; + } + + public function getTType($byte) + { + return self::$ttypes[$byte & 0x0f]; + } + + // If we are on a 32bit architecture we have to explicitly deal with + // 64-bit twos-complement arithmetic since PHP wants to treat all ints + // as signed and any int over 2^31 - 1 as a float + + // Read and write I64 as two 32 bit numbers $hi and $lo + + public function readI64(&$value) + { + // Read varint from wire + $hi = 0; + $lo = 0; + + $idx = 0; + $shift = 0; + + while (true) { + $x = $this->trans_->readAll(1); + $arr = unpack('C', $x); + $byte = $arr[1]; + $idx += 1; + // Shift hi and lo together. + if ($shift < 28) { + $lo |= (($byte & 0x7f) << $shift); + } elseif ($shift == 28) { + $lo |= (($byte & 0x0f) << 28); + $hi |= (($byte & 0x70) >> 4); + } else { + $hi |= (($byte & 0x7f) << ($shift - 32)); + } + if (($byte >> 7) === 0) { + break; + } + $shift += 7; + } + + // Now, unzig it. + $xorer = 0; + if ($lo & 1) { + $xorer = 0xffffffff; + } + $lo = ($lo >> 1) & 0x7fffffff; + $lo = $lo | (($hi & 1) << 31); + $hi = ($hi >> 1) ^ $xorer; + $lo = $lo ^ $xorer; + + // Now put $hi and $lo back together + $isNeg = $hi < 0 || $hi & 0x80000000; + + // Check for a negative + if ($isNeg) { + $hi = ~$hi & (int)0xffffffff; + $lo = ~$lo & (int)0xffffffff; + + if ($lo == (int)0xffffffff) { + $hi++; + $lo = 0; + } else { + $lo++; + } + } + + // Force 32bit words in excess of 2G to be positive - we deal with sign + // explicitly below + + if ($hi & (int)0x80000000) { + $hi &= (int)0x7fffffff; + $hi += 0x80000000; + } + + if ($lo & (int)0x80000000) { + $lo &= (int)0x7fffffff; + $lo += 0x80000000; + } + + // Create as negative value first, since we can store -2^63 but not 2^63 + $value = -$hi * 4294967296 - $lo; + + if (!$isNeg) { + $value = -$value; + } + + return $idx; + } + + public function writeI64($value) + { + // If we are in an I32 range, use the easy method below. + if (($value > 4294967296) || ($value < -4294967296)) { + // Convert $value to $hi and $lo + $neg = $value < 0; + + if ($neg) { + $value *= -1; + } + + $hi = (int)$value >> 32; + $lo = (int)$value & 0xffffffff; + + if ($neg) { + $hi = ~$hi; + $lo = ~$lo; + if (($lo & (int)0xffffffff) == (int)0xffffffff) { + $lo = 0; + $hi++; + } else { + $lo++; + } + } + + // Now do the zigging and zagging. + $xorer = 0; + if ($neg) { + $xorer = 0xffffffff; + } + $lowbit = ($lo >> 31) & 1; + $hi = ($hi << 1) | $lowbit; + $lo = ($lo << 1); + $lo = ($lo ^ $xorer) & 0xffffffff; + $hi = ($hi ^ $xorer) & 0xffffffff; + + // now write out the varint, ensuring we shift both hi and lo + $out = ""; + while (true) { + if (($lo & ~0x7f) === 0 && + $hi === 0) { + $out .= chr($lo); + break; + } else { + $out .= chr(($lo & 0xff) | 0x80); + $lo = $lo >> 7; + $lo = $lo | ($hi << 25); + $hi = $hi >> 7; + // Right shift carries sign, but we don't want it to. + $hi = $hi & (127 << 25); + } + } + + $ret = TStringFuncFactory::create()->strlen($out); + $this->trans_->write($out, $ret); + + return $ret; + } else { + return $this->writeVarint($this->toZigZag($value, 64)); + } + } +} diff --git a/vendor/packaged/thrift/src/Protocol/TJSONProtocol.php b/vendor/packaged/thrift/src/Protocol/TJSONProtocol.php new file mode 100644 index 000000000..914488421 --- /dev/null +++ b/vendor/packaged/thrift/src/Protocol/TJSONProtocol.php @@ -0,0 +1,815 @@ + 1) { + switch (substr($name, 0, 1)) { + case 'd': + $result = TType::DOUBLE; + break; + case 'i': + switch (substr($name, 1, 1)) { + case '8': + $result = TType::BYTE; + break; + case '1': + $result = TType::I16; + break; + case '3': + $result = TType::I32; + break; + case '6': + $result = TType::I64; + break; + } + break; + case 'l': + $result = TType::LST; + break; + case 'm': + $result = TType::MAP; + break; + case 'r': + $result = TType::STRUCT; + break; + case 's': + if (substr($name, 1, 1) == 't') { + $result = TType::STRING; + } elseif (substr($name, 1, 1) == 'e') { + $result = TType::SET; + } + break; + case 't': + $result = TType::BOOL; + break; + } + } + if ($result == TType::STOP) { + throw new TProtocolException("Unrecognized type", TProtocolException::INVALID_DATA); + } + + return $result; + } + + public $contextStack_ = array(); + public $context_; + public $reader_; + + private function pushContext($c) + { + array_push($this->contextStack_, $this->context_); + $this->context_ = $c; + } + + private function popContext() + { + $this->context_ = array_pop($this->contextStack_); + } + + public function __construct($trans) + { + parent::__construct($trans); + $this->context_ = new BaseContext(); + $this->reader_ = new LookaheadReader($this); + } + + public function reset() + { + $this->contextStack_ = array(); + $this->context_ = new BaseContext(); + $this->reader_ = new LookaheadReader($this); + } + + private $tmpbuf_ = array(4); + + public function readJSONSyntaxChar($b) + { + $ch = $this->reader_->read(); + + if (substr($ch, 0, 1) != $b) { + throw new TProtocolException("Unexpected character: " . $ch, TProtocolException::INVALID_DATA); + } + } + + private function hexVal($s) + { + for ($i = 0; $i < strlen($s); $i++) { + $ch = substr($s, $i, 1); + + if (!($ch >= "a" && $ch <= "f") && !($ch >= "0" && $ch <= "9")) { + throw new TProtocolException("Expected hex character " . $ch, TProtocolException::INVALID_DATA); + } + } + + return hexdec($s); + } + + private function hexChar($val) + { + return dechex($val); + } + + private function hasJSONUnescapedUnicode() + { + if (PHP_MAJOR_VERSION > 5 || (PHP_MAJOR_VERSION == 5 && PHP_MINOR_VERSION >= 4)) { + return true; + } + + return false; + } + + private function unescapedUnicode($str) + { + if ($this->hasJSONUnescapedUnicode()) { + return json_encode($str, JSON_UNESCAPED_UNICODE); + } + + $json = json_encode($str); + + /* + * Unescaped character outside the Basic Multilingual Plane + * High surrogate: 0xD800 - 0xDBFF + * Low surrogate: 0xDC00 - 0xDFFF + */ + $json = preg_replace_callback( + '/\\\\u(d[89ab][0-9a-f]{2})\\\\u(d[cdef][0-9a-f]{2})/i', + function ($matches) { + return mb_convert_encoding(pack('H*', $matches[1] . $matches[2]), 'UTF-8', 'UTF-16BE'); + }, + $json + ); + + /* + * Unescaped characters within the Basic Multilingual Plane + */ + $json = preg_replace_callback( + '/\\\\u([0-9a-f]{4})/i', + function ($matches) { + return mb_convert_encoding(pack('H*', $matches[1]), 'UTF-8', 'UTF-16BE'); + }, + $json + ); + + return $json; + } + + private function writeJSONString($b) + { + $this->context_->write(); + + if (is_numeric($b) && $this->context_->escapeNum()) { + $this->trans_->write(self::QUOTE); + } + + $this->trans_->write($this->unescapedUnicode($b)); + + if (is_numeric($b) && $this->context_->escapeNum()) { + $this->trans_->write(self::QUOTE); + } + } + + private function writeJSONInteger($num) + { + $this->context_->write(); + + if ($this->context_->escapeNum()) { + $this->trans_->write(self::QUOTE); + } + + $this->trans_->write($num); + + if ($this->context_->escapeNum()) { + $this->trans_->write(self::QUOTE); + } + } + + private function writeJSONDouble($num) + { + $this->context_->write(); + + if ($this->context_->escapeNum()) { + $this->trans_->write(self::QUOTE); + } + + $this->trans_->write(json_encode($num)); + + if ($this->context_->escapeNum()) { + $this->trans_->write(self::QUOTE); + } + } + + private function writeJSONBase64($data) + { + $this->context_->write(); + $this->trans_->write(self::QUOTE); + $this->trans_->write(json_encode(base64_encode($data))); + $this->trans_->write(self::QUOTE); + } + + private function writeJSONObjectStart() + { + $this->context_->write(); + $this->trans_->write(self::LBRACE); + $this->pushContext(new PairContext($this)); + } + + private function writeJSONObjectEnd() + { + $this->popContext(); + $this->trans_->write(self::RBRACE); + } + + private function writeJSONArrayStart() + { + $this->context_->write(); + $this->trans_->write(self::LBRACKET); + $this->pushContext(new ListContext($this)); + } + + private function writeJSONArrayEnd() + { + $this->popContext(); + $this->trans_->write(self::RBRACKET); + } + + private function readJSONString($skipContext) + { + if (!$skipContext) { + $this->context_->read(); + } + + $jsonString = ''; + $lastChar = null; + while (true) { + $ch = $this->reader_->read(); + $jsonString .= $ch; + if ($ch == self::QUOTE && + $lastChar !== null && + $lastChar !== self::ESCSEQ) { + break; + } + if ($ch == self::ESCSEQ && $lastChar == self::ESCSEQ) { + $lastChar = self::DOUBLEESC; + } else { + $lastChar = $ch; + } + } + + return json_decode($jsonString); + } + + private function isJSONNumeric($b) + { + switch ($b) { + case '+': + case '-': + case '.': + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'E': + case 'e': + return true; + } + + return false; + } + + private function readJSONNumericChars() + { + $strbld = array(); + + while (true) { + $ch = $this->reader_->peek(); + + if (!$this->isJSONNumeric($ch)) { + break; + } + + $strbld[] = $this->reader_->read(); + } + + return implode("", $strbld); + } + + private function readJSONInteger() + { + $this->context_->read(); + + if ($this->context_->escapeNum()) { + $this->readJSONSyntaxChar(self::QUOTE); + } + + $str = $this->readJSONNumericChars(); + + if ($this->context_->escapeNum()) { + $this->readJSONSyntaxChar(self::QUOTE); + } + + if (!is_numeric($str)) { + throw new TProtocolException("Invalid data in numeric: " . $str, TProtocolException::INVALID_DATA); + } + + return intval($str); + } + + /** + * Identical to readJSONInteger but without the final cast. + * Needed for proper handling of i64 on 32 bit machines. Why a + * separate function? So we don't have to force the rest of the + * use cases through the extra conditional. + */ + private function readJSONIntegerAsString() + { + $this->context_->read(); + + if ($this->context_->escapeNum()) { + $this->readJSONSyntaxChar(self::QUOTE); + } + + $str = $this->readJSONNumericChars(); + + if ($this->context_->escapeNum()) { + $this->readJSONSyntaxChar(self::QUOTE); + } + + if (!is_numeric($str)) { + throw new TProtocolException("Invalid data in numeric: " . $str, TProtocolException::INVALID_DATA); + } + + return $str; + } + + private function readJSONDouble() + { + $this->context_->read(); + + if (substr($this->reader_->peek(), 0, 1) == self::QUOTE) { + $arr = $this->readJSONString(true); + + if ($arr == "NaN") { + return NAN; + } elseif ($arr == "Infinity") { + return INF; + } elseif (!$this->context_->escapeNum()) { + throw new TProtocolException( + "Numeric data unexpectedly quoted " . $arr, + TProtocolException::INVALID_DATA + ); + } + + return floatval($arr); + } else { + if ($this->context_->escapeNum()) { + $this->readJSONSyntaxChar(self::QUOTE); + } + + return floatval($this->readJSONNumericChars()); + } + } + + private function readJSONBase64() + { + $arr = $this->readJSONString(false); + $data = base64_decode($arr, true); + + if ($data === false) { + throw new TProtocolException("Invalid base64 data " . $arr, TProtocolException::INVALID_DATA); + } + + return $data; + } + + private function readJSONObjectStart() + { + $this->context_->read(); + $this->readJSONSyntaxChar(self::LBRACE); + $this->pushContext(new PairContext($this)); + } + + private function readJSONObjectEnd() + { + $this->readJSONSyntaxChar(self::RBRACE); + $this->popContext(); + } + + private function readJSONArrayStart() + { + $this->context_->read(); + $this->readJSONSyntaxChar(self::LBRACKET); + $this->pushContext(new ListContext($this)); + } + + private function readJSONArrayEnd() + { + $this->readJSONSyntaxChar(self::RBRACKET); + $this->popContext(); + } + + /** + * Writes the message header + * + * @param string $name Function name + * @param int $type message type TMessageType::CALL or TMessageType::REPLY + * @param int $seqid The sequence id of this message + */ + public function writeMessageBegin($name, $type, $seqid) + { + $this->writeJSONArrayStart(); + $this->writeJSONInteger(self::VERSION); + $this->writeJSONString($name); + $this->writeJSONInteger($type); + $this->writeJSONInteger($seqid); + } + + /** + * Close the message + */ + public function writeMessageEnd() + { + $this->writeJSONArrayEnd(); + } + + /** + * Writes a struct header. + * + * @param string $name Struct name + * @throws TException on write error + * @return int How many bytes written + */ + public function writeStructBegin($name) + { + $this->writeJSONObjectStart(); + } + + /** + * Close a struct. + * + * @throws TException on write error + * @return int How many bytes written + */ + public function writeStructEnd() + { + $this->writeJSONObjectEnd(); + } + + public function writeFieldBegin($fieldName, $fieldType, $fieldId) + { + $this->writeJSONInteger($fieldId); + $this->writeJSONObjectStart(); + $this->writeJSONString($this->getTypeNameForTypeID($fieldType)); + } + + public function writeFieldEnd() + { + $this->writeJsonObjectEnd(); + } + + public function writeFieldStop() + { + } + + public function writeMapBegin($keyType, $valType, $size) + { + $this->writeJSONArrayStart(); + $this->writeJSONString($this->getTypeNameForTypeID($keyType)); + $this->writeJSONString($this->getTypeNameForTypeID($valType)); + $this->writeJSONInteger($size); + $this->writeJSONObjectStart(); + } + + public function writeMapEnd() + { + $this->writeJSONObjectEnd(); + $this->writeJSONArrayEnd(); + } + + public function writeListBegin($elemType, $size) + { + $this->writeJSONArrayStart(); + $this->writeJSONString($this->getTypeNameForTypeID($elemType)); + $this->writeJSONInteger($size); + } + + public function writeListEnd() + { + $this->writeJSONArrayEnd(); + } + + public function writeSetBegin($elemType, $size) + { + $this->writeJSONArrayStart(); + $this->writeJSONString($this->getTypeNameForTypeID($elemType)); + $this->writeJSONInteger($size); + } + + public function writeSetEnd() + { + $this->writeJSONArrayEnd(); + } + + public function writeBool($bool) + { + $this->writeJSONInteger($bool ? 1 : 0); + } + + public function writeByte($byte) + { + $this->writeJSONInteger($byte); + } + + public function writeI16($i16) + { + $this->writeJSONInteger($i16); + } + + public function writeI32($i32) + { + $this->writeJSONInteger($i32); + } + + public function writeI64($i64) + { + $this->writeJSONInteger($i64); + } + + public function writeDouble($dub) + { + $this->writeJSONDouble($dub); + } + + public function writeString($str) + { + $this->writeJSONString($str); + } + + /** + * Reads the message header + * + * @param string $name Function name + * @param int $type message type TMessageType::CALL or TMessageType::REPLY + * @parem int $seqid The sequence id of this message + */ + public function readMessageBegin(&$name, &$type, &$seqid) + { + $this->readJSONArrayStart(); + + if ($this->readJSONInteger() != self::VERSION) { + throw new TProtocolException("Message contained bad version", TProtocolException::BAD_VERSION); + } + + $name = $this->readJSONString(false); + $type = $this->readJSONInteger(); + $seqid = $this->readJSONInteger(); + + return true; + } + + /** + * Read the close of message + */ + public function readMessageEnd() + { + $this->readJSONArrayEnd(); + } + + public function readStructBegin(&$name) + { + $this->readJSONObjectStart(); + + return 0; + } + + public function readStructEnd() + { + $this->readJSONObjectEnd(); + } + + public function readFieldBegin(&$name, &$fieldType, &$fieldId) + { + $ch = $this->reader_->peek(); + $name = ""; + + if (substr($ch, 0, 1) == self::RBRACE) { + $fieldType = TType::STOP; + } else { + $fieldId = $this->readJSONInteger(); + $this->readJSONObjectStart(); + $fieldType = $this->getTypeIDForTypeName($this->readJSONString(false)); + } + } + + public function readFieldEnd() + { + $this->readJSONObjectEnd(); + } + + public function readMapBegin(&$keyType, &$valType, &$size) + { + $this->readJSONArrayStart(); + $keyType = $this->getTypeIDForTypeName($this->readJSONString(false)); + $valType = $this->getTypeIDForTypeName($this->readJSONString(false)); + $size = $this->readJSONInteger(); + $this->readJSONObjectStart(); + } + + public function readMapEnd() + { + $this->readJSONObjectEnd(); + $this->readJSONArrayEnd(); + } + + public function readListBegin(&$elemType, &$size) + { + $this->readJSONArrayStart(); + $elemType = $this->getTypeIDForTypeName($this->readJSONString(false)); + $size = $this->readJSONInteger(); + + return true; + } + + public function readListEnd() + { + $this->readJSONArrayEnd(); + } + + public function readSetBegin(&$elemType, &$size) + { + $this->readJSONArrayStart(); + $elemType = $this->getTypeIDForTypeName($this->readJSONString(false)); + $size = $this->readJSONInteger(); + + return true; + } + + public function readSetEnd() + { + $this->readJSONArrayEnd(); + } + + public function readBool(&$bool) + { + $bool = $this->readJSONInteger() == 0 ? false : true; + + return true; + } + + public function readByte(&$byte) + { + $byte = $this->readJSONInteger(); + + return true; + } + + public function readI16(&$i16) + { + $i16 = $this->readJSONInteger(); + + return true; + } + + public function readI32(&$i32) + { + $i32 = $this->readJSONInteger(); + + return true; + } + + public function readI64(&$i64) + { + if (PHP_INT_SIZE === 4) { + $i64 = $this->readJSONIntegerAsString(); + } else { + $i64 = $this->readJSONInteger(); + } + + return true; + } + + public function readDouble(&$dub) + { + $dub = $this->readJSONDouble(); + + return true; + } + + public function readString(&$str) + { + $str = $this->readJSONString(false); + + return true; + } +} diff --git a/vendor/packaged/thrift/src/Protocol/TMultiplexedProtocol.php b/vendor/packaged/thrift/src/Protocol/TMultiplexedProtocol.php new file mode 100644 index 000000000..d579c099d --- /dev/null +++ b/vendor/packaged/thrift/src/Protocol/TMultiplexedProtocol.php @@ -0,0 +1,85 @@ +TMultiplexedProtocol is a protocol-independent concrete decorator + * that allows a Thrift client to communicate with a multiplexing Thrift server, + * by prepending the service name to the function name during function calls. + * + * @package Thrift\Protocol + */ +class TMultiplexedProtocol extends TProtocolDecorator +{ + /** + * Separator between service name and function name. + * Should be the same as used at multiplexed Thrift server. + * + * @var string + */ + const SEPARATOR = ":"; + + /** + * The name of service. + * + * @var string + */ + private $serviceName_; + + /** + * Constructor of TMultiplexedProtocol class. + * + * Wrap the specified protocol, allowing it to be used to communicate with a + * multiplexing server. The $serviceName is required as it is + * prepended to the message header so that the multiplexing server can broker + * the function call to the proper service. + * + * @param TProtocol $protocol + * @param string $serviceName The name of service. + */ + public function __construct(TProtocol $protocol, $serviceName) + { + parent::__construct($protocol); + $this->serviceName_ = $serviceName; + } + + /** + * Writes the message header. + * Prepends the service name to the function name, separated by TMultiplexedProtocol::SEPARATOR. + * + * @param string $name Function name. + * @param int $type Message type. + * @param int $seqid The sequence id of this message. + */ + public function writeMessageBegin($name, $type, $seqid) + { + if ($type == TMessageType::CALL || $type == TMessageType::ONEWAY) { + $nameWithService = $this->serviceName_ . self::SEPARATOR . $name; + parent::writeMessageBegin($nameWithService, $type, $seqid); + } else { + parent::writeMessageBegin($name, $type, $seqid); + } + } +} diff --git a/vendor/packaged/thrift/src/Protocol/TProtocol.php b/vendor/packaged/thrift/src/Protocol/TProtocol.php new file mode 100644 index 000000000..f7b581f7b --- /dev/null +++ b/vendor/packaged/thrift/src/Protocol/TProtocol.php @@ -0,0 +1,352 @@ +trans_ = $trans; + } + + /** + * Accessor for transport + * + * @return TTransport + */ + public function getTransport() + { + return $this->trans_; + } + + /** + * Writes the message header + * + * @param string $name Function name + * @param int $type message type TMessageType::CALL or TMessageType::REPLY + * @param int $seqid The sequence id of this message + */ + abstract public function writeMessageBegin($name, $type, $seqid); + + /** + * Close the message + */ + abstract public function writeMessageEnd(); + + /** + * Writes a struct header. + * + * @param string $name Struct name + * @throws TException on write error + * @return int How many bytes written + */ + abstract public function writeStructBegin($name); + + /** + * Close a struct. + * + * @throws TException on write error + * @return int How many bytes written + */ + abstract public function writeStructEnd(); + + /* + * Starts a field. + * + * @param string $name Field name + * @param int $type Field type + * @param int $fid Field id + * @throws TException on write error + * @return int How many bytes written + */ + abstract public function writeFieldBegin($fieldName, $fieldType, $fieldId); + + abstract public function writeFieldEnd(); + + abstract public function writeFieldStop(); + + abstract public function writeMapBegin($keyType, $valType, $size); + + abstract public function writeMapEnd(); + + abstract public function writeListBegin($elemType, $size); + + abstract public function writeListEnd(); + + abstract public function writeSetBegin($elemType, $size); + + abstract public function writeSetEnd(); + + abstract public function writeBool($bool); + + abstract public function writeByte($byte); + + abstract public function writeI16($i16); + + abstract public function writeI32($i32); + + abstract public function writeI64($i64); + + abstract public function writeDouble($dub); + + abstract public function writeString($str); + + /** + * Reads the message header + * + * @param string $name Function name + * @param int $type message type TMessageType::CALL or TMessageType::REPLY + * @parem int $seqid The sequence id of this message + */ + abstract public function readMessageBegin(&$name, &$type, &$seqid); + + /** + * Read the close of message + */ + abstract public function readMessageEnd(); + + abstract public function readStructBegin(&$name); + + abstract public function readStructEnd(); + + abstract public function readFieldBegin(&$name, &$fieldType, &$fieldId); + + abstract public function readFieldEnd(); + + abstract public function readMapBegin(&$keyType, &$valType, &$size); + + abstract public function readMapEnd(); + + abstract public function readListBegin(&$elemType, &$size); + + abstract public function readListEnd(); + + abstract public function readSetBegin(&$elemType, &$size); + + abstract public function readSetEnd(); + + abstract public function readBool(&$bool); + + abstract public function readByte(&$byte); + + abstract public function readI16(&$i16); + + abstract public function readI32(&$i32); + + abstract public function readI64(&$i64); + + abstract public function readDouble(&$dub); + + abstract public function readString(&$str); + + /** + * The skip function is a utility to parse over unrecognized date without + * causing corruption. + * + * @param TType $type What type is it + */ + public function skip($type) + { + switch ($type) { + case TType::BOOL: + return $this->readBool($bool); + case TType::BYTE: + return $this->readByte($byte); + case TType::I16: + return $this->readI16($i16); + case TType::I32: + return $this->readI32($i32); + case TType::I64: + return $this->readI64($i64); + case TType::DOUBLE: + return $this->readDouble($dub); + case TType::STRING: + return $this->readString($str); + case TType::STRUCT: + $result = $this->readStructBegin($name); + while (true) { + $result += $this->readFieldBegin($name, $ftype, $fid); + if ($ftype == TType::STOP) { + break; + } + $result += $this->skip($ftype); + $result += $this->readFieldEnd(); + } + $result += $this->readStructEnd(); + + return $result; + + case TType::MAP: + $result = $this->readMapBegin($keyType, $valType, $size); + for ($i = 0; $i < $size; $i++) { + $result += $this->skip($keyType); + $result += $this->skip($valType); + } + $result += $this->readMapEnd(); + + return $result; + + case TType::SET: + $result = $this->readSetBegin($elemType, $size); + for ($i = 0; $i < $size; $i++) { + $result += $this->skip($elemType); + } + $result += $this->readSetEnd(); + + return $result; + + case TType::LST: + $result = $this->readListBegin($elemType, $size); + for ($i = 0; $i < $size; $i++) { + $result += $this->skip($elemType); + } + $result += $this->readListEnd(); + + return $result; + + default: + throw new TProtocolException( + 'Unknown field type: ' . $type, + TProtocolException::INVALID_DATA + ); + } + } + + /** + * Utility for skipping binary data + * + * @param TTransport $itrans TTransport object + * @param int $type Field type + */ + public static function skipBinary($itrans, $type) + { + switch ($type) { + case TType::BOOL: + return $itrans->readAll(1); + case TType::BYTE: + return $itrans->readAll(1); + case TType::I16: + return $itrans->readAll(2); + case TType::I32: + return $itrans->readAll(4); + case TType::I64: + return $itrans->readAll(8); + case TType::DOUBLE: + return $itrans->readAll(8); + case TType::STRING: + $len = unpack('N', $itrans->readAll(4)); + $len = $len[1]; + if ($len > 0x7fffffff) { + $len = 0 - (($len - 1) ^ 0xffffffff); + } + + return 4 + $itrans->readAll($len); + + case TType::STRUCT: + $result = 0; + while (true) { + $ftype = 0; + $fid = 0; + $data = $itrans->readAll(1); + $arr = unpack('c', $data); + $ftype = $arr[1]; + if ($ftype == TType::STOP) { + break; + } + // I16 field id + $result += $itrans->readAll(2); + $result += self::skipBinary($itrans, $ftype); + } + + return $result; + + case TType::MAP: + // Ktype + $data = $itrans->readAll(1); + $arr = unpack('c', $data); + $ktype = $arr[1]; + // Vtype + $data = $itrans->readAll(1); + $arr = unpack('c', $data); + $vtype = $arr[1]; + // Size + $data = $itrans->readAll(4); + $arr = unpack('N', $data); + $size = $arr[1]; + if ($size > 0x7fffffff) { + $size = 0 - (($size - 1) ^ 0xffffffff); + } + $result = 6; + for ($i = 0; $i < $size; $i++) { + $result += self::skipBinary($itrans, $ktype); + $result += self::skipBinary($itrans, $vtype); + } + + return $result; + + case TType::SET: + case TType::LST: + // Vtype + $data = $itrans->readAll(1); + $arr = unpack('c', $data); + $vtype = $arr[1]; + // Size + $data = $itrans->readAll(4); + $arr = unpack('N', $data); + $size = $arr[1]; + if ($size > 0x7fffffff) { + $size = 0 - (($size - 1) ^ 0xffffffff); + } + $result = 5; + for ($i = 0; $i < $size; $i++) { + $result += self::skipBinary($itrans, $vtype); + } + + return $result; + + default: + throw new TProtocolException( + 'Unknown field type: ' . $type, + TProtocolException::INVALID_DATA + ); + } + } +} diff --git a/vendor/packaged/thrift/src/Protocol/TProtocolDecorator.php b/vendor/packaged/thrift/src/Protocol/TProtocolDecorator.php new file mode 100644 index 000000000..a85e0b8e5 --- /dev/null +++ b/vendor/packaged/thrift/src/Protocol/TProtocolDecorator.php @@ -0,0 +1,285 @@ +TProtocolDecorator forwards all requests to an enclosed + * TProtocol instance, providing a way to author concise + * concrete decorator subclasses. While it has no abstract methods, it + * is marked abstract as a reminder that by itself, it does not modify + * the behaviour of the enclosed TProtocol. + * + * @package Thrift\Protocol + */ +abstract class TProtocolDecorator extends TProtocol +{ + /** + * Instance of protocol, to which all operations will be forwarded. + * + * @var TProtocol + */ + private $concreteProtocol_; + + /** + * Constructor of TProtocolDecorator class. + * Encloses the specified protocol. + * + * @param TProtocol $protocol All operations will be forward to this instance. Must be non-null. + */ + protected function __construct(TProtocol $protocol) + { + parent::__construct($protocol->getTransport()); + $this->concreteProtocol_ = $protocol; + } + + /** + * Writes the message header. + * + * @param string $name Function name + * @param int $type message type TMessageType::CALL or TMessageType::REPLY + * @param int $seqid The sequence id of this message + */ + public function writeMessageBegin($name, $type, $seqid) + { + return $this->concreteProtocol_->writeMessageBegin($name, $type, $seqid); + } + + /** + * Closes the message. + */ + public function writeMessageEnd() + { + return $this->concreteProtocol_->writeMessageEnd(); + } + + /** + * Writes a struct header. + * + * @param string $name Struct name + * + * @throws TException on write error + * @return int How many bytes written + */ + public function writeStructBegin($name) + { + return $this->concreteProtocol_->writeStructBegin($name); + } + + /** + * Close a struct. + * + * @throws TException on write error + * @return int How many bytes written + */ + public function writeStructEnd() + { + return $this->concreteProtocol_->writeStructEnd(); + } + + public function writeFieldBegin($fieldName, $fieldType, $fieldId) + { + return $this->concreteProtocol_->writeFieldBegin($fieldName, $fieldType, $fieldId); + } + + public function writeFieldEnd() + { + return $this->concreteProtocol_->writeFieldEnd(); + } + + public function writeFieldStop() + { + return $this->concreteProtocol_->writeFieldStop(); + } + + public function writeMapBegin($keyType, $valType, $size) + { + return $this->concreteProtocol_->writeMapBegin($keyType, $valType, $size); + } + + public function writeMapEnd() + { + return $this->concreteProtocol_->writeMapEnd(); + } + + public function writeListBegin($elemType, $size) + { + return $this->concreteProtocol_->writeListBegin($elemType, $size); + } + + public function writeListEnd() + { + return $this->concreteProtocol_->writeListEnd(); + } + + public function writeSetBegin($elemType, $size) + { + return $this->concreteProtocol_->writeSetBegin($elemType, $size); + } + + public function writeSetEnd() + { + return $this->concreteProtocol_->writeSetEnd(); + } + + public function writeBool($bool) + { + return $this->concreteProtocol_->writeBool($bool); + } + + public function writeByte($byte) + { + return $this->concreteProtocol_->writeByte($byte); + } + + public function writeI16($i16) + { + return $this->concreteProtocol_->writeI16($i16); + } + + public function writeI32($i32) + { + return $this->concreteProtocol_->writeI32($i32); + } + + public function writeI64($i64) + { + return $this->concreteProtocol_->writeI64($i64); + } + + public function writeDouble($dub) + { + return $this->concreteProtocol_->writeDouble($dub); + } + + public function writeString($str) + { + return $this->concreteProtocol_->writeString($str); + } + + /** + * Reads the message header + * + * @param string $name Function name + * @param int $type message type TMessageType::CALL or TMessageType::REPLY + * @param int $seqid The sequence id of this message + */ + public function readMessageBegin(&$name, &$type, &$seqid) + { + return $this->concreteProtocol_->readMessageBegin($name, $type, $seqid); + } + + /** + * Read the close of message + */ + public function readMessageEnd() + { + return $this->concreteProtocol_->readMessageEnd(); + } + + public function readStructBegin(&$name) + { + return $this->concreteProtocol_->readStructBegin($name); + } + + public function readStructEnd() + { + return $this->concreteProtocol_->readStructEnd(); + } + + public function readFieldBegin(&$name, &$fieldType, &$fieldId) + { + return $this->concreteProtocol_->readFieldBegin($name, $fieldType, $fieldId); + } + + public function readFieldEnd() + { + return $this->concreteProtocol_->readFieldEnd(); + } + + public function readMapBegin(&$keyType, &$valType, &$size) + { + $this->concreteProtocol_->readMapBegin($keyType, $valType, $size); + } + + public function readMapEnd() + { + return $this->concreteProtocol_->readMapEnd(); + } + + public function readListBegin(&$elemType, &$size) + { + $this->concreteProtocol_->readListBegin($elemType, $size); + } + + public function readListEnd() + { + return $this->concreteProtocol_->readListEnd(); + } + + public function readSetBegin(&$elemType, &$size) + { + return $this->concreteProtocol_->readSetBegin($elemType, $size); + } + + public function readSetEnd() + { + return $this->concreteProtocol_->readSetEnd(); + } + + public function readBool(&$bool) + { + return $this->concreteProtocol_->readBool($bool); + } + + public function readByte(&$byte) + { + return $this->concreteProtocol_->readByte($byte); + } + + public function readI16(&$i16) + { + return $this->concreteProtocol_->readI16($i16); + } + + public function readI32(&$i32) + { + return $this->concreteProtocol_->readI32($i32); + } + + public function readI64(&$i64) + { + return $this->concreteProtocol_->readI64($i64); + } + + public function readDouble(&$dub) + { + return $this->concreteProtocol_->readDouble($dub); + } + + public function readString(&$str) + { + return $this->concreteProtocol_->readString($str); + } +} diff --git a/vendor/packaged/thrift/src/Protocol/TSimpleJSONProtocol.php b/vendor/packaged/thrift/src/Protocol/TSimpleJSONProtocol.php new file mode 100644 index 000000000..1cf1f6407 --- /dev/null +++ b/vendor/packaged/thrift/src/Protocol/TSimpleJSONProtocol.php @@ -0,0 +1,374 @@ +writeContextStack_[] = $this->writeContext_; + $this->writeContext_ = $c; + } + + /** + * Pop the last write context off the stack + */ + protected function popWriteContext() + { + $this->writeContext_ = array_pop($this->writeContextStack_); + } + + /** + * Used to make sure that we are not encountering a map whose keys are containers + */ + protected function assertContextIsNotMapKey($invalidKeyType) + { + if ($this->writeContext_->isMapKey()) { + throw new CollectionMapKeyException( + "Cannot serialize a map with keys that are of type " . + $invalidKeyType + ); + } + } + + private function writeJSONString($b) + { + $this->writeContext_->write(); + + $this->trans_->write(json_encode((string)$b)); + } + + private function writeJSONInteger($num) + { + $isMapKey = $this->writeContext_->isMapKey(); + + $this->writeContext_->write(); + + if ($isMapKey) { + $this->trans_->write(self::QUOTE); + } + + $this->trans_->write((int)$num); + + if ($isMapKey) { + $this->trans_->write(self::QUOTE); + } + } + + private function writeJSONDouble($num) + { + $isMapKey = $this->writeContext_->isMapKey(); + + $this->writeContext_->write(); + + if ($isMapKey) { + $this->trans_->write(self::QUOTE); + } + + $this->trans_->write(json_encode((float)$num)); + + if ($isMapKey) { + $this->trans_->write(self::QUOTE); + } + } + + /** + * Constructor + */ + public function __construct($trans) + { + parent::__construct($trans); + $this->writeContext_ = new Context(); + } + + /** + * Writes the message header + * + * @param string $name Function name + * @param int $type message type TMessageType::CALL or TMessageType::REPLY + * @param int $seqid The sequence id of this message + */ + public function writeMessageBegin($name, $type, $seqid) + { + $this->trans_->write(self::LBRACKET); + $this->pushWriteContext(new ListContext($this)); + $this->writeJSONString($name); + $this->writeJSONInteger($type); + $this->writeJSONInteger($seqid); + } + + /** + * Close the message + */ + public function writeMessageEnd() + { + $this->popWriteContext(); + $this->trans_->write(self::RBRACKET); + } + + /** + * Writes a struct header. + * + * @param string $name Struct name + */ + public function writeStructBegin($name) + { + $this->writeContext_->write(); + $this->trans_->write(self::LBRACE); + $this->pushWriteContext(new StructContext($this)); + } + + /** + * Close a struct. + */ + public function writeStructEnd() + { + $this->popWriteContext(); + $this->trans_->write(self::RBRACE); + } + + public function writeFieldBegin($fieldName, $fieldType, $fieldId) + { + $this->writeJSONString($fieldName); + } + + public function writeFieldEnd() + { + } + + public function writeFieldStop() + { + } + + public function writeMapBegin($keyType, $valType, $size) + { + $this->assertContextIsNotMapKey(self::NAME_MAP); + $this->writeContext_->write(); + $this->trans_->write(self::LBRACE); + $this->pushWriteContext(new MapContext($this)); + } + + public function writeMapEnd() + { + $this->popWriteContext(); + $this->trans_->write(self::RBRACE); + } + + public function writeListBegin($elemType, $size) + { + $this->assertContextIsNotMapKey(self::NAME_LIST); + $this->writeContext_->write(); + $this->trans_->write(self::LBRACKET); + $this->pushWriteContext(new ListContext($this)); + // No metadata! + } + + public function writeListEnd() + { + $this->popWriteContext(); + $this->trans_->write(self::RBRACKET); + } + + public function writeSetBegin($elemType, $size) + { + $this->assertContextIsNotMapKey(self::NAME_SET); + $this->writeContext_->write(); + $this->trans_->write(self::LBRACKET); + $this->pushWriteContext(new ListContext($this)); + // No metadata! + } + + public function writeSetEnd() + { + $this->popWriteContext(); + $this->trans_->write(self::RBRACKET); + } + + public function writeBool($bool) + { + $this->writeJSONInteger($bool ? 1 : 0); + } + + public function writeByte($byte) + { + $this->writeJSONInteger($byte); + } + + public function writeI16($i16) + { + $this->writeJSONInteger($i16); + } + + public function writeI32($i32) + { + $this->writeJSONInteger($i32); + } + + public function writeI64($i64) + { + $this->writeJSONInteger($i64); + } + + public function writeDouble($dub) + { + $this->writeJSONDouble($dub); + } + + public function writeString($str) + { + $this->writeJSONString($str); + } + + /** + * Reading methods. + * + * simplejson is not meant to be read back into thrift + * - see http://wiki.apache.org/thrift/ThriftUsageJava + * - use JSON instead + */ + + public function readMessageBegin(&$name, &$type, &$seqid) + { + throw new TException("Not implemented"); + } + + public function readMessageEnd() + { + throw new TException("Not implemented"); + } + + public function readStructBegin(&$name) + { + throw new TException("Not implemented"); + } + + public function readStructEnd() + { + throw new TException("Not implemented"); + } + + public function readFieldBegin(&$name, &$fieldType, &$fieldId) + { + throw new TException("Not implemented"); + } + + public function readFieldEnd() + { + throw new TException("Not implemented"); + } + + public function readMapBegin(&$keyType, &$valType, &$size) + { + throw new TException("Not implemented"); + } + + public function readMapEnd() + { + throw new TException("Not implemented"); + } + + public function readListBegin(&$elemType, &$size) + { + throw new TException("Not implemented"); + } + + public function readListEnd() + { + throw new TException("Not implemented"); + } + + public function readSetBegin(&$elemType, &$size) + { + throw new TException("Not implemented"); + } + + public function readSetEnd() + { + throw new TException("Not implemented"); + } + + public function readBool(&$bool) + { + throw new TException("Not implemented"); + } + + public function readByte(&$byte) + { + throw new TException("Not implemented"); + } + + public function readI16(&$i16) + { + throw new TException("Not implemented"); + } + + public function readI32(&$i32) + { + throw new TException("Not implemented"); + } + + public function readI64(&$i64) + { + throw new TException("Not implemented"); + } + + public function readDouble(&$dub) + { + throw new TException("Not implemented"); + } + + public function readString(&$str) + { + throw new TException("Not implemented"); + } +} diff --git a/vendor/packaged/thrift/src/Serializer/TBinarySerializer.php b/vendor/packaged/thrift/src/Serializer/TBinarySerializer.php new file mode 100644 index 000000000..9d2b14730 --- /dev/null +++ b/vendor/packaged/thrift/src/Serializer/TBinarySerializer.php @@ -0,0 +1,87 @@ +getName(), + TMessageType::REPLY, + $object, + 0, + $protocol->isStrictWrite() + ); + + $protocol->readMessageBegin($unused_name, $unused_type, $unused_seqid); + } else { + $object->write($protocol); + } + $protocol->getTransport()->flush(); + + return $transport->getBuffer(); + } + + public static function deserialize($string_object, $class_name, $buffer_size = 8192) + { + $transport = new TMemoryBuffer(); + $protocol = new TBinaryProtocolAccelerated($transport); + if (function_exists('thrift_protocol_read_binary')) { + // NOTE (t.heintz) TBinaryProtocolAccelerated internally wraps our TMemoryBuffer in a + // TBufferedTransport, so we have to retrieve it again or risk losing data when writing + // less than 512 bytes to the transport (see the comment there as well). + // @see THRIFT-1579 + $protocol->writeMessageBegin('', TMessageType::REPLY, 0); + $protocolTransport = $protocol->getTransport(); + $protocolTransport->write($string_object); + $protocolTransport->flush(); + + return thrift_protocol_read_binary($protocol, $class_name, $protocol->isStrictRead(), $buffer_size); + } else { + $transport->write($string_object); + $object = new $class_name(); + $object->read($protocol); + + return $object; + } + } +} diff --git a/vendor/packaged/thrift/src/Server/TForkingServer.php b/vendor/packaged/thrift/src/Server/TForkingServer.php new file mode 100644 index 000000000..0bb6e9192 --- /dev/null +++ b/vendor/packaged/thrift/src/Server/TForkingServer.php @@ -0,0 +1,125 @@ +transport_->listen(); + + while (!$this->stop_) { + try { + $transport = $this->transport_->accept(); + + if ($transport != null) { + $pid = pcntl_fork(); + + if ($pid > 0) { + $this->handleParent($transport, $pid); + } elseif ($pid === 0) { + $this->handleChild($transport); + } else { + throw new TException('Failed to fork'); + } + } + } catch (TTransportException $e) { + } + + $this->collectChildren(); + } + } + + /** + * Code run by the parent + * + * @param TTransport $transport + * @param int $pid + * @return void + */ + private function handleParent(TTransport $transport, $pid) + { + $this->children_[$pid] = $transport; + } + + /** + * Code run by the child. + * + * @param TTransport $transport + * @return void + */ + private function handleChild(TTransport $transport) + { + try { + $inputTransport = $this->inputTransportFactory_->getTransport($transport); + $outputTransport = $this->outputTransportFactory_->getTransport($transport); + $inputProtocol = $this->inputProtocolFactory_->getProtocol($inputTransport); + $outputProtocol = $this->outputProtocolFactory_->getProtocol($outputTransport); + while ($this->processor_->process($inputProtocol, $outputProtocol)) { + } + @$transport->close(); + } catch (TTransportException $e) { + } + + exit(0); + } + + /** + * Collects any children we may have + * + * @return void + */ + private function collectChildren() + { + foreach ($this->children_ as $pid => $transport) { + if (pcntl_waitpid($pid, $status, WNOHANG) > 0) { + unset($this->children_[$pid]); + if ($transport) { + @$transport->close(); + } + } + } + } + + /** + * Stops the server running. Kills the transport + * and then stops the main serving loop + * + * @return void + */ + public function stop() + { + $this->transport_->close(); + $this->stop_ = true; + } +} diff --git a/vendor/packaged/thrift/src/Server/TSSLServerSocket.php b/vendor/packaged/thrift/src/Server/TSSLServerSocket.php new file mode 100644 index 000000000..ac589b76b --- /dev/null +++ b/vendor/packaged/thrift/src/Server/TSSLServerSocket.php @@ -0,0 +1,97 @@ +getSSLHost($host); + parent::__construct($ssl_host, $port); + $this->context_ = $context; + } + + public function getSSLHost($host) + { + $transport_protocol_loc = strpos($host, "://"); + if ($transport_protocol_loc === false) { + $host = 'ssl://' . $host; + } + return $host; + } + + /** + * Opens a new socket server handle + * + * @return void + */ + public function listen() + { + $this->listener_ = @stream_socket_server( + $this->host_ . ':' . $this->port_, + $errno, + $errstr, + STREAM_SERVER_BIND | STREAM_SERVER_LISTEN, + $this->context_ + ); + } + + /** + * Implementation of accept. If not client is accepted in the given time + * + * @return TSocket + */ + protected function acceptImpl() + { + $handle = @stream_socket_accept($this->listener_, $this->acceptTimeout_ / 1000.0); + if (!$handle) { + return null; + } + + $socket = new TSSLSocket(); + $socket->setHandle($handle); + + return $socket; + } +} diff --git a/vendor/packaged/thrift/src/Server/TServer.php b/vendor/packaged/thrift/src/Server/TServer.php new file mode 100644 index 000000000..268c37820 --- /dev/null +++ b/vendor/packaged/thrift/src/Server/TServer.php @@ -0,0 +1,102 @@ +processor_ = $processor; + $this->transport_ = $transport; + $this->inputTransportFactory_ = $inputTransportFactory; + $this->outputTransportFactory_ = $outputTransportFactory; + $this->inputProtocolFactory_ = $inputProtocolFactory; + $this->outputProtocolFactory_ = $outputProtocolFactory; + } + + /** + * Serves the server. This should never return + * unless a problem permits it to do so or it + * is interrupted intentionally + * + * @abstract + * @return void + */ + abstract public function serve(); + + /** + * Stops the server serving + * + * @abstract + * @return void + */ + abstract public function stop(); +} diff --git a/vendor/packaged/thrift/src/Server/TServerSocket.php b/vendor/packaged/thrift/src/Server/TServerSocket.php new file mode 100644 index 000000000..8f38fb23f --- /dev/null +++ b/vendor/packaged/thrift/src/Server/TServerSocket.php @@ -0,0 +1,124 @@ +host_ = $host; + $this->port_ = $port; + } + + /** + * Sets the accept timeout + * + * @param int $acceptTimeout + * @return void + */ + public function setAcceptTimeout($acceptTimeout) + { + $this->acceptTimeout_ = $acceptTimeout; + } + + /** + * Opens a new socket server handle + * + * @return void + */ + public function listen() + { + $this->listener_ = stream_socket_server('tcp://' . $this->host_ . ':' . $this->port_); + } + + /** + * Closes the socket server handle + * + * @return void + */ + public function close() + { + @fclose($this->listener_); + $this->listener_ = null; + } + + /** + * Implementation of accept. If not client is accepted in the given time + * + * @return TSocket + */ + protected function acceptImpl() + { + $handle = @stream_socket_accept($this->listener_, $this->acceptTimeout_ / 1000.0); + if (!$handle) { + return null; + } + + $socket = new TSocket(); + $socket->setHandle($handle); + + return $socket; + } +} diff --git a/vendor/packaged/thrift/src/Server/TServerTransport.php b/vendor/packaged/thrift/src/Server/TServerTransport.php new file mode 100644 index 000000000..15a27afa8 --- /dev/null +++ b/vendor/packaged/thrift/src/Server/TServerTransport.php @@ -0,0 +1,56 @@ +acceptImpl(); + + if ($transport == null) { + throw new TTransportException("accept() may not return NULL"); + } + + return $transport; + } +} diff --git a/vendor/packaged/thrift/src/Server/TSimpleServer.php b/vendor/packaged/thrift/src/Server/TSimpleServer.php new file mode 100644 index 000000000..4c1dda5a5 --- /dev/null +++ b/vendor/packaged/thrift/src/Server/TSimpleServer.php @@ -0,0 +1,60 @@ +transport_->listen(); + + while (!$this->stop_) { + try { + $transport = $this->transport_->accept(); + + if ($transport != null) { + $inputTransport = $this->inputTransportFactory_->getTransport($transport); + $outputTransport = $this->outputTransportFactory_->getTransport($transport); + $inputProtocol = $this->inputProtocolFactory_->getProtocol($inputTransport); + $outputProtocol = $this->outputProtocolFactory_->getProtocol($outputTransport); + while ($this->processor_->process($inputProtocol, $outputProtocol)) { + } + } + } catch (TTransportException $e) { + } + } + } + + /** + * Stops the server running. Kills the transport + * and then stops the main serving loop + * + * @return void + */ + public function stop() + { + $this->transport_->close(); + $this->stop_ = true; + } +} diff --git a/vendor/packaged/thrift/src/StoredMessageProtocol.php b/vendor/packaged/thrift/src/StoredMessageProtocol.php new file mode 100644 index 000000000..c4aaaa9ec --- /dev/null +++ b/vendor/packaged/thrift/src/StoredMessageProtocol.php @@ -0,0 +1,53 @@ +fname_ = $fname; + $this->mtype_ = $mtype; + $this->rseqid_ = $rseqid; + } + + public function readMessageBegin(&$name, &$type, &$seqid) + { + $name = $this->fname_; + $type = $this->mtype_; + $seqid = $this->rseqid_; + } +} diff --git a/vendor/packaged/thrift/src/StringFunc/Core.php b/vendor/packaged/thrift/src/StringFunc/Core.php new file mode 100644 index 000000000..39a75b3a2 --- /dev/null +++ b/vendor/packaged/thrift/src/StringFunc/Core.php @@ -0,0 +1,40 @@ +strlen($str) - $start; + } + + return mb_substr($str, $start, $length, '8bit'); + } + + public function strlen($str) + { + return mb_strlen($str, '8bit'); + } +} diff --git a/vendor/packaged/thrift/src/StringFunc/TStringFunc.php b/vendor/packaged/thrift/src/StringFunc/TStringFunc.php new file mode 100644 index 000000000..dea497f2e --- /dev/null +++ b/vendor/packaged/thrift/src/StringFunc/TStringFunc.php @@ -0,0 +1,28 @@ +TMultiplexedProcessor is a Processor allowing + * a single TServer to provide multiple services. + * + *

To do so, you instantiate the processor and then register additional + * processors with it, as shown in the following example:

+ * + *
+ * $processor = new TMultiplexedProcessor(); + * + * processor->registerProcessor( + * "Calculator", + * new \tutorial\CalculatorProcessor(new CalculatorHandler())); + * + * processor->registerProcessor( + * "WeatherReport", + * new \tutorial\WeatherReportProcessor(new WeatherReportHandler())); + * + * $processor->process($protocol, $protocol); + *
+ */ + +class TMultiplexedProcessor +{ + private $serviceProcessorMap_; + + /** + * 'Register' a service with this TMultiplexedProcessor. This + * allows us to broker requests to individual services by using the service + * name to select them at request time. + * + * @param serviceName Name of a service, has to be identical to the name + * declared in the Thrift IDL, e.g. "WeatherReport". + * @param processor Implementation of a service, usually referred to + * as "handlers", e.g. WeatherReportHandler implementing WeatherReport.Iface. + */ + public function registerProcessor($serviceName, $processor) + { + $this->serviceProcessorMap_[$serviceName] = $processor; + } + + /** + * This implementation of process performs the following steps: + * + *
    + *
  1. Read the beginning of the message.
  2. + *
  3. Extract the service name from the message.
  4. + *
  5. Using the service name to locate the appropriate processor.
  6. + *
  7. Dispatch to the processor, with a decorated instance of TProtocol + * that allows readMessageBegin() to return the original Message.
  8. + *
+ * + * @throws TException If the message type is not CALL or ONEWAY, if + * the service name was not found in the message, or if the service + * name was not found in the service map. + */ + public function process(TProtocol $input, TProtocol $output) + { + /* + Use the actual underlying protocol (e.g. TBinaryProtocol) to read the + message header. This pulls the message "off the wire", which we'll + deal with at the end of this method. + */ + $input->readMessageBegin($fname, $mtype, $rseqid); + + if ($mtype !== TMessageType::CALL && $mtype != TMessageType::ONEWAY) { + throw new TException("This should not have happened!?"); + } + + // Extract the service name and the new Message name. + if (strpos($fname, TMultiplexedProtocol::SEPARATOR) === false) { + throw new TException("Service name not found in message name: {$fname}. Did you " . + "forget to use a TMultiplexProtocol in your client?"); + } + list($serviceName, $messageName) = explode(':', $fname, 2); + if (!array_key_exists($serviceName, $this->serviceProcessorMap_)) { + throw new TException("Service name not found: {$serviceName}. Did you forget " . + "to call registerProcessor()?"); + } + + // Dispatch processing to the stored processor + $processor = $this->serviceProcessorMap_[$serviceName]; + + return $processor->process( + new StoredMessageProtocol($input, $messageName, $mtype, $rseqid), + $output + ); + } +} diff --git a/vendor/packaged/thrift/src/Transport/TBufferedTransport.php b/vendor/packaged/thrift/src/Transport/TBufferedTransport.php new file mode 100644 index 000000000..253c5acfb --- /dev/null +++ b/vendor/packaged/thrift/src/Transport/TBufferedTransport.php @@ -0,0 +1,206 @@ +transport_ = $transport; + $this->rBufSize_ = $rBufSize; + $this->wBufSize_ = $wBufSize; + } + + public function isOpen() + { + return $this->transport_->isOpen(); + } + + /** + * @inheritdoc + * + * @throws TTransportException + */ + public function open() + { + $this->transport_->open(); + } + + public function close() + { + $this->transport_->close(); + } + + public function putBack($data) + { + if (TStringFuncFactory::create()->strlen($this->rBuf_) === 0) { + $this->rBuf_ = $data; + } else { + $this->rBuf_ = ($data . $this->rBuf_); + } + } + + /** + * The reason that we customize readAll here is that the majority of PHP + * streams are already internally buffered by PHP. The socket stream, for + * example, buffers internally and blocks if you call read with $len greater + * than the amount of data available, unlike recv() in C. + * + * Therefore, use the readAll method of the wrapped transport inside + * the buffered readAll. + * + * @throws TTransportException + */ + public function readAll($len) + { + $have = TStringFuncFactory::create()->strlen($this->rBuf_); + if ($have == 0) { + $data = $this->transport_->readAll($len); + } elseif ($have < $len) { + $data = $this->rBuf_; + $this->rBuf_ = ''; + $data .= $this->transport_->readAll($len - $have); + } elseif ($have == $len) { + $data = $this->rBuf_; + $this->rBuf_ = ''; + } elseif ($have > $len) { + $data = TStringFuncFactory::create()->substr($this->rBuf_, 0, $len); + $this->rBuf_ = TStringFuncFactory::create()->substr($this->rBuf_, $len); + } + + return $data; + } + + /** + * @inheritdoc + * + * @param int $len + * @return string + * @throws TTransportException + */ + public function read($len) + { + if (TStringFuncFactory::create()->strlen($this->rBuf_) === 0) { + $this->rBuf_ = $this->transport_->read($this->rBufSize_); + } + + if (TStringFuncFactory::create()->strlen($this->rBuf_) <= $len) { + $ret = $this->rBuf_; + $this->rBuf_ = ''; + + return $ret; + } + + $ret = TStringFuncFactory::create()->substr($this->rBuf_, 0, $len); + $this->rBuf_ = TStringFuncFactory::create()->substr($this->rBuf_, $len); + + return $ret; + } + + /** + * @inheritdoc + * + * @param string $buf + * @throws TTransportException + */ + public function write($buf) + { + $this->wBuf_ .= $buf; + if (TStringFuncFactory::create()->strlen($this->wBuf_) >= $this->wBufSize_) { + $out = $this->wBuf_; + + // Note that we clear the internal wBuf_ prior to the underlying write + // to ensure we're in a sane state (i.e. internal buffer cleaned) + // if the underlying write throws up an exception + $this->wBuf_ = ''; + $this->transport_->write($out); + } + } + + /** + * @inheritdoc + * + * @throws TTransportException + */ + public function flush() + { + if (TStringFuncFactory::create()->strlen($this->wBuf_) > 0) { + $out = $this->wBuf_; + + // Note that we clear the internal wBuf_ prior to the underlying write + // to ensure we're in a sane state (i.e. internal buffer cleaned) + // if the underlying write throws up an exception + $this->wBuf_ = ''; + $this->transport_->write($out); + } + $this->transport_->flush(); + } +} diff --git a/vendor/packaged/thrift/src/Transport/TCurlClient.php b/vendor/packaged/thrift/src/Transport/TCurlClient.php new file mode 100644 index 000000000..f781da969 --- /dev/null +++ b/vendor/packaged/thrift/src/Transport/TCurlClient.php @@ -0,0 +1,281 @@ +strlen($uri) > 0) && ($uri[0] != '/')) { + $uri = '/' . $uri; + } + $this->scheme_ = $scheme; + $this->host_ = $host; + $this->port_ = $port; + $this->uri_ = $uri; + $this->request_ = ''; + $this->response_ = null; + $this->timeout_ = null; + $this->headers_ = array(); + } + + /** + * Set read timeout + * + * @param float $timeout + */ + public function setTimeoutSecs($timeout) + { + $this->timeout_ = $timeout; + } + + /** + * Whether this transport is open. + * + * @return boolean true if open + */ + public function isOpen() + { + return true; + } + + /** + * Open the transport for reading/writing + * + * @throws TTransportException if cannot open + */ + public function open() + { + } + + /** + * Close the transport. + */ + public function close() + { + $this->request_ = ''; + $this->response_ = null; + } + + /** + * Read some data into the array. + * + * @param int $len How much to read + * @return string The data that has been read + * @throws TTransportException if cannot read any more data + */ + public function read($len) + { + if ($len >= strlen($this->response_)) { + return $this->response_; + } else { + $ret = substr($this->response_, 0, $len); + $this->response_ = substr($this->response_, $len); + + return $ret; + } + } + + /** + * Guarantees that the full amount of data is read. Since TCurlClient gets entire payload at + * once, parent readAll cannot be used. + * + * @return string The data, of exact length + * @throws TTransportException if cannot read data + */ + public function readAll($len) + { + $data = $this->read($len); + + if (TStringFuncFactory::create()->strlen($data) !== $len) { + throw new TTransportException('TCurlClient could not read '.$len.' bytes'); + } + + return $data; + } + + /** + * Writes some data into the pending buffer + * + * @param string $buf The data to write + * @throws TTransportException if writing fails + */ + public function write($buf) + { + $this->request_ .= $buf; + } + + /** + * Opens and sends the actual request over the HTTP connection + * + * @throws TTransportException if a writing error occurs + */ + public function flush() + { + if (!self::$curlHandle) { + register_shutdown_function(array('Thrift\\Transport\\TCurlClient', 'closeCurlHandle')); + self::$curlHandle = curl_init(); + curl_setopt(self::$curlHandle, CURLOPT_RETURNTRANSFER, true); + curl_setopt(self::$curlHandle, CURLOPT_BINARYTRANSFER, true); + curl_setopt(self::$curlHandle, CURLOPT_USERAGENT, 'PHP/TCurlClient'); + curl_setopt(self::$curlHandle, CURLOPT_CUSTOMREQUEST, 'POST'); + curl_setopt(self::$curlHandle, CURLOPT_FOLLOWLOCATION, true); + curl_setopt(self::$curlHandle, CURLOPT_MAXREDIRS, 1); + } + // God, PHP really has some esoteric ways of doing simple things. + $host = $this->host_ . ($this->port_ != 80 ? ':' . $this->port_ : ''); + $fullUrl = $this->scheme_ . "://" . $host . $this->uri_; + + $headers = array(); + $defaultHeaders = array('Accept' => 'application/x-thrift', + 'Content-Type' => 'application/x-thrift', + 'Content-Length' => TStringFuncFactory::create()->strlen($this->request_)); + foreach (array_merge($defaultHeaders, $this->headers_) as $key => $value) { + $headers[] = "$key: $value"; + } + + curl_setopt(self::$curlHandle, CURLOPT_HTTPHEADER, $headers); + + if ($this->timeout_ > 0) { + if ($this->timeout_ < 1.0) { + // Timestamps smaller than 1 second are ignored when CURLOPT_TIMEOUT is used + curl_setopt(self::$curlHandle, CURLOPT_TIMEOUT_MS, 1000 * $this->timeout_); + } else { + curl_setopt(self::$curlHandle, CURLOPT_TIMEOUT, $this->timeout_); + } + } + curl_setopt(self::$curlHandle, CURLOPT_POSTFIELDS, $this->request_); + $this->request_ = ''; + + curl_setopt(self::$curlHandle, CURLOPT_URL, $fullUrl); + $this->response_ = curl_exec(self::$curlHandle); + $responseError = curl_error(self::$curlHandle); + + $code = curl_getinfo(self::$curlHandle, CURLINFO_HTTP_CODE); + + // Handle non 200 status code / connect failure + if ($this->response_ === false || $code !== 200) { + curl_close(self::$curlHandle); + self::$curlHandle = null; + $this->response_ = null; + $error = 'TCurlClient: Could not connect to ' . $fullUrl; + if ($responseError) { + $error .= ', ' . $responseError; + } + if ($code) { + $error .= ', HTTP status code: ' . $code; + } + throw new TTransportException($error, TTransportException::UNKNOWN); + } + } + + public static function closeCurlHandle() + { + try { + if (self::$curlHandle) { + curl_close(self::$curlHandle); + self::$curlHandle = null; + } + } catch (\Exception $x) { + error_log('There was an error closing the curl handle: ' . $x->getMessage()); + } + } + + public function addHeaders($headers) + { + $this->headers_ = array_merge($this->headers_, $headers); + } +} diff --git a/vendor/packaged/thrift/src/Transport/TFramedTransport.php b/vendor/packaged/thrift/src/Transport/TFramedTransport.php new file mode 100644 index 000000000..39d186987 --- /dev/null +++ b/vendor/packaged/thrift/src/Transport/TFramedTransport.php @@ -0,0 +1,192 @@ +transport_ = $transport; + $this->read_ = $read; + $this->write_ = $write; + } + + public function isOpen() + { + return $this->transport_->isOpen(); + } + + public function open() + { + $this->transport_->open(); + } + + public function close() + { + $this->transport_->close(); + } + + /** + * Reads from the buffer. When more data is required reads another entire + * chunk and serves future reads out of that. + * + * @param int $len How much data + */ + public function read($len) + { + if (!$this->read_) { + return $this->transport_->read($len); + } + + if (TStringFuncFactory::create()->strlen($this->rBuf_) === 0) { + $this->readFrame(); + } + + // Just return full buff + if ($len >= TStringFuncFactory::create()->strlen($this->rBuf_)) { + $out = $this->rBuf_; + $this->rBuf_ = null; + + return $out; + } + + // Return TStringFuncFactory::create()->substr + $out = TStringFuncFactory::create()->substr($this->rBuf_, 0, $len); + $this->rBuf_ = TStringFuncFactory::create()->substr($this->rBuf_, $len); + + return $out; + } + + /** + * Put previously read data back into the buffer + * + * @param string $data data to return + */ + public function putBack($data) + { + if (TStringFuncFactory::create()->strlen($this->rBuf_) === 0) { + $this->rBuf_ = $data; + } else { + $this->rBuf_ = ($data . $this->rBuf_); + } + } + + /** + * Reads a chunk of data into the internal read buffer. + */ + private function readFrame() + { + $buf = $this->transport_->readAll(4); + $val = unpack('N', $buf); + $sz = $val[1]; + + $this->rBuf_ = $this->transport_->readAll($sz); + } + + /** + * Writes some data to the pending output buffer. + * + * @param string $buf The data + * @param int $len Limit of bytes to write + */ + public function write($buf, $len = null) + { + if (!$this->write_) { + return $this->transport_->write($buf, $len); + } + + if ($len !== null && $len < TStringFuncFactory::create()->strlen($buf)) { + $buf = TStringFuncFactory::create()->substr($buf, 0, $len); + } + $this->wBuf_ .= $buf; + } + + /** + * Writes the output buffer to the stream in the format of a 4-byte length + * followed by the actual data. + */ + public function flush() + { + if (!$this->write_ || TStringFuncFactory::create()->strlen($this->wBuf_) == 0) { + return $this->transport_->flush(); + } + + $out = pack('N', TStringFuncFactory::create()->strlen($this->wBuf_)); + $out .= $this->wBuf_; + + // Note that we clear the internal wBuf_ prior to the underlying write + // to ensure we're in a sane state (i.e. internal buffer cleaned) + // if the underlying write throws up an exception + $this->wBuf_ = ''; + $this->transport_->write($out); + $this->transport_->flush(); + } +} diff --git a/vendor/packaged/thrift/src/Transport/THttpClient.php b/vendor/packaged/thrift/src/Transport/THttpClient.php new file mode 100644 index 000000000..4d6be32fe --- /dev/null +++ b/vendor/packaged/thrift/src/Transport/THttpClient.php @@ -0,0 +1,258 @@ +strlen($uri) > 0) && ($uri[0] != '/')) { + $uri = '/' . $uri; + } + $this->scheme_ = $scheme; + $this->host_ = $host; + $this->port_ = $port; + $this->uri_ = $uri; + $this->buf_ = ''; + $this->handle_ = null; + $this->timeout_ = null; + $this->headers_ = array(); + $this->context_ = $context; + } + + /** + * Set read timeout + * + * @param float $timeout + */ + public function setTimeoutSecs($timeout) + { + $this->timeout_ = $timeout; + } + + /** + * Whether this transport is open. + * + * @return boolean true if open + */ + public function isOpen() + { + return true; + } + + /** + * Open the transport for reading/writing + * + * @throws TTransportException if cannot open + */ + public function open() + { + } + + /** + * Close the transport. + */ + public function close() + { + if ($this->handle_) { + @fclose($this->handle_); + $this->handle_ = null; + } + } + + /** + * Read some data into the array. + * + * @param int $len How much to read + * @return string The data that has been read + * @throws TTransportException if cannot read any more data + */ + public function read($len) + { + $data = @fread($this->handle_, $len); + if ($data === false || $data === '') { + $md = stream_get_meta_data($this->handle_); + if ($md['timed_out']) { + throw new TTransportException( + 'THttpClient: timed out reading ' . $len . ' bytes from ' . + $this->host_ . ':' . $this->port_ . $this->uri_, + TTransportException::TIMED_OUT + ); + } else { + throw new TTransportException( + 'THttpClient: Could not read ' . $len . ' bytes from ' . + $this->host_ . ':' . $this->port_ . $this->uri_, + TTransportException::UNKNOWN + ); + } + } + + return $data; + } + + /** + * Writes some data into the pending buffer + * + * @param string $buf The data to write + * @throws TTransportException if writing fails + */ + public function write($buf) + { + $this->buf_ .= $buf; + } + + /** + * Opens and sends the actual request over the HTTP connection + * + * @throws TTransportException if a writing error occurs + */ + public function flush() + { + // God, PHP really has some esoteric ways of doing simple things. + $host = $this->host_ . ($this->port_ != 80 ? ':' . $this->port_ : ''); + + $headers = array(); + $defaultHeaders = array('Host' => $host, + 'Accept' => 'application/x-thrift', + 'User-Agent' => 'PHP/THttpClient', + 'Content-Type' => 'application/x-thrift', + 'Content-Length' => TStringFuncFactory::create()->strlen($this->buf_)); + foreach (array_merge($defaultHeaders, $this->headers_) as $key => $value) { + $headers[] = "$key: $value"; + } + + $options = $this->context_; + + $baseHttpOptions = isset($options["http"]) ? $options["http"] : array(); + + $httpOptions = $baseHttpOptions + array('method' => 'POST', + 'header' => implode("\r\n", $headers), + 'max_redirects' => 1, + 'content' => $this->buf_); + if ($this->timeout_ > 0) { + $httpOptions['timeout'] = $this->timeout_; + } + $this->buf_ = ''; + + $options["http"] = $httpOptions; + $contextid = stream_context_create($options); + $this->handle_ = @fopen( + $this->scheme_ . '://' . $host . $this->uri_, + 'r', + false, + $contextid + ); + + // Connect failed? + if ($this->handle_ === false) { + $this->handle_ = null; + $error = 'THttpClient: Could not connect to ' . $host . $this->uri_; + throw new TTransportException($error, TTransportException::NOT_OPEN); + } + } + + public function addHeaders($headers) + { + $this->headers_ = array_merge($this->headers_, $headers); + } +} diff --git a/vendor/packaged/thrift/src/Transport/TMemoryBuffer.php b/vendor/packaged/thrift/src/Transport/TMemoryBuffer.php new file mode 100644 index 000000000..fee03a2a4 --- /dev/null +++ b/vendor/packaged/thrift/src/Transport/TMemoryBuffer.php @@ -0,0 +1,106 @@ +buf_ = $buf; + } + + protected $buf_ = ''; + + public function isOpen() + { + return true; + } + + public function open() + { + } + + public function close() + { + } + + public function write($buf) + { + $this->buf_ .= $buf; + } + + public function read($len) + { + $bufLength = TStringFuncFactory::create()->strlen($this->buf_); + + if ($bufLength === 0) { + throw new TTransportException( + 'TMemoryBuffer: Could not read ' . + $len . ' bytes from buffer.', + TTransportException::UNKNOWN + ); + } + + if ($bufLength <= $len) { + $ret = $this->buf_; + $this->buf_ = ''; + + return $ret; + } + + $ret = TStringFuncFactory::create()->substr($this->buf_, 0, $len); + $this->buf_ = TStringFuncFactory::create()->substr($this->buf_, $len); + + return $ret; + } + + public function getBuffer() + { + return $this->buf_; + } + + public function available() + { + return TStringFuncFactory::create()->strlen($this->buf_); + } + + public function putBack($data) + { + $this->buf_ = $data . $this->buf_; + } +} diff --git a/vendor/packaged/thrift/src/Transport/TNullTransport.php b/vendor/packaged/thrift/src/Transport/TNullTransport.php new file mode 100644 index 000000000..7e086b67c --- /dev/null +++ b/vendor/packaged/thrift/src/Transport/TNullTransport.php @@ -0,0 +1,56 @@ +read_ = $mode & self::MODE_R; + $this->write_ = $mode & self::MODE_W; + } + + public function open() + { + if ($this->read_) { + $this->inStream_ = @fopen(self::inStreamName(), 'r'); + if (!is_resource($this->inStream_)) { + throw new TException('TPhpStream: Could not open php://input'); + } + } + if ($this->write_) { + $this->outStream_ = @fopen('php://output', 'w'); + if (!is_resource($this->outStream_)) { + throw new TException('TPhpStream: Could not open php://output'); + } + } + } + + public function close() + { + if ($this->read_) { + @fclose($this->inStream_); + $this->inStream_ = null; + } + if ($this->write_) { + @fclose($this->outStream_); + $this->outStream_ = null; + } + } + + public function isOpen() + { + return + (!$this->read_ || is_resource($this->inStream_)) && + (!$this->write_ || is_resource($this->outStream_)); + } + + public function read($len) + { + $data = @fread($this->inStream_, $len); + if ($data === false || $data === '') { + throw new TException('TPhpStream: Could not read ' . $len . ' bytes'); + } + + return $data; + } + + public function write($buf) + { + while (TStringFuncFactory::create()->strlen($buf) > 0) { + $got = @fwrite($this->outStream_, $buf); + if ($got === 0 || $got === false) { + throw new TException( + 'TPhpStream: Could not write ' . TStringFuncFactory::create()->strlen($buf) . ' bytes' + ); + } + $buf = TStringFuncFactory::create()->substr($buf, $got); + } + } + + public function flush() + { + @fflush($this->outStream_); + } + + private static function inStreamName() + { + if (php_sapi_name() == 'cli') { + return 'php://stdin'; + } + + return 'php://input'; + } +} diff --git a/vendor/packaged/thrift/src/Transport/TSSLSocket.php b/vendor/packaged/thrift/src/Transport/TSSLSocket.php new file mode 100644 index 000000000..b4a0adb54 --- /dev/null +++ b/vendor/packaged/thrift/src/Transport/TSSLSocket.php @@ -0,0 +1,117 @@ +host_ = $this->getSSLHost($host); + $this->port_ = $port; + $this->context_ = $context; + $this->debugHandler_ = $debugHandler ? $debugHandler : 'error_log'; + } + + /** + * Creates a host name with SSL transport protocol + * if no transport protocol already specified in + * the host name. + * + * @param string $host Host to listen on + * @return string $host Host name with transport protocol + */ + private function getSSLHost($host) + { + $transport_protocol_loc = strpos($host, "://"); + if ($transport_protocol_loc === false) { + $host = 'ssl://' . $host; + } + return $host; + } + + /** + * Connects the socket. + */ + public function open() + { + if ($this->isOpen()) { + throw new TTransportException('Socket already connected', TTransportException::ALREADY_OPEN); + } + + if (empty($this->host_)) { + throw new TTransportException('Cannot open null host', TTransportException::NOT_OPEN); + } + + if ($this->port_ <= 0) { + throw new TTransportException('Cannot open without port', TTransportException::NOT_OPEN); + } + + $this->handle_ = @stream_socket_client( + $this->host_ . ':' . $this->port_, + $errno, + $errstr, + $this->sendTimeoutSec_ + ($this->sendTimeoutUsec_ / 1000000), + STREAM_CLIENT_CONNECT, + $this->context_ + ); + + // Connect failed? + if ($this->handle_ === false) { + $error = 'TSocket: Could not connect to ' . + $this->host_ . ':' . $this->port_ . ' (' . $errstr . ' [' . $errno . '])'; + if ($this->debug_) { + call_user_func($this->debugHandler_, $error); + } + throw new TException($error); + } + } +} diff --git a/vendor/packaged/thrift/src/Transport/TSocket.php b/vendor/packaged/thrift/src/Transport/TSocket.php new file mode 100644 index 000000000..5147efa63 --- /dev/null +++ b/vendor/packaged/thrift/src/Transport/TSocket.php @@ -0,0 +1,366 @@ +host_ = $host; + $this->port_ = $port; + $this->persist_ = $persist; + $this->debugHandler_ = $debugHandler ? $debugHandler : 'error_log'; + } + + /** + * @param resource $handle + * @return void + */ + public function setHandle($handle) + { + $this->handle_ = $handle; + stream_set_blocking($this->handle_, false); + } + + /** + * Sets the send timeout. + * + * @param int $timeout Timeout in milliseconds. + */ + public function setSendTimeout($timeout) + { + $this->sendTimeoutSec_ = floor($timeout / 1000); + $this->sendTimeoutUsec_ = + ($timeout - ($this->sendTimeoutSec_ * 1000)) * 1000; + } + + /** + * Sets the receive timeout. + * + * @param int $timeout Timeout in milliseconds. + */ + public function setRecvTimeout($timeout) + { + $this->recvTimeoutSec_ = floor($timeout / 1000); + $this->recvTimeoutUsec_ = + ($timeout - ($this->recvTimeoutSec_ * 1000)) * 1000; + } + + /** + * Sets debugging output on or off + * + * @param bool $debug + */ + public function setDebug($debug) + { + $this->debug_ = $debug; + } + + /** + * Get the host that this socket is connected to + * + * @return string host + */ + public function getHost() + { + return $this->host_; + } + + /** + * Get the remote port that this socket is connected to + * + * @return int port + */ + public function getPort() + { + return $this->port_; + } + + /** + * Tests whether this is open + * + * @return bool true if the socket is open + */ + public function isOpen() + { + return is_resource($this->handle_); + } + + /** + * Connects the socket. + */ + public function open() + { + if ($this->isOpen()) { + throw new TTransportException('Socket already connected', TTransportException::ALREADY_OPEN); + } + + if (empty($this->host_)) { + throw new TTransportException('Cannot open null host', TTransportException::NOT_OPEN); + } + + if ($this->port_ <= 0) { + throw new TTransportException('Cannot open without port', TTransportException::NOT_OPEN); + } + + if ($this->persist_) { + $this->handle_ = @pfsockopen( + $this->host_, + $this->port_, + $errno, + $errstr, + $this->sendTimeoutSec_ + ($this->sendTimeoutUsec_ / 1000000) + ); + } else { + $this->handle_ = @fsockopen( + $this->host_, + $this->port_, + $errno, + $errstr, + $this->sendTimeoutSec_ + ($this->sendTimeoutUsec_ / 1000000) + ); + } + + // Connect failed? + if ($this->handle_ === false) { + $error = 'TSocket: Could not connect to ' . + $this->host_ . ':' . $this->port_ . ' (' . $errstr . ' [' . $errno . '])'; + if ($this->debug_) { + call_user_func($this->debugHandler_, $error); + } + throw new TException($error); + } + + if (function_exists('socket_import_stream') && function_exists('socket_set_option')) { + $socket = socket_import_stream($this->handle_); + socket_set_option($socket, SOL_TCP, TCP_NODELAY, 1); + } + } + + /** + * Closes the socket. + */ + public function close() + { + @fclose($this->handle_); + $this->handle_ = null; + } + + /** + * Read from the socket at most $len bytes. + * + * This method will not wait for all the requested data, it will return as + * soon as any data is received. + * + * @param int $len Maximum number of bytes to read. + * @return string Binary data + */ + public function read($len) + { + $null = null; + $read = array($this->handle_); + $readable = @stream_select( + $read, + $null, + $null, + $this->recvTimeoutSec_, + $this->recvTimeoutUsec_ + ); + + if ($readable > 0) { + $data = fread($this->handle_, $len); + if ($data === false) { + throw new TTransportException('TSocket: Could not read ' . $len . ' bytes from ' . + $this->host_ . ':' . $this->port_); + } elseif ($data == '' && feof($this->handle_)) { + throw new TTransportException('TSocket read 0 bytes'); + } + + return $data; + } elseif ($readable === 0) { + throw new TTransportException('TSocket: timed out reading ' . $len . ' bytes from ' . + $this->host_ . ':' . $this->port_); + } else { + throw new TTransportException('TSocket: Could not read ' . $len . ' bytes from ' . + $this->host_ . ':' . $this->port_); + } + } + + /** + * Write to the socket. + * + * @param string $buf The data to write + */ + public function write($buf) + { + $null = null; + $write = array($this->handle_); + + // keep writing until all the data has been written + while (TStringFuncFactory::create()->strlen($buf) > 0) { + // wait for stream to become available for writing + $writable = @stream_select( + $null, + $write, + $null, + $this->sendTimeoutSec_, + $this->sendTimeoutUsec_ + ); + if ($writable > 0) { + // write buffer to stream + $written = fwrite($this->handle_, $buf); + if ($written === -1 || $written === false) { + throw new TTransportException( + 'TSocket: Could not write ' . TStringFuncFactory::create()->strlen($buf) . ' bytes ' . + $this->host_ . ':' . $this->port_ + ); + } + // determine how much of the buffer is left to write + $buf = TStringFuncFactory::create()->substr($buf, $written); + } elseif ($writable === 0) { + throw new TTransportException( + 'TSocket: timed out writing ' . TStringFuncFactory::create()->strlen($buf) . ' bytes from ' . + $this->host_ . ':' . $this->port_ + ); + } else { + throw new TTransportException( + 'TSocket: Could not write ' . TStringFuncFactory::create()->strlen($buf) . ' bytes ' . + $this->host_ . ':' . $this->port_ + ); + } + } + } + + /** + * Flush output to the socket. + * + * Since read(), readAll() and write() operate on the sockets directly, + * this is a no-op + * + * If you wish to have flushable buffering behaviour, wrap this TSocket + * in a TBufferedTransport. + */ + public function flush() + { + // no-op + } +} diff --git a/vendor/packaged/thrift/src/Transport/TSocketPool.php b/vendor/packaged/thrift/src/Transport/TSocketPool.php new file mode 100644 index 000000000..cb9e8ddfa --- /dev/null +++ b/vendor/packaged/thrift/src/Transport/TSocketPool.php @@ -0,0 +1,310 @@ + $val) { + $ports[$key] = $port; + } + } + + foreach ($hosts as $key => $host) { + $this->servers_ [] = array('host' => $host, + 'port' => $ports[$key]); + } + } + + /** + * Add a server to the pool + * + * This function does not prevent you from adding a duplicate server entry. + * + * @param string $host hostname or IP + * @param int $port port + */ + public function addServer($host, $port) + { + $this->servers_[] = array('host' => $host, 'port' => $port); + } + + /** + * Sets how many time to keep retrying a host in the connect function. + * + * @param int $numRetries + */ + public function setNumRetries($numRetries) + { + $this->numRetries_ = $numRetries; + } + + /** + * Sets how long to wait until retrying a host if it was marked down + * + * @param int $numRetries + */ + public function setRetryInterval($retryInterval) + { + $this->retryInterval_ = $retryInterval; + } + + /** + * Sets how many time to keep retrying a host before marking it as down. + * + * @param int $numRetries + */ + public function setMaxConsecutiveFailures($maxConsecutiveFailures) + { + $this->maxConsecutiveFailures_ = $maxConsecutiveFailures; + } + + /** + * Turns randomization in connect order on or off. + * + * @param bool $randomize + */ + public function setRandomize($randomize) + { + $this->randomize_ = $randomize; + } + + /** + * Whether to always try the last server. + * + * @param bool $alwaysTryLast + */ + public function setAlwaysTryLast($alwaysTryLast) + { + $this->alwaysTryLast_ = $alwaysTryLast; + } + + /** + * Connects the socket by iterating through all the servers in the pool + * and trying to find one that works. + */ + public function open() + { + // Check if we want order randomization + if ($this->randomize_) { + shuffle($this->servers_); + } + + // Count servers to identify the "last" one + $numServers = count($this->servers_); + + for ($i = 0; $i < $numServers; ++$i) { + // This extracts the $host and $port variables + extract($this->servers_[$i]); + + // Check APC cache for a record of this server being down + $failtimeKey = 'thrift_failtime:' . $host . ':' . $port . '~'; + + // Cache miss? Assume it's OK + $lastFailtime = apc_fetch($failtimeKey); + if ($lastFailtime === false) { + $lastFailtime = 0; + } + + $retryIntervalPassed = false; + + // Cache hit...make sure enough the retry interval has elapsed + if ($lastFailtime > 0) { + $elapsed = time() - $lastFailtime; + if ($elapsed > $this->retryInterval_) { + $retryIntervalPassed = true; + if ($this->debug_) { + call_user_func( + $this->debugHandler_, + 'TSocketPool: retryInterval ' . + '(' . $this->retryInterval_ . ') ' . + 'has passed for host ' . $host . ':' . $port + ); + } + } + } + + // Only connect if not in the middle of a fail interval, OR if this + // is the LAST server we are trying, just hammer away on it + $isLastServer = false; + if ($this->alwaysTryLast_) { + $isLastServer = ($i == ($numServers - 1)); + } + + if (($lastFailtime === 0) || + ($isLastServer) || + ($lastFailtime > 0 && $retryIntervalPassed)) { + // Set underlying TSocket params to this one + $this->host_ = $host; + $this->port_ = $port; + + // Try up to numRetries_ connections per server + for ($attempt = 0; $attempt < $this->numRetries_; $attempt++) { + try { + // Use the underlying TSocket open function + parent::open(); + + // Only clear the failure counts if required to do so + if ($lastFailtime > 0) { + apc_store($failtimeKey, 0); + } + + // Successful connection, return now + return; + } catch (TException $tx) { + // Connection failed + } + } + + // Mark failure of this host in the cache + $consecfailsKey = 'thrift_consecfails:' . $host . ':' . $port . '~'; + + // Ignore cache misses + $consecfails = apc_fetch($consecfailsKey); + if ($consecfails === false) { + $consecfails = 0; + } + + // Increment by one + $consecfails++; + + // Log and cache this failure + if ($consecfails >= $this->maxConsecutiveFailures_) { + if ($this->debug_) { + call_user_func( + $this->debugHandler_, + 'TSocketPool: marking ' . $host . ':' . $port . + ' as down for ' . $this->retryInterval_ . ' secs ' . + 'after ' . $consecfails . ' failed attempts.' + ); + } + // Store the failure time + apc_store($failtimeKey, time()); + + // Clear the count of consecutive failures + apc_store($consecfailsKey, 0); + } else { + apc_store($consecfailsKey, $consecfails); + } + } + } + + // Oh no; we failed them all. The system is totally ill! + $error = 'TSocketPool: All hosts in pool are down. '; + $hosts = array(); + foreach ($this->servers_ as $server) { + $hosts [] = $server['host'] . ':' . $server['port']; + } + $hostlist = implode(',', $hosts); + $error .= '(' . $hostlist . ')'; + if ($this->debug_) { + call_user_func($this->debugHandler_, $error); + } + throw new TException($error); + } +} diff --git a/vendor/packaged/thrift/src/Transport/TTransport.php b/vendor/packaged/thrift/src/Transport/TTransport.php new file mode 100644 index 000000000..35921c666 --- /dev/null +++ b/vendor/packaged/thrift/src/Transport/TTransport.php @@ -0,0 +1,98 @@ +read($len); + + $data = ''; + $got = 0; + while (($got = TStringFuncFactory::create()->strlen($data)) < $len) { + $data .= $this->read($len - $got); + } + + return $data; + } + + /** + * Writes the given data out. + * + * @param string $buf The data to write + * @throws TTransportException if writing fails + */ + abstract public function write($buf); + + /** + * Flushes any pending data out of a buffer + * + * @throws TTransportException if a writing error occurs + */ + public function flush() + { + } +} diff --git a/vendor/packaged/thrift/src/Type/TConstant.php b/vendor/packaged/thrift/src/Type/TConstant.php new file mode 100644 index 000000000..215da4a3d --- /dev/null +++ b/vendor/packaged/thrift/src/Type/TConstant.php @@ -0,0 +1,52 @@ +=8.0.0" + }, + "autoload": { + "psr-4": { + "Psr\\Cache\\": "src/" + } + }, + "extra": { + "branch-alias": { + "dev-master": "1.0.x-dev" + } + } +} diff --git a/vendor/psr/cache/src/CacheException.php b/vendor/psr/cache/src/CacheException.php new file mode 100644 index 000000000..bb785f46c --- /dev/null +++ b/vendor/psr/cache/src/CacheException.php @@ -0,0 +1,10 @@ +logger = $logger; + } + + public function doSomething() + { + if ($this->logger) { + $this->logger->info('Doing work'); + } + + try { + $this->doSomethingElse(); + } catch (Exception $exception) { + $this->logger->error('Oh no!', array('exception' => $exception)); + } + + // do something useful + } +} +``` + +You can then pick one of the implementations of the interface to get a logger. + +If you want to implement the interface, you can require this package and +implement `Psr\Log\LoggerInterface` in your code. Please read the +[specification text](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-3-logger-interface.md) +for details. diff --git a/vendor/psr/log/composer.json b/vendor/psr/log/composer.json new file mode 100644 index 000000000..879fc6f53 --- /dev/null +++ b/vendor/psr/log/composer.json @@ -0,0 +1,26 @@ +{ + "name": "psr/log", + "description": "Common interface for logging libraries", + "keywords": ["psr", "psr-3", "log"], + "homepage": "https://github.com/php-fig/log", + "license": "MIT", + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "require": { + "php": ">=8.0.0" + }, + "autoload": { + "psr-4": { + "Psr\\Log\\": "src" + } + }, + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + } +} diff --git a/vendor/psr/log/src/AbstractLogger.php b/vendor/psr/log/src/AbstractLogger.php new file mode 100644 index 000000000..d60a091af --- /dev/null +++ b/vendor/psr/log/src/AbstractLogger.php @@ -0,0 +1,15 @@ +logger = $logger; + } +} diff --git a/vendor/psr/log/src/LoggerInterface.php b/vendor/psr/log/src/LoggerInterface.php new file mode 100644 index 000000000..b3a24b5f7 --- /dev/null +++ b/vendor/psr/log/src/LoggerInterface.php @@ -0,0 +1,125 @@ +log(LogLevel::EMERGENCY, $message, $context); + } + + /** + * Action must be taken immediately. + * + * Example: Entire website down, database unavailable, etc. This should + * trigger the SMS alerts and wake you up. + * + * @param string|\Stringable $message + * @param array $context + * + * @return void + */ + public function alert(string|\Stringable $message, array $context = []): void + { + $this->log(LogLevel::ALERT, $message, $context); + } + + /** + * Critical conditions. + * + * Example: Application component unavailable, unexpected exception. + * + * @param string|\Stringable $message + * @param array $context + * + * @return void + */ + public function critical(string|\Stringable $message, array $context = []): void + { + $this->log(LogLevel::CRITICAL, $message, $context); + } + + /** + * Runtime errors that do not require immediate action but should typically + * be logged and monitored. + * + * @param string|\Stringable $message + * @param array $context + * + * @return void + */ + public function error(string|\Stringable $message, array $context = []): void + { + $this->log(LogLevel::ERROR, $message, $context); + } + + /** + * Exceptional occurrences that are not errors. + * + * Example: Use of deprecated APIs, poor use of an API, undesirable things + * that are not necessarily wrong. + * + * @param string|\Stringable $message + * @param array $context + * + * @return void + */ + public function warning(string|\Stringable $message, array $context = []): void + { + $this->log(LogLevel::WARNING, $message, $context); + } + + /** + * Normal but significant events. + * + * @param string|\Stringable $message + * @param array $context + * + * @return void + */ + public function notice(string|\Stringable $message, array $context = []): void + { + $this->log(LogLevel::NOTICE, $message, $context); + } + + /** + * Interesting events. + * + * Example: User logs in, SQL logs. + * + * @param string|\Stringable $message + * @param array $context + * + * @return void + */ + public function info(string|\Stringable $message, array $context = []): void + { + $this->log(LogLevel::INFO, $message, $context); + } + + /** + * Detailed debug information. + * + * @param string|\Stringable $message + * @param array $context + * + * @return void + */ + public function debug(string|\Stringable $message, array $context = []): void + { + $this->log(LogLevel::DEBUG, $message, $context); + } + + /** + * Logs with an arbitrary level. + * + * @param mixed $level + * @param string|\Stringable $message + * @param array $context + * + * @return void + * + * @throws \Psr\Log\InvalidArgumentException + */ + abstract public function log($level, string|\Stringable $message, array $context = []): void; +} diff --git a/vendor/psr/log/src/NullLogger.php b/vendor/psr/log/src/NullLogger.php new file mode 100644 index 000000000..c1cc3c069 --- /dev/null +++ b/vendor/psr/log/src/NullLogger.php @@ -0,0 +1,30 @@ +logger) { }` + * blocks. + */ +class NullLogger extends AbstractLogger +{ + /** + * Logs with an arbitrary level. + * + * @param mixed $level + * @param string|\Stringable $message + * @param array $context + * + * @return void + * + * @throws \Psr\Log\InvalidArgumentException + */ + public function log($level, string|\Stringable $message, array $context = []): void + { + // noop + } +}