From 884fd92f1320d17daebb772297da03fb2cfa59b8 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Tue, 1 Oct 2024 16:00:34 +0300 Subject: drop opentelemetry --- .../open-telemetry/api/Trace/NonRecordingSpan.php | 76 --------- .../open-telemetry/api/Trace/NoopSpanBuilder.php | 65 ------- vendor/open-telemetry/api/Trace/NoopTracer.php | 26 --- .../api/Trace/NoopTracerProvider.php | 17 -- .../Trace/Propagation/TraceContextPropagator.php | 157 ----------------- .../Trace/Propagation/TraceContextValidator.php | 31 ---- vendor/open-telemetry/api/Trace/Span.php | 59 ------- .../api/Trace/SpanBuilderInterface.php | 51 ------ vendor/open-telemetry/api/Trace/SpanContext.php | 127 -------------- .../api/Trace/SpanContextInterface.php | 28 --- .../api/Trace/SpanContextValidator.php | 35 ---- vendor/open-telemetry/api/Trace/SpanInterface.php | 96 ----------- vendor/open-telemetry/api/Trace/SpanKind.php | 17 -- vendor/open-telemetry/api/Trace/StatusCode.php | 15 -- vendor/open-telemetry/api/Trace/TraceFlags.php | 11 -- vendor/open-telemetry/api/Trace/TraceState.php | 190 --------------------- .../api/Trace/TraceStateInterface.php | 61 ------- .../open-telemetry/api/Trace/TracerInterface.php | 11 -- .../api/Trace/TracerProviderInterface.php | 19 --- vendor/open-telemetry/api/Trace/functions.php | 44 ----- 20 files changed, 1136 deletions(-) delete mode 100644 vendor/open-telemetry/api/Trace/NonRecordingSpan.php delete mode 100644 vendor/open-telemetry/api/Trace/NoopSpanBuilder.php delete mode 100644 vendor/open-telemetry/api/Trace/NoopTracer.php delete mode 100644 vendor/open-telemetry/api/Trace/NoopTracerProvider.php delete mode 100644 vendor/open-telemetry/api/Trace/Propagation/TraceContextPropagator.php delete mode 100644 vendor/open-telemetry/api/Trace/Propagation/TraceContextValidator.php delete mode 100644 vendor/open-telemetry/api/Trace/Span.php delete mode 100644 vendor/open-telemetry/api/Trace/SpanBuilderInterface.php delete mode 100644 vendor/open-telemetry/api/Trace/SpanContext.php delete mode 100644 vendor/open-telemetry/api/Trace/SpanContextInterface.php delete mode 100644 vendor/open-telemetry/api/Trace/SpanContextValidator.php delete mode 100644 vendor/open-telemetry/api/Trace/SpanInterface.php delete mode 100644 vendor/open-telemetry/api/Trace/SpanKind.php delete mode 100644 vendor/open-telemetry/api/Trace/StatusCode.php delete mode 100644 vendor/open-telemetry/api/Trace/TraceFlags.php delete mode 100644 vendor/open-telemetry/api/Trace/TraceState.php delete mode 100644 vendor/open-telemetry/api/Trace/TraceStateInterface.php delete mode 100644 vendor/open-telemetry/api/Trace/TracerInterface.php delete mode 100644 vendor/open-telemetry/api/Trace/TracerProviderInterface.php delete mode 100644 vendor/open-telemetry/api/Trace/functions.php (limited to 'vendor/open-telemetry/api/Trace') diff --git a/vendor/open-telemetry/api/Trace/NonRecordingSpan.php b/vendor/open-telemetry/api/Trace/NonRecordingSpan.php deleted file mode 100644 index 67d74d39b..000000000 --- a/vendor/open-telemetry/api/Trace/NonRecordingSpan.php +++ /dev/null @@ -1,76 +0,0 @@ -context = $context; - } - - /** @inheritDoc */ - public function getContext(): SpanContextInterface - { - return $this->context; - } - - /** @inheritDoc */ - public function isRecording(): bool - { - return false; - } - - /** @inheritDoc */ - public function setAttribute(string $key, $value): SpanInterface - { - return $this; - } - - /** @inheritDoc */ - public function setAttributes(iterable $attributes): SpanInterface - { - return $this; - } - - /** @inheritDoc */ - public function addEvent(string $name, iterable $attributes = [], int $timestamp = null): SpanInterface - { - return $this; - } - - /** @inheritDoc */ - public function recordException(Throwable $exception, iterable $attributes = []): SpanInterface - { - return $this; - } - - /** @inheritDoc */ - public function updateName(string $name): SpanInterface - { - return $this; - } - - /** @inheritDoc */ - public function setStatus(string $code, string $description = null): SpanInterface - { - return $this; - } - - /** @inheritDoc */ - public function end(int $endEpochNanos = null): void - { - } -} diff --git a/vendor/open-telemetry/api/Trace/NoopSpanBuilder.php b/vendor/open-telemetry/api/Trace/NoopSpanBuilder.php deleted file mode 100644 index 6f971e525..000000000 --- a/vendor/open-telemetry/api/Trace/NoopSpanBuilder.php +++ /dev/null @@ -1,65 +0,0 @@ -contextStorage = $contextStorage; - } - - public function setParent($context): SpanBuilderInterface - { - $this->parentContext = $context; - - return $this; - } - - public function addLink(SpanContextInterface $context, iterable $attributes = []): SpanBuilderInterface - { - return $this; - } - - public function setAttribute(string $key, $value): SpanBuilderInterface - { - return $this; - } - - public function setAttributes(iterable $attributes): SpanBuilderInterface - { - return $this; - } - - public function setStartTimestamp(int $timestampNanos): SpanBuilderInterface - { - return $this; - } - - public function setSpanKind(int $spanKind): SpanBuilderInterface - { - return $this; - } - - public function startSpan(): SpanInterface - { - $parentContext = Context::resolve($this->parentContext, $this->contextStorage); - $span = Span::fromContext($parentContext); - if ($span->isRecording()) { - $span = Span::wrap($span->getContext()); - } - - return $span; - } -} diff --git a/vendor/open-telemetry/api/Trace/NoopTracer.php b/vendor/open-telemetry/api/Trace/NoopTracer.php deleted file mode 100644 index bc50248bd..000000000 --- a/vendor/open-telemetry/api/Trace/NoopTracer.php +++ /dev/null @@ -1,26 +0,0 @@ -getContext(); - - if (!$spanContext->isValid()) { - return; - } - - // Build and inject the traceparent header - $traceparent = self::VERSION . '-' . $spanContext->getTraceId() . '-' . $spanContext->getSpanId() . '-' . ($spanContext->isSampled() ? '01' : '00'); - $setter->set($carrier, self::TRACEPARENT, $traceparent); - - // Build and inject the tracestate header - // Spec says to avoid sending empty tracestate headers - if (($tracestate = (string) $spanContext->getTraceState()) !== '') { - $setter->set($carrier, self::TRACESTATE, $tracestate); - } - } - - /** {@inheritdoc} */ - public function extract($carrier, PropagationGetterInterface $getter = null, ContextInterface $context = null): ContextInterface - { - $getter ??= ArrayAccessGetterSetter::getInstance(); - $context ??= Context::getCurrent(); - - $spanContext = self::extractImpl($carrier, $getter); - if (!$spanContext->isValid()) { - return $context; - } - - return $context->withContextValue(Span::wrap($spanContext)); - } - - private static function extractImpl($carrier, PropagationGetterInterface $getter): SpanContextInterface - { - $traceparent = $getter->get($carrier, self::TRACEPARENT); - if ($traceparent === null) { - return SpanContext::getInvalid(); - } - - // traceParent = {version}-{trace-id}-{parent-id}-{trace-flags} - $pieces = explode('-', $traceparent); - - // If the header does not have at least 4 pieces, it is invalid -- restart the trace. - if (count($pieces) < 4) { - return SpanContext::getInvalid(); - } - - [$version, $traceId, $spanId, $traceFlags] = $pieces; - - /** - * Return invalid if: - * - Version is invalid (not 2 char hex or 'ff') - * - Trace version, trace ID, span ID or trace flag are invalid - */ - if (!TraceContextValidator::isValidTraceVersion($version) - || !SpanContextValidator::isValidTraceId($traceId) - || !SpanContextValidator::isValidSpanId($spanId) - || !TraceContextValidator::isValidTraceFlag($traceFlags) - ) { - return SpanContext::getInvalid(); - } - - // Return invalid if the trace version is not a future version but still has > 4 pieces. - $versionIsFuture = hexdec($version) > hexdec(self::VERSION); - if (count($pieces) > 4 && !$versionIsFuture) { - return SpanContext::getInvalid(); - } - - // Only the sampled flag is extracted from the traceFlags (00000001) - $convertedTraceFlags = hexdec($traceFlags); - $isSampled = ($convertedTraceFlags & TraceFlags::SAMPLED) === TraceFlags::SAMPLED; - - // Tracestate = 'Vendor1=Value1,...,VendorN=ValueN' - $rawTracestate = $getter->get($carrier, self::TRACESTATE); - if ($rawTracestate !== null) { - $tracestate = new TraceState($rawTracestate); - - return SpanContext::createFromRemoteParent( - $traceId, - $spanId, - $isSampled ? TraceFlags::SAMPLED : TraceFlags::DEFAULT, - $tracestate - ); - } - - // Only traceparent header is extracted. No tracestate. - return SpanContext::createFromRemoteParent( - $traceId, - $spanId, - $isSampled ? TraceFlags::SAMPLED : TraceFlags::DEFAULT - ); - } -} diff --git a/vendor/open-telemetry/api/Trace/Propagation/TraceContextValidator.php b/vendor/open-telemetry/api/Trace/Propagation/TraceContextValidator.php deleted file mode 100644 index 5fb3f12c7..000000000 --- a/vendor/open-telemetry/api/Trace/Propagation/TraceContextValidator.php +++ /dev/null @@ -1,31 +0,0 @@ -get(ContextKeys::span()) ?? self::getInvalid(); - } - - /** @inheritDoc */ - final public static function getCurrent(): SpanInterface - { - return self::fromContext(Context::getCurrent()); - } - - /** @inheritDoc */ - final public static function getInvalid(): SpanInterface - { - if (null === self::$invalidSpan) { - self::$invalidSpan = new NonRecordingSpan(SpanContext::getInvalid()); - } - - return self::$invalidSpan; - } - - /** @inheritDoc */ - final public static function wrap(SpanContextInterface $spanContext): SpanInterface - { - if (!$spanContext->isValid()) { - return self::getInvalid(); - } - - return new NonRecordingSpan($spanContext); - } - - /** @inheritDoc */ - final public function activate(): ScopeInterface - { - return Context::getCurrent()->withContextValue($this)->activate(); - } - - /** @inheritDoc */ - final public function storeInContext(ContextInterface $context): ContextInterface - { - return $context->with(ContextKeys::span(), $this); - } -} diff --git a/vendor/open-telemetry/api/Trace/SpanBuilderInterface.php b/vendor/open-telemetry/api/Trace/SpanBuilderInterface.php deleted file mode 100644 index 52070933a..000000000 --- a/vendor/open-telemetry/api/Trace/SpanBuilderInterface.php +++ /dev/null @@ -1,51 +0,0 @@ -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; - } -} diff --git a/vendor/open-telemetry/api/Trace/SpanContextInterface.php b/vendor/open-telemetry/api/Trace/SpanContextInterface.php deleted file mode 100644 index d15bc5987..000000000 --- a/vendor/open-telemetry/api/Trace/SpanContextInterface.php +++ /dev/null @@ -1,28 +0,0 @@ - $attributes - */ - public function setAttributes(iterable $attributes): SpanInterface; - - /** - * @see https://github.com/open-telemetry/opentelemetry-specification/blob/v1.6.1/specification/trace/api.md#add-events - */ - public function addEvent(string $name, iterable $attributes = [], int $timestamp = null): SpanInterface; - - /** - * @see https://github.com/open-telemetry/opentelemetry-specification/blob/v1.6.1/specification/trace/api.md#record-exception - */ - public function recordException(Throwable $exception, iterable $attributes = []): SpanInterface; - - /** - * @see https://github.com/open-telemetry/opentelemetry-specification/blob/v1.6.1/specification/trace/api.md#updatename - * - * @param non-empty-string $name - */ - public function updateName(string $name): SpanInterface; - - /** - * @see https://github.com/open-telemetry/opentelemetry-specification/blob/v1.6.1/specification/trace/api.md#set-status - * - * @psalm-param StatusCode::STATUS_* $code - */ - public function setStatus(string $code, string $description = null): SpanInterface; - - /** - * @see https://github.com/open-telemetry/opentelemetry-specification/blob/v1.6.1/specification/trace/api.md#end - */ - public function end(int $endEpochNanos = null): void; -} diff --git a/vendor/open-telemetry/api/Trace/SpanKind.php b/vendor/open-telemetry/api/Trace/SpanKind.php deleted file mode 100644 index f44339e00..000000000 --- a/vendor/open-telemetry/api/Trace/SpanKind.php +++ /dev/null @@ -1,17 +0,0 @@ -traceState = $this->parse($rawTracestate); - } - - /** - * {@inheritdoc} - */ - public function with(string $key, string $value): TraceStateInterface - { - $clonedTracestate = clone $this; - - if ($this->validateKey($key) && $this->validateValue($value)) { - - /* - * Only one entry per key is allowed. In this case we need to overwrite the vendor entry - * upon reentry to the tracing system and ensure the updated entry is at the beginning of - * the list. This means we place it the back for now and it will be at the beginning once - * we reverse the order back during __toString(). - */ - if (array_key_exists($key, $clonedTracestate->traceState)) { - unset($clonedTracestate->traceState[$key]); - } - - // Add new or updated entry to the back of the list. - $clonedTracestate->traceState[$key] = $value; - } else { - self::logWarning('Invalid tracetrace key/value for: ' . $key); - } - - return $clonedTracestate; - } - - /** - * {@inheritdoc} - */ - public function without(string $key): TraceStateInterface - { - $clonedTracestate = clone $this; - - if ($key !== '') { - unset($clonedTracestate->traceState[$key]); - } - - return $clonedTracestate; - } - - /** - * {@inheritdoc} - */ - public function get(string $key): ?string - { - return $this->traceState[$key] ?? null; - } - - /** - * {@inheritdoc} - */ - public function getListMemberCount(): int - { - return count($this->traceState); - } - - /** - * {@inheritdoc} - */ - public function __toString(): string - { - if ($this->traceState === []) { - return ''; - } - $traceStateString=''; - foreach (array_reverse($this->traceState) as $k => $v) { - $traceStateString .=$k . self::LIST_MEMBER_KEY_VALUE_SPLITTER . $v . self::LIST_MEMBERS_SEPARATOR; - } - - return rtrim($traceStateString, ','); - } - - /** - * Parse the raw tracestate header into the TraceState object. Since new or updated entries must - * be added to the beginning of the list, the key-value pairs in the TraceState object will be - * stored in reverse order. This ensures new entries added to the TraceState object are at the - * beginning when we reverse the order back again while building the final tracestate header. - * - * Ex: - * tracestate = 'vendor1=value1,vendor2=value2' - * - * || - * \/ - * - * $this->tracestate = ['vendor2' => 'value2' ,'vendor1' => 'value1'] - * - */ - private function parse(string $rawTracestate): array - { - if (strlen($rawTracestate) > self::MAX_COMBINED_LENGTH) { - self::logWarning('tracestate discarded, exceeds max combined length: ' . self::MAX_COMBINED_LENGTH); - - return []; - } - $parsedTracestate = []; - $listMembers = explode(self::LIST_MEMBERS_SEPARATOR, $rawTracestate); - - if (count($listMembers) > self::MAX_LIST_MEMBERS) { - self::logWarning('tracestate discarded, too many members'); - - return []; - } - - foreach ($listMembers as $listMember) { - $vendor = explode(self::LIST_MEMBER_KEY_VALUE_SPLITTER, trim($listMember)); - - // There should only be one list-member per vendor separated by '=' - if (count($vendor) !== 2 || !$this->validateKey($vendor[0]) || !$this->validateValue($vendor[1])) { - self::logWarning('tracestate discarded, invalid member: ' . $listMember); - - return []; - } - $parsedTracestate[$vendor[0]] = $vendor[1]; - } - - /* - * Reversing the tracestate ensures the new entries added to the TraceState object are at - * the beginning when we reverse it back during __toString(). - */ - return array_reverse($parsedTracestate); - } - - /** - * The Key is opaque string that is an identifier for a vendor. It can be up - * to 256 characters and MUST begin with a lowercase letter or a digit, and can - * only contain lowercase letters (a-z), digits (0-9), underscores (_), dashes (-), - * asterisks (*), and forward slashes (/). For multi-tenant vendor scenarios, an at - * sign (@) can be used to prefix the vendor name. Vendors SHOULD set the tenant ID - * at the beginning of the key. - * - * @see https://www.w3.org/TR/trace-context/#key - */ - private function validateKey(string $key): bool - { - return preg_match(self::VALID_KEY_REGEX, $key) !== 0; - } - - /** - * The value is an opaque string containing up to 256 printable ASCII [RFC0020] - * characters (i.e., the range 0x20 to 0x7E) except comma (,) and (=). Note that - * this also excludes tabs, newlines, carriage returns, etc. - * - * @see https://www.w3.org/TR/trace-context/#value - */ - private function validateValue(string $key): bool - { - return (preg_match(self::VALID_VALUE_BASE_REGEX, $key) !== 0) - && (preg_match(self::INVALID_VALUE_COMMA_EQUAL_REGEX, $key) === 0); - } -} diff --git a/vendor/open-telemetry/api/Trace/TraceStateInterface.php b/vendor/open-telemetry/api/Trace/TraceStateInterface.php deleted file mode 100644 index 79d4e0299..000000000 --- a/vendor/open-telemetry/api/Trace/TraceStateInterface.php +++ /dev/null @@ -1,61 +0,0 @@ - $args arguments to provide to the closure - * @return R result of the closure invocation - * - * @phpstan-ignore-next-line - */ -function trace(SpanInterface $span, Closure $closure, iterable $args = []) -{ - $s = $span; - $c = $closure; - $a = $args; - unset($span, $closure, $args); - - $scope = $s->activate(); - - try { - /** @psalm-suppress InvalidArgument */ - return $c(...$a, ...($a = [])); - } catch (Throwable $e) { - $s->setStatus(StatusCode::STATUS_ERROR, $e->getMessage()); - $s->recordException($e, ['exception.escaped' => true]); - - throw $e; - } finally { - $scope->detach(); - $s->end(); - } -} -- cgit v1.2.3-54-g00ecf