-
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into 3.1-merge
- Loading branch information
Showing
9 changed files
with
236 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* This file is part of Hyperf. | ||
* | ||
* @link https://www.hyperf.io | ||
* @document https://hyperf.wiki | ||
* @contact [email protected] | ||
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE | ||
*/ | ||
namespace OpenTracing; | ||
|
||
use Hyperf\Tracer\TracerContext; | ||
|
||
final class GlobalTracer | ||
{ | ||
/** | ||
* @var Tracer | ||
*/ | ||
private static $instance; | ||
|
||
/** | ||
* @var bool | ||
*/ | ||
private static $isRegistered = false; | ||
|
||
/** | ||
* GlobalTracer::set sets the [singleton] Tracer returned by get(). | ||
* Those who use GlobalTracer (rather than directly manage a Tracer instance) | ||
* should call GlobalTracer::set as early as possible in bootstrap, prior to | ||
* start a new span. Prior to calling GlobalTracer::set, any Spans started | ||
* via the `Tracer::startActiveSpan` (etc) globals are noops. | ||
*/ | ||
public static function set(Tracer $tracer): void | ||
{ | ||
TracerContext::setTracer($tracer); | ||
self::$isRegistered = true; | ||
} | ||
|
||
/** | ||
* GlobalTracer::get returns the global singleton `Tracer` implementation. | ||
* Before `GlobalTracer::set` is called, the `GlobalTracer::get` is a noop | ||
* implementation that drops all data handed to it. | ||
*/ | ||
public static function get(): Tracer | ||
{ | ||
return TracerContext::getTracer(); | ||
} | ||
|
||
/** | ||
* Returns true if a global tracer has been registered, otherwise returns false. | ||
*/ | ||
public static function isRegistered(): bool | ||
{ | ||
return self::$isRegistered; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* This file is part of Hyperf. | ||
* | ||
* @link https://www.hyperf.io | ||
* @document https://hyperf.wiki | ||
* @contact [email protected] | ||
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE | ||
*/ | ||
namespace Hyperf\Tracer\Aspect; | ||
|
||
use Hyperf\Di\Aop\AbstractAspect; | ||
use Hyperf\Di\Aop\ProceedingJoinPoint; | ||
use Hyperf\Tracer\TracerContext; | ||
use Zipkin\Propagation\TraceContext; | ||
|
||
class CreateTraceContextAspect extends AbstractAspect | ||
{ | ||
public array $classes = [ | ||
TraceContext::class . '::create', | ||
TraceContext::class . '::create*', | ||
]; | ||
|
||
public function process(ProceedingJoinPoint $proceedingJoinPoint) | ||
{ | ||
$traceContext = $proceedingJoinPoint->process(); | ||
if ($traceContext instanceof TraceContext) { | ||
TracerContext::setTraceId($traceContext->getTraceId()); | ||
} | ||
return $traceContext; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* This file is part of Hyperf. | ||
* | ||
* @link https://www.hyperf.io | ||
* @document https://hyperf.wiki | ||
* @contact [email protected] | ||
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE | ||
*/ | ||
namespace Hyperf\Tracer\Exception; | ||
|
||
use RuntimeException; | ||
|
||
class ConnectionClosedException extends RuntimeException | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
/** | ||
* This file is part of Hyperf. | ||
* | ||
* @link https://www.hyperf.io | ||
* @document https://hyperf.wiki | ||
* @contact [email protected] | ||
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE | ||
*/ | ||
namespace Hyperf\Tracer\Exception; | ||
|
||
use RuntimeException; | ||
|
||
class TimeoutException extends RuntimeException | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters