From 8f3646a9c93a06f76f6abb31020fdb74b4b1fc59 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sun, 9 Apr 2023 20:50:33 +0300 Subject: exp: jaeger tracing --- .../src/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 +++++++++++++++++ .../jaeger-client-php/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 ++ .../ReporterFactory/AbstractReporterFactory.php | 23 + .../ReporterFactory/JaegerHttpReporterFactory.php | 35 ++ .../ReporterFactory/JaegerReporterFactory.php | 44 ++ .../ReporterFactory/ReporterFactoryInterface.php | 10 + .../ReporterFactory/ZipkinReporterFactory.php | 46 ++ .../src/Jaeger/Sampler/ConstSampler.php | 68 +++ .../src/Jaeger/Sampler/ProbabilisticSampler.php | 88 ++++ .../src/Jaeger/Sampler/RateLimitingSampler.php | 62 +++ .../src/Jaeger/Sampler/SamplerInterface.php | 29 ++ .../jaeger-client-php/src/Jaeger/Scope.php | 71 +++ .../jaeger-client-php/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 +++++++++++++++++++++ .../jaeger-client-php/src/Jaeger/SpanContext.php | 120 ++++++ .../src/Jaeger/Thrift/Agent/AgentClient.php | 76 ++++ .../src/Jaeger/Thrift/Agent/AgentIf.php | 30 ++ .../Jaeger/Thrift/Agent/Agent_emitBatch_args.php | 56 +++ .../Thrift/Agent/Agent_emitZipkinBatch_args.php | 60 +++ .../Thrift/Agent/AggregationValidatorClient.php | 83 ++++ .../Jaeger/Thrift/Agent/AggregationValidatorIf.php | 27 ++ .../AggregationValidator_validateTrace_args.php | 55 +++ .../AggregationValidator_validateTrace_result.php | 56 +++ .../src/Jaeger/Thrift/Agent/BaggageRestriction.php | 65 +++ .../Agent/BaggageRestrictionManagerClient.php | 83 ++++ .../Thrift/Agent/BaggageRestrictionManagerIf.php | 31 ++ ...trictionManager_getBaggageRestrictions_args.php | 55 +++ ...ictionManager_getBaggageRestrictions_result.php | 60 +++ .../src/Jaeger/Thrift/Agent/Dependencies.php | 61 +++ .../src/Jaeger/Thrift/Agent/DependencyClient.php | 105 +++++ .../src/Jaeger/Thrift/Agent/DependencyIf.php | 31 ++ .../src/Jaeger/Thrift/Agent/DependencyLink.php | 74 ++++ .../Dependency_getDependenciesForTrace_args.php | 55 +++ .../Dependency_getDependenciesForTrace_result.php | 56 +++ .../Agent/Dependency_saveDependencies_args.php | 56 +++ .../Thrift/Agent/OperationSamplingStrategy.php | 66 +++ .../Agent/PerOperationSamplingStrategies.php | 88 ++++ .../Thrift/Agent/ProbabilisticSamplingStrategy.php | 56 +++ .../Thrift/Agent/RateLimitingSamplingStrategy.php | 56 +++ .../Jaeger/Thrift/Agent/SamplingManagerClient.php | 83 ++++ .../src/Jaeger/Thrift/Agent/SamplingManagerIf.php | 27 ++ .../SamplingManager_getSamplingStrategy_args.php | 55 +++ .../SamplingManager_getSamplingStrategy_result.php | 56 +++ .../Thrift/Agent/SamplingStrategyResponse.php | 86 ++++ .../Jaeger/Thrift/Agent/SamplingStrategyType.php | 28 ++ .../Jaeger/Thrift/Agent/ValidateTraceResponse.php | 65 +++ .../src/Jaeger/Thrift/Agent/Zipkin/Annotation.php | 87 ++++ .../Jaeger/Thrift/Agent/Zipkin/AnnotationType.php | 38 ++ .../Thrift/Agent/Zipkin/BinaryAnnotation.php | 106 +++++ .../src/Jaeger/Thrift/Agent/Zipkin/Constant.php | 246 +++++++++++ .../src/Jaeger/Thrift/Agent/Zipkin/Endpoint.php | 108 +++++ .../src/Jaeger/Thrift/Agent/Zipkin/Response.php | 56 +++ .../src/Jaeger/Thrift/Agent/Zipkin/Span.php | 190 ++++++++ .../Thrift/Agent/Zipkin/ZipkinCollectorClient.php | 83 ++++ .../Thrift/Agent/Zipkin/ZipkinCollectorIf.php | 27 ++ .../ZipkinCollector_submitZipkinBatch_args.php | 60 +++ .../ZipkinCollector_submitZipkinBatch_result.php | 60 +++ .../jaeger-client-php/src/Jaeger/Thrift/Batch.php | 71 +++ .../src/Jaeger/Thrift/BatchSubmitResponse.php | 56 +++ .../src/Jaeger/Thrift/CollectorClient.php | 83 ++++ .../src/Jaeger/Thrift/CollectorIf.php | 27 ++ .../Jaeger/Thrift/Collector_submitBatches_args.php | 60 +++ .../Thrift/Collector_submitBatches_result.php | 60 +++ .../src/Jaeger/Thrift/Crossdock/Downstream.php | 102 +++++ .../Jaeger/Thrift/Crossdock/JoinTraceRequest.php | 66 +++ .../src/Jaeger/Thrift/Crossdock/ObservedSpan.php | 74 ++++ .../Jaeger/Thrift/Crossdock/StartTraceRequest.php | 84 ++++ .../src/Jaeger/Thrift/Crossdock/TraceResponse.php | 82 ++++ .../Thrift/Crossdock/TracedServiceClient.php | 134 ++++++ .../Jaeger/Thrift/Crossdock/TracedServiceIf.php | 40 ++ .../Crossdock/TracedService_joinTrace_args.php | 56 +++ .../Crossdock/TracedService_joinTrace_result.php | 56 +++ .../Crossdock/TracedService_startTrace_args.php | 56 +++ .../Crossdock/TracedService_startTrace_result.php | 56 +++ .../src/Jaeger/Thrift/Crossdock/Transport.php | 30 ++ .../jaeger-client-php/src/Jaeger/Thrift/Log.php | 70 +++ .../src/Jaeger/Thrift/Process.php | 70 +++ .../jaeger-client-php/src/Jaeger/Thrift/Span.php | 161 +++++++ .../src/Jaeger/Thrift/SpanRef.php | 83 ++++ .../src/Jaeger/Thrift/SpanRefType.php | 28 ++ .../jaeger-client-php/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 ++++++ 102 files changed, 8383 insertions(+) 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 (limited to 'vendor/jonahgeorge/jaeger-client-php/src/Jaeger') 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(); + } +} -- cgit v1.2.3