diff --git a/class_map/GlobalTracer.php b/class_map/GlobalTracer.php index a52c4b5..1435219 100644 --- a/class_map/GlobalTracer.php +++ b/class_map/GlobalTracer.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace OpenTracing; use Hyperf\Tracer\TracerContext; diff --git a/class_map/Map.php b/class_map/Map.php index 26d3a8a..be7bde9 100644 --- a/class_map/Map.php +++ b/class_map/Map.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Zipkin\Propagation; use ArrayAccess; @@ -56,7 +57,6 @@ public function get($carrier, string $key): ?string } /** - * {@inheritdoc} * @param array|ArrayAccess $carrier */ public function put(&$carrier, string $key, string $value): void diff --git a/class_map/ThriftUdpTransport.php b/class_map/ThriftUdpTransport.php index 90308d6..b22f3ee 100644 --- a/class_map/ThriftUdpTransport.php +++ b/class_map/ThriftUdpTransport.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Jaeger; use Hyperf\Context\ApplicationContext; diff --git a/publish/opentracing.php b/publish/opentracing.php index 104de6f..b0a2b4e 100644 --- a/publish/opentracing.php +++ b/publish/opentracing.php @@ -9,6 +9,12 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ +use Hyperf\Tracer\Adapter\JaegerTracerFactory; +use Hyperf\Tracer\Adapter\NoOpTracerFactory; +use Hyperf\Tracer\Adapter\Reporter\Kafka; +use Hyperf\Tracer\Adapter\ZipkinTracerFactory; +use Zipkin\Reporters\Http; +use Zipkin\Reporters\Noop; use Zipkin\Samplers\BinarySampler; use function Hyperf\Support\env; @@ -30,7 +36,7 @@ ], 'tracer' => [ 'zipkin' => [ - 'driver' => Hyperf\Tracer\Adapter\ZipkinTracerFactory::class, + 'driver' => ZipkinTracerFactory::class, 'app' => [ 'name' => env('APP_NAME', 'skeleton'), // Hyperf will detect the system info automatically as the value if ipv4, ipv6, port is null @@ -42,7 +48,7 @@ 'reporters' => [ // options for http reporter 'http' => [ - 'class' => \Zipkin\Reporters\Http::class, + 'class' => Http::class, 'constructor' => [ 'options' => [ 'endpoint_url' => env('ZIPKIN_ENDPOINT_URL', 'http://localhost:9411/api/v2/spans'), @@ -52,7 +58,7 @@ ], // options for kafka reporter 'kafka' => [ - 'class' => \Hyperf\Tracer\Adapter\Reporter\Kafka::class, + 'class' => Kafka::class, 'constructor' => [ 'options' => [ 'topic' => env('ZIPKIN_KAFKA_TOPIC', 'zipkin'), @@ -64,13 +70,13 @@ ], ], 'noop' => [ - 'class' => \Zipkin\Reporters\Noop::class, + 'class' => Noop::class, ], ], 'sampler' => BinarySampler::createAsAlwaysSample(), ], 'jaeger' => [ - 'driver' => Hyperf\Tracer\Adapter\JaegerTracerFactory::class, + 'driver' => JaegerTracerFactory::class, 'name' => env('APP_NAME', 'skeleton'), 'options' => [ /* @@ -90,7 +96,7 @@ ], ], 'noop' => [ - 'driver' => Hyperf\Tracer\Adapter\NoOpTracerFactory::class, + 'driver' => NoOpTracerFactory::class, ], ], 'tags' => [ diff --git a/src/Adapter/HttpClientFactory.php b/src/Adapter/HttpClientFactory.php index 0eb6d4e..30d92b5 100644 --- a/src/Adapter/HttpClientFactory.php +++ b/src/Adapter/HttpClientFactory.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Tracer\Adapter; /** diff --git a/src/Adapter/JaegerTracerFactory.php b/src/Adapter/JaegerTracerFactory.php index d7ccf0e..3383413 100644 --- a/src/Adapter/JaegerTracerFactory.php +++ b/src/Adapter/JaegerTracerFactory.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Tracer\Adapter; use Hyperf\Contract\ConfigInterface; diff --git a/src/Adapter/NoOpTracerFactory.php b/src/Adapter/NoOpTracerFactory.php index 840b395..d97829d 100644 --- a/src/Adapter/NoOpTracerFactory.php +++ b/src/Adapter/NoOpTracerFactory.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Tracer\Adapter; use Hyperf\Tracer\Contract\NamedFactoryInterface; diff --git a/src/Adapter/Reporter/HttpClientFactory.php b/src/Adapter/Reporter/HttpClientFactory.php index 605cabc..64ce1e4 100644 --- a/src/Adapter/Reporter/HttpClientFactory.php +++ b/src/Adapter/Reporter/HttpClientFactory.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Tracer\Adapter\Reporter; use Closure; diff --git a/src/Adapter/Reporter/Kafka.php b/src/Adapter/Reporter/Kafka.php index d26e133..11f5a15 100644 --- a/src/Adapter/Reporter/Kafka.php +++ b/src/Adapter/Reporter/Kafka.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Tracer\Adapter\Reporter; use Psr\Log\LoggerInterface; diff --git a/src/Adapter/Reporter/KafkaClientFactory.php b/src/Adapter/Reporter/KafkaClientFactory.php index 4a6cf8a..cad88e9 100644 --- a/src/Adapter/Reporter/KafkaClientFactory.php +++ b/src/Adapter/Reporter/KafkaClientFactory.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Tracer\Adapter\Reporter; use Closure; diff --git a/src/Adapter/Reporter/ReporterFactory.php b/src/Adapter/Reporter/ReporterFactory.php index ec8b88c..6fc17df 100644 --- a/src/Adapter/Reporter/ReporterFactory.php +++ b/src/Adapter/Reporter/ReporterFactory.php @@ -9,12 +9,14 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Tracer\Adapter\Reporter; use Hyperf\Contract\StdoutLoggerInterface; use Psr\Container\ContainerInterface; use RuntimeException; use Zipkin\Reporter; +use Zipkin\Reporters\Http; use function Hyperf\Support\make; @@ -38,7 +40,7 @@ public function make(array $option = []): Reporter throw new RuntimeException('Unsupported reporter.'); } - if ($class === \Zipkin\Reporters\Http::class) { + if ($class === Http::class) { $constructor['requesterFactory'] = $this->container->get(HttpClientFactory::class); } diff --git a/src/Adapter/ZipkinTracerFactory.php b/src/Adapter/ZipkinTracerFactory.php index 9f66e58..6b1f8fb 100644 --- a/src/Adapter/ZipkinTracerFactory.php +++ b/src/Adapter/ZipkinTracerFactory.php @@ -9,12 +9,14 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Tracer\Adapter; use Hyperf\Contract\ConfigInterface; use Hyperf\Tracer\Adapter\Reporter\ReporterFactory; use Hyperf\Tracer\Contract\NamedFactoryInterface; use Zipkin\Endpoint; +use Zipkin\Reporters\Http; use Zipkin\Samplers\BinarySampler; use Zipkin\TracingBuilder; use ZipkinOpenTracing\Tracer; @@ -56,7 +58,7 @@ private function parseConfig(): array ]), $this->getConfig('sampler', BinarySampler::createAsAlwaysSample()), $this->getConfig('reporters.' . $reporter, [ - 'class' => \Zipkin\Reporters\Http::class, + 'class' => Http::class, 'constructor' => [ 'options' => $this->getConfig('options', []), ], diff --git a/src/Annotation/Trace.php b/src/Annotation/Trace.php index 7cae4fe..11198ce 100644 --- a/src/Annotation/Trace.php +++ b/src/Annotation/Trace.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Tracer\Annotation; use Attribute; diff --git a/src/Aspect/CoroutineAspect.php b/src/Aspect/CoroutineAspect.php index 3536ce1..fca8933 100644 --- a/src/Aspect/CoroutineAspect.php +++ b/src/Aspect/CoroutineAspect.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Tracer\Aspect; use Hyperf\Di\Aop\AbstractAspect; diff --git a/src/Aspect/CreateTraceContextAspect.php b/src/Aspect/CreateTraceContextAspect.php index 24bf7ee..380bd98 100644 --- a/src/Aspect/CreateTraceContextAspect.php +++ b/src/Aspect/CreateTraceContextAspect.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Tracer\Aspect; use Hyperf\Di\Aop\AbstractAspect; diff --git a/src/Aspect/DbAspect.php b/src/Aspect/DbAspect.php index c5c0dda..d152e60 100644 --- a/src/Aspect/DbAspect.php +++ b/src/Aspect/DbAspect.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Tracer\Aspect; use Hyperf\DB\DB; diff --git a/src/Aspect/ElasticserachAspect.php b/src/Aspect/ElasticserachAspect.php index e38ceb9..419cc55 100644 --- a/src/Aspect/ElasticserachAspect.php +++ b/src/Aspect/ElasticserachAspect.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Tracer\Aspect; use Elasticsearch\Client; diff --git a/src/Aspect/GrpcAspect.php b/src/Aspect/GrpcAspect.php index 1ec5f0e..cbdc554 100644 --- a/src/Aspect/GrpcAspect.php +++ b/src/Aspect/GrpcAspect.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Tracer\Aspect; use Hyperf\Context\Context as CT; diff --git a/src/Aspect/HttpClientAspect.php b/src/Aspect/HttpClientAspect.php index 40602ff..dfc5370 100644 --- a/src/Aspect/HttpClientAspect.php +++ b/src/Aspect/HttpClientAspect.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Tracer\Aspect; use GuzzleHttp\Client; diff --git a/src/Aspect/JsonRpcAspect.php b/src/Aspect/JsonRpcAspect.php index 57d5be4..a65a5c6 100644 --- a/src/Aspect/JsonRpcAspect.php +++ b/src/Aspect/JsonRpcAspect.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Tracer\Aspect; /** diff --git a/src/Aspect/MethodAspect.php b/src/Aspect/MethodAspect.php index b32a54a..099c6b9 100644 --- a/src/Aspect/MethodAspect.php +++ b/src/Aspect/MethodAspect.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Tracer\Aspect; use Hyperf\Di\Aop\AbstractAspect; diff --git a/src/Aspect/RedisAspect.php b/src/Aspect/RedisAspect.php index 782725e..641a07d 100644 --- a/src/Aspect/RedisAspect.php +++ b/src/Aspect/RedisAspect.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Tracer\Aspect; use Hyperf\Di\Aop\AbstractAspect; diff --git a/src/Aspect/RpcAspect.php b/src/Aspect/RpcAspect.php index f903e66..a2bb5b7 100644 --- a/src/Aspect/RpcAspect.php +++ b/src/Aspect/RpcAspect.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Tracer\Aspect; use Hyperf\Context\Context as CT; diff --git a/src/Aspect/TraceAnnotationAspect.php b/src/Aspect/TraceAnnotationAspect.php index 0e44cb1..3e14c45 100644 --- a/src/Aspect/TraceAnnotationAspect.php +++ b/src/Aspect/TraceAnnotationAspect.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Tracer\Aspect; use Hyperf\Di\Aop\AbstractAspect; diff --git a/src/ConfigProvider.php b/src/ConfigProvider.php index 257a5d4..e98107c 100644 --- a/src/ConfigProvider.php +++ b/src/ConfigProvider.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Tracer; use GuzzleHttp\Client; diff --git a/src/Contract/NamedFactoryInterface.php b/src/Contract/NamedFactoryInterface.php index cfe81b5..ec81b3e 100644 --- a/src/Contract/NamedFactoryInterface.php +++ b/src/Contract/NamedFactoryInterface.php @@ -9,12 +9,15 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Tracer\Contract; +use OpenTracing\Tracer; + interface NamedFactoryInterface { /** * Create the object from factory. */ - public function make(string $name): \OpenTracing\Tracer; + public function make(string $name): Tracer; } diff --git a/src/Exception/ConnectionClosedException.php b/src/Exception/ConnectionClosedException.php index 427191a..051ca9b 100644 --- a/src/Exception/ConnectionClosedException.php +++ b/src/Exception/ConnectionClosedException.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Tracer\Exception; use RuntimeException; diff --git a/src/Exception/InvalidArgumentException.php b/src/Exception/InvalidArgumentException.php index 07bd8f0..abcb97c 100644 --- a/src/Exception/InvalidArgumentException.php +++ b/src/Exception/InvalidArgumentException.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Tracer\Exception; class InvalidArgumentException extends \InvalidArgumentException diff --git a/src/Exception/TimeoutException.php b/src/Exception/TimeoutException.php index ecdffed..0466190 100644 --- a/src/Exception/TimeoutException.php +++ b/src/Exception/TimeoutException.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Tracer\Exception; use RuntimeException; diff --git a/src/Listener/DbQueryExecutedListener.php b/src/Listener/DbQueryExecutedListener.php index 74c2fcc..23b35b7 100644 --- a/src/Listener/DbQueryExecutedListener.php +++ b/src/Listener/DbQueryExecutedListener.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Tracer\Listener; use Hyperf\Collection\Arr; diff --git a/src/Listener/RequestTraceListener.php b/src/Listener/RequestTraceListener.php index 8a8b68f..f5630a8 100644 --- a/src/Listener/RequestTraceListener.php +++ b/src/Listener/RequestTraceListener.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Tracer\Listener; use Hyperf\Coroutine\Coroutine; diff --git a/src/Middleware/TraceMiddleware.php b/src/Middleware/TraceMiddleware.php index 92a816e..594e962 100644 --- a/src/Middleware/TraceMiddleware.php +++ b/src/Middleware/TraceMiddleware.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Tracer\Middleware; use Hyperf\Coroutine\Coroutine; @@ -48,7 +49,7 @@ public function process(ServerRequestInterface $request, RequestHandlerInterface defer(function () use ($tracer) { try { $tracer->flush(); - } catch (\Throwable) { + } catch (Throwable) { } }); try { diff --git a/src/SpanStarter.php b/src/SpanStarter.php index d2339c6..e6ccf8e 100644 --- a/src/SpanStarter.php +++ b/src/SpanStarter.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Tracer; use Hyperf\Context\ApplicationContext; diff --git a/src/SpanTagManager.php b/src/SpanTagManager.php index 07f3bbf..285d1cd 100644 --- a/src/SpanTagManager.php +++ b/src/SpanTagManager.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Tracer; class SpanTagManager diff --git a/src/SpanTagManagerFactory.php b/src/SpanTagManagerFactory.php index d673295..94e722d 100644 --- a/src/SpanTagManagerFactory.php +++ b/src/SpanTagManagerFactory.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Tracer; use Hyperf\Contract\ConfigInterface; diff --git a/src/SwitchManager.php b/src/SwitchManager.php index ebe8d2c..4e690cd 100644 --- a/src/SwitchManager.php +++ b/src/SwitchManager.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Tracer; use Hyperf\Context\Context; @@ -51,7 +52,7 @@ public function isEnable(string $identifier): bool return $this->config[$identifier] && Context::get('tracer.root') instanceof Span; } - public function isIgnoreException(Throwable|string $exception): bool + public function isIgnoreException(string|Throwable $exception): bool { $ignoreExceptions = $this->config['ignore_exceptions'] ?? []; foreach ($ignoreExceptions as $ignoreException) { diff --git a/src/SwitchManagerFactory.php b/src/SwitchManagerFactory.php index 1e1176d..68bf659 100644 --- a/src/SwitchManagerFactory.php +++ b/src/SwitchManagerFactory.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Tracer; use Hyperf\Contract\ConfigInterface; diff --git a/src/TracerContext.php b/src/TracerContext.php index 5e2af2e..13b3e25 100644 --- a/src/TracerContext.php +++ b/src/TracerContext.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Tracer; use Hyperf\Context\Context; diff --git a/src/TracerFactory.php b/src/TracerFactory.php index 43e8b5f..d3cc77f 100644 --- a/src/TracerFactory.php +++ b/src/TracerFactory.php @@ -9,6 +9,7 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace Hyperf\Tracer; use Hyperf\Contract\ConfigInterface; diff --git a/tests/TracerFactoryTest.php b/tests/TracerFactoryTest.php index 6fd10bd..636e930 100644 --- a/tests/TracerFactoryTest.php +++ b/tests/TracerFactoryTest.php @@ -9,16 +9,26 @@ * @contact group@hyperf.io * @license https://github.com/hyperf/hyperf/blob/master/LICENSE */ + namespace HyperfTest\Tracer; use Hyperf\Config\Config; use Hyperf\Context\ApplicationContext; +use Hyperf\Contract\ConfigInterface; use Hyperf\Di\Container; +use Hyperf\Tracer\Adapter\JaegerTracerFactory; +use Hyperf\Tracer\Adapter\NoOpTracerFactory; +use Hyperf\Tracer\Adapter\Reporter\HttpClientFactory; +use Hyperf\Tracer\Adapter\Reporter\ReporterFactory; +use Hyperf\Tracer\Adapter\ZipkinTracerFactory; use Hyperf\Tracer\TracerFactory; use Mockery; +use OpenTracing\NoopTracer; use PHPUnit\Framework\Attributes\CoversNothing; use PHPUnit\Framework\TestCase; +use Zipkin\Reporters\Http; use Zipkin\Samplers\BinarySampler; +use ZipkinOpenTracing\Tracer; use function Hyperf\Support\env; @@ -57,7 +67,7 @@ public function testOldSetting() $container = $this->getContainer($config); $factory = new TracerFactory(); - $this->assertInstanceOf(\ZipkinOpenTracing\Tracer::class, $factory($container)); + $this->assertInstanceOf(Tracer::class, $factory($container)); } public function testZipkinFactory() @@ -69,7 +79,7 @@ public function testZipkinFactory() ], 'tracer' => [ 'zipkin' => [ - 'driver' => \Hyperf\Tracer\Adapter\ZipkinTracerFactory::class, + 'driver' => ZipkinTracerFactory::class, 'app' => [ 'name' => 'skeleton', // Hyperf will detect the system info automatically as the value if ipv4, ipv6, port is null @@ -82,13 +92,13 @@ public function testZipkinFactory() 'sampler' => BinarySampler::createAsAlwaysSample(), ], 'jaeger' => [ - 'driver' => \Hyperf\Tracer\Adapter\JaegerTracerFactory::class, + 'driver' => JaegerTracerFactory::class, 'name' => 'skeleton', 'options' => [ ], ], 'noop' => [ - 'driver' => \Hyperf\Tracer\Adapter\NoOpTracerFactory::class, + 'driver' => NoOpTracerFactory::class, ], ], ], @@ -96,7 +106,7 @@ public function testZipkinFactory() $container = $this->getContainer($config); $factory = new TracerFactory(); - $this->assertInstanceOf(\ZipkinOpenTracing\Tracer::class, $factory($container)); + $this->assertInstanceOf(Tracer::class, $factory($container)); } public function testJaegerFactory() @@ -108,7 +118,7 @@ public function testJaegerFactory() ], 'tracer' => [ 'zipkin' => [ - 'driver' => \Hyperf\Tracer\Adapter\ZipkinTracerFactory::class, + 'driver' => ZipkinTracerFactory::class, 'app' => [ 'name' => 'skeleton', // Hyperf will detect the system info automatically as the value if ipv4, ipv6, port is null @@ -121,13 +131,13 @@ public function testJaegerFactory() 'sampler' => BinarySampler::createAsAlwaysSample(), ], 'jaeger' => [ - 'driver' => \Hyperf\Tracer\Adapter\JaegerTracerFactory::class, + 'driver' => JaegerTracerFactory::class, 'name' => 'skeleton', 'options' => [ ], ], 'noop' => [ - 'driver' => \Hyperf\Tracer\Adapter\NoOpTracerFactory::class, + 'driver' => NoOpTracerFactory::class, ], ], ], @@ -147,7 +157,7 @@ public function testNoOpFactory() ], 'tracer' => [ 'zipkin' => [ - 'driver' => \Hyperf\Tracer\Adapter\ZipkinTracerFactory::class, + 'driver' => ZipkinTracerFactory::class, 'app' => [ 'name' => 'skeleton', // Hyperf will detect the system info automatically as the value if ipv4, ipv6, port is null @@ -160,13 +170,13 @@ public function testNoOpFactory() 'sampler' => BinarySampler::createAsAlwaysSample(), ], 'jaeger' => [ - 'driver' => \Hyperf\Tracer\Adapter\JaegerTracerFactory::class, + 'driver' => JaegerTracerFactory::class, 'name' => 'skeleton', 'options' => [ ], ], 'noop' => [ - 'driver' => \Hyperf\Tracer\Adapter\NoOpTracerFactory::class, + 'driver' => NoOpTracerFactory::class, ], ], ], @@ -174,28 +184,28 @@ public function testNoOpFactory() $container = $this->getContainer($config); $factory = new TracerFactory(); - $this->assertInstanceOf(\OpenTracing\NoopTracer::class, $factory($container)); + $this->assertInstanceOf(NoopTracer::class, $factory($container)); } protected function getContainer($config) { $container = Mockery::mock(Container::class); - $client = Mockery::mock(\Hyperf\Tracer\Adapter\Reporter\HttpClientFactory::class); - $reporter = Mockery::mock(\Hyperf\Tracer\Adapter\Reporter\ReporterFactory::class); + $client = Mockery::mock(HttpClientFactory::class); + $reporter = Mockery::mock(ReporterFactory::class); $reporter->shouldReceive('make') - ->andReturn(new \Zipkin\Reporters\Http([], $client)); + ->andReturn(new Http([], $client)); $container->shouldReceive('get') - ->with(\Hyperf\Tracer\Adapter\ZipkinTracerFactory::class) - ->andReturn(new \Hyperf\Tracer\Adapter\ZipkinTracerFactory($config, $reporter)); + ->with(ZipkinTracerFactory::class) + ->andReturn(new ZipkinTracerFactory($config, $reporter)); $container->shouldReceive('get') - ->with(\Hyperf\Tracer\Adapter\JaegerTracerFactory::class) - ->andReturn(new \Hyperf\Tracer\Adapter\JaegerTracerFactory($config)); + ->with(JaegerTracerFactory::class) + ->andReturn(new JaegerTracerFactory($config)); $container->shouldReceive('get') - ->with(\Hyperf\Tracer\Adapter\NoOpTracerFactory::class) - ->andReturn(new \Hyperf\Tracer\Adapter\NoOpTracerFactory()); + ->with(NoOpTracerFactory::class) + ->andReturn(new NoOpTracerFactory()); $container->shouldReceive('get') - ->with(\Hyperf\Contract\ConfigInterface::class) + ->with(ConfigInterface::class) ->andReturn($config); ApplicationContext::setContainer($container);