diff options
| author | Andrew Dolgov <fox@fakecake.org> | 2024-10-01 16:00:34 +0300 |
|---|---|---|
| committer | Andrew Dolgov <fox@fakecake.org> | 2024-10-01 16:00:34 +0300 |
| commit | 884fd92f1320d17daebb772297da03fb2cfa59b8 (patch) | |
| tree | 3aa80af1df6ffa1d70f21f9fc4411f451c8b6c56 /vendor/open-telemetry/api/Trace/SpanContext.php | |
| parent | 8fcc68baf5b0ff964a0a4a045353462586e0e316 (diff) | |
drop opentelemetry
Diffstat (limited to 'vendor/open-telemetry/api/Trace/SpanContext.php')
| -rw-r--r-- | vendor/open-telemetry/api/Trace/SpanContext.php | 127 |
1 files changed, 0 insertions, 127 deletions
diff --git a/vendor/open-telemetry/api/Trace/SpanContext.php b/vendor/open-telemetry/api/Trace/SpanContext.php deleted file mode 100644 index 7da7c0701..000000000 --- a/vendor/open-telemetry/api/Trace/SpanContext.php +++ /dev/null @@ -1,127 +0,0 @@ -<?php - -declare(strict_types=1); - -namespace OpenTelemetry\API\Trace; - -use function hex2bin; - -final class SpanContext implements SpanContextInterface -{ - private static ?SpanContextInterface $invalidContext = null; - - /** - * @see https://www.w3.org/TR/trace-context/#trace-flags - * @see https://www.w3.org/TR/trace-context/#sampled-flag - */ - private bool $isSampled; - - private string $traceId; - private string $spanId; - private ?TraceStateInterface $traceState; - private bool $isValid = true; - private bool $isRemote; - private int $traceFlags; - - private function __construct( - string $traceId, - string $spanId, - int $traceFlags, - bool $isRemote, - TraceStateInterface $traceState = null - ) { - // TraceId must be exactly 16 bytes (32 chars) and at least one non-zero byte - // SpanId must be exactly 8 bytes (16 chars) and at least one non-zero byte - if (!SpanContextValidator::isValidTraceId($traceId) || !SpanContextValidator::isValidSpanId($spanId)) { - $traceId = SpanContextValidator::INVALID_TRACE; - $spanId = SpanContextValidator::INVALID_SPAN; - $this->isValid=false; - } - - $this->traceId = $traceId; - $this->spanId = $spanId; - $this->traceState = $traceState; - $this->isRemote = $isRemote; - $this->isSampled = ($traceFlags & TraceFlags::SAMPLED) === TraceFlags::SAMPLED; - $this->traceFlags = $traceFlags; - } - - public function getTraceId(): string - { - return $this->traceId; - } - - public function getTraceIdBinary(): string - { - return hex2bin($this->traceId); - } - - public function getSpanId(): string - { - return $this->spanId; - } - - public function getSpanIdBinary(): string - { - return hex2bin($this->spanId); - } - - public function getTraceState(): ?TraceStateInterface - { - return $this->traceState; - } - - public function isSampled(): bool - { - return $this->isSampled; - } - - public function isValid(): bool - { - return $this->isValid; - } - - public function isRemote(): bool - { - return $this->isRemote; - } - - public function getTraceFlags(): int - { - return $this->traceFlags; - } - - /** @inheritDoc */ - public static function createFromRemoteParent(string $traceId, string $spanId, int $traceFlags = TraceFlags::DEFAULT, ?TraceStateInterface $traceState = null): SpanContextInterface - { - return new self( - $traceId, - $spanId, - $traceFlags, - true, - $traceState, - ); - } - - /** @inheritDoc */ - public static function create(string $traceId, string $spanId, int $traceFlags = TraceFlags::DEFAULT, ?TraceStateInterface $traceState = null): SpanContextInterface - { - return new self( - $traceId, - $spanId, - $traceFlags, - false, - $traceState, - ); - } - - /** @inheritDoc */ - public static function getInvalid(): SpanContextInterface - { - if (null === self::$invalidContext) { - self::$invalidContext = self::create(SpanContextValidator::INVALID_TRACE, SpanContextValidator::INVALID_SPAN, 0); - } - - return self::$invalidContext; - } -} |