summaryrefslogtreecommitdiff
path: root/vendor/open-telemetry/api/Baggage
diff options
context:
space:
mode:
authorAndrew Dolgov <fox@fakecake.org>2024-10-01 16:00:34 +0300
committerAndrew Dolgov <fox@fakecake.org>2024-10-01 16:00:34 +0300
commit884fd92f1320d17daebb772297da03fb2cfa59b8 (patch)
tree3aa80af1df6ffa1d70f21f9fc4411f451c8b6c56 /vendor/open-telemetry/api/Baggage
parent8fcc68baf5b0ff964a0a4a045353462586e0e316 (diff)
drop opentelemetry
Diffstat (limited to 'vendor/open-telemetry/api/Baggage')
-rw-r--r--vendor/open-telemetry/api/Baggage/Baggage.php100
-rw-r--r--vendor/open-telemetry/api/Baggage/BaggageBuilder.php40
-rw-r--r--vendor/open-telemetry/api/Baggage/BaggageBuilderInterface.php23
-rw-r--r--vendor/open-telemetry/api/Baggage/BaggageInterface.php62
-rw-r--r--vendor/open-telemetry/api/Baggage/Entry.php38
-rw-r--r--vendor/open-telemetry/api/Baggage/Metadata.php27
-rw-r--r--vendor/open-telemetry/api/Baggage/MetadataInterface.php13
-rw-r--r--vendor/open-telemetry/api/Baggage/Propagation/BaggagePropagator.php92
-rw-r--r--vendor/open-telemetry/api/Baggage/Propagation/Parser.php69
9 files changed, 0 insertions, 464 deletions
diff --git a/vendor/open-telemetry/api/Baggage/Baggage.php b/vendor/open-telemetry/api/Baggage/Baggage.php
deleted file mode 100644
index 06c701605..000000000
--- a/vendor/open-telemetry/api/Baggage/Baggage.php
+++ /dev/null
@@ -1,100 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace OpenTelemetry\API\Baggage;
-
-use OpenTelemetry\Context\Context;
-use OpenTelemetry\Context\ContextInterface;
-use OpenTelemetry\Context\ContextKeys;
-use OpenTelemetry\Context\ScopeInterface;
-
-final class Baggage implements BaggageInterface
-{
- private static ?self $emptyBaggage = null;
-
- /** @inheritDoc */
- public static function fromContext(ContextInterface $context): BaggageInterface
- {
- return $context->get(ContextKeys::baggage()) ?? self::getEmpty();
- }
-
- /** @inheritDoc */
- public static function getBuilder(): BaggageBuilderInterface
- {
- return new BaggageBuilder();
- }
-
- /** @inheritDoc */
- public static function getCurrent(): BaggageInterface
- {
- return self::fromContext(Context::getCurrent());
- }
-
- /** @inheritDoc */
- public static function getEmpty(): BaggageInterface
- {
- if (null === self::$emptyBaggage) {
- self::$emptyBaggage = new self();
- }
-
- return self::$emptyBaggage;
- }
-
- /** @var array<string, Entry> */
- private array $entries;
-
- /** @param array<string, Entry> $entries */
- public function __construct(array $entries = [])
- {
- $this->entries = $entries;
- }
-
- /** @inheritDoc */
- public function activate(): ScopeInterface
- {
- return Context::getCurrent()->withContextValue($this)->activate();
- }
-
- /** @inheritDoc */
- public function getEntry(string $key): ?Entry
- {
- return $this->entries[$key] ?? null;
- }
-
- /** @inheritDoc */
- public function getValue(string $key)
- {
- if (($entry = $this->getEntry($key)) !== null) {
- return $entry->getValue();
- }
-
- return null;
- }
-
- /** @inheritDoc */
- public function getAll(): iterable
- {
- foreach ($this->entries as $key => $entry) {
- yield $key => $entry;
- }
- }
-
- /** @inheritDoc */
- public function isEmpty(): bool
- {
- return $this->entries === [];
- }
-
- /** @inheritDoc */
- public function toBuilder(): BaggageBuilderInterface
- {
- return new BaggageBuilder($this->entries);
- }
-
- /** @inheritDoc */
- public function storeInContext(ContextInterface $context): ContextInterface
- {
- return $context->with(ContextKeys::baggage(), $this);
- }
-}
diff --git a/vendor/open-telemetry/api/Baggage/BaggageBuilder.php b/vendor/open-telemetry/api/Baggage/BaggageBuilder.php
deleted file mode 100644
index d4500eac5..000000000
--- a/vendor/open-telemetry/api/Baggage/BaggageBuilder.php
+++ /dev/null
@@ -1,40 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace OpenTelemetry\API\Baggage;
-
-final class BaggageBuilder implements BaggageBuilderInterface
-{
- /** @var array<string, Entry> */
- private array $entries;
-
- /** @param array<string, Entry> $entries */
- public function __construct(array $entries = [])
- {
- $this->entries = $entries;
- }
-
- /** @inheritDoc */
- public function remove(string $key): BaggageBuilderInterface
- {
- unset($this->entries[$key]);
-
- return $this;
- }
-
- /** @inheritDoc */
- public function set(string $key, $value, MetadataInterface $metadata = null): BaggageBuilderInterface
- {
- $metadata ??= Metadata::getEmpty();
-
- $this->entries[$key] = new Entry($value, $metadata);
-
- return $this;
- }
-
- public function build(): BaggageInterface
- {
- return new Baggage($this->entries);
- }
-}
diff --git a/vendor/open-telemetry/api/Baggage/BaggageBuilderInterface.php b/vendor/open-telemetry/api/Baggage/BaggageBuilderInterface.php
deleted file mode 100644
index 301cfbc3c..000000000
--- a/vendor/open-telemetry/api/Baggage/BaggageBuilderInterface.php
+++ /dev/null
@@ -1,23 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace OpenTelemetry\API\Baggage;
-
-use OpenTelemetry\API\Baggage as API;
-
-interface BaggageBuilderInterface
-{
- /**
- * @see https://github.com/open-telemetry/opentelemetry-specification/blob/v1.6.1/specification/baggage/api.md#set-value
- * @param mixed $value
- */
- public function set(string $key, $value, API\MetadataInterface $metadata = null): API\BaggageBuilderInterface;
-
- /**
- * @see https://github.com/open-telemetry/opentelemetry-specification/blob/v1.6.1/specification/baggage/api.md#remove-value
- */
- public function remove(string $key): API\BaggageBuilderInterface;
-
- public function build(): API\BaggageInterface;
-}
diff --git a/vendor/open-telemetry/api/Baggage/BaggageInterface.php b/vendor/open-telemetry/api/Baggage/BaggageInterface.php
deleted file mode 100644
index 83f45755d..000000000
--- a/vendor/open-telemetry/api/Baggage/BaggageInterface.php
+++ /dev/null
@@ -1,62 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace OpenTelemetry\API\Baggage;
-
-use OpenTelemetry\API\Baggage as API;
-use OpenTelemetry\Context\ContextInterface;
-use OpenTelemetry\Context\ImplicitContextKeyedInterface;
-
-/**
- * @see https://github.com/open-telemetry/opentelemetry-specification/blob/v1.6.1/specification/baggage/api.md#operations
- */
-interface BaggageInterface extends ImplicitContextKeyedInterface
-{
- /**
- * Returns the {@see API\BaggageInterface} from the provided *$context*,
- * falling back on {@see API\BaggageInterface::getEmpty()} if there is no baggage in the provided context.
- */
- public static function fromContext(ContextInterface $context): API\BaggageInterface;
-
- /**
- * Returns a new empty {@see API\BaggageBuilderInterface}.
- */
- public static function getBuilder(): API\BaggageBuilderInterface;
-
- /**
- * Returns the current {@see Baggage} from the current {@see ContextInterface},
- * falling back on {@see API\BaggageInterface::getEmpty()} if there is no baggage in the current context.
- */
- public static function getCurrent(): API\BaggageInterface;
-
- /**
- * Returns a new {@see API\BaggageInterface} with no entries.
- */
- public static function getEmpty(): API\BaggageInterface;
-
- /**
- * @see https://github.com/open-telemetry/opentelemetry-specification/blob/v1.6.1/specification/baggage/api.md#get-value
- */
- public function getEntry(string $key): ?API\Entry;
-
- /**
- * Returns the value from the {@see API\Entry} with the provided *key*.
- * @see getEntry
- *
- * @return mixed
- */
- public function getValue(string $key);
-
- /**
- * @see https://github.com/open-telemetry/opentelemetry-specification/blob/v1.6.1/specification/baggage/api.md#get-all-values
- */
- public function getAll(): iterable;
-
- public function isEmpty(): bool;
-
- /**
- * Returns a new {@see API\BaggageBuilderInterface} pre-initialized with the contents of `$this`.
- */
- public function toBuilder(): API\BaggageBuilderInterface;
-}
diff --git a/vendor/open-telemetry/api/Baggage/Entry.php b/vendor/open-telemetry/api/Baggage/Entry.php
deleted file mode 100644
index eb3d0de5b..000000000
--- a/vendor/open-telemetry/api/Baggage/Entry.php
+++ /dev/null
@@ -1,38 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace OpenTelemetry\API\Baggage;
-
-final class Entry
-{
- /** @var mixed */
- private $value;
-
- private MetadataInterface $metadata;
-
- /**
- * @param mixed $value
- * @param MetadataInterface $metadata
- */
- public function __construct(
- $value,
- MetadataInterface $metadata
- ) {
- $this->value = $value;
- $this->metadata = $metadata;
- }
-
- /**
- * @return mixed
- */
- public function getValue()
- {
- return $this->value;
- }
-
- public function getMetadata(): MetadataInterface
- {
- return $this->metadata;
- }
-}
diff --git a/vendor/open-telemetry/api/Baggage/Metadata.php b/vendor/open-telemetry/api/Baggage/Metadata.php
deleted file mode 100644
index 043c96a8a..000000000
--- a/vendor/open-telemetry/api/Baggage/Metadata.php
+++ /dev/null
@@ -1,27 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace OpenTelemetry\API\Baggage;
-
-final class Metadata implements MetadataInterface
-{
- private static ?self $instance = null;
-
- public static function getEmpty(): Metadata
- {
- return self::$instance ??= new self('');
- }
-
- private string $metadata;
-
- public function __construct(string $metadata)
- {
- $this->metadata = $metadata;
- }
-
- public function getValue(): string
- {
- return $this->metadata;
- }
-}
diff --git a/vendor/open-telemetry/api/Baggage/MetadataInterface.php b/vendor/open-telemetry/api/Baggage/MetadataInterface.php
deleted file mode 100644
index cd0a6d1ec..000000000
--- a/vendor/open-telemetry/api/Baggage/MetadataInterface.php
+++ /dev/null
@@ -1,13 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace OpenTelemetry\API\Baggage;
-
-/**
- * @see https://github.com/open-telemetry/opentelemetry-specification/blob/v1.6.1/specification/baggage/api.md#set-value
- */
-interface MetadataInterface
-{
- public function getValue(): string;
-}
diff --git a/vendor/open-telemetry/api/Baggage/Propagation/BaggagePropagator.php b/vendor/open-telemetry/api/Baggage/Propagation/BaggagePropagator.php
deleted file mode 100644
index fae62dcab..000000000
--- a/vendor/open-telemetry/api/Baggage/Propagation/BaggagePropagator.php
+++ /dev/null
@@ -1,92 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace OpenTelemetry\API\Baggage\Propagation;
-
-use OpenTelemetry\API\Baggage\Baggage;
-use OpenTelemetry\API\Baggage\BaggageBuilderInterface;
-use OpenTelemetry\API\Baggage\Entry; /** @phan-suppress-current-line PhanUnreferencedUseNormal */
-use OpenTelemetry\Context\Context;
-use OpenTelemetry\Context\ContextInterface;
-use OpenTelemetry\Context\Propagation\ArrayAccessGetterSetter;
-use OpenTelemetry\Context\Propagation\PropagationGetterInterface;
-use OpenTelemetry\Context\Propagation\PropagationSetterInterface;
-use OpenTelemetry\Context\Propagation\TextMapPropagatorInterface;
-use function rtrim;
-use function urlencode;
-
-/**
- * @see https://www.w3.org/TR/baggage
- */
-final class BaggagePropagator implements TextMapPropagatorInterface
-{
- public const BAGGAGE = 'baggage';
-
- private static ?self $instance = null;
-
- public static function getInstance(): self
- {
- if (null === self::$instance) {
- self::$instance = new self();
- }
-
- return self::$instance;
- }
-
- public function fields(): array
- {
- return [self::BAGGAGE];
- }
-
- public function inject(&$carrier, PropagationSetterInterface $setter = null, ContextInterface $context = null): void
- {
- $setter ??= ArrayAccessGetterSetter::getInstance();
- $context ??= Context::getCurrent();
-
- $baggage = Baggage::fromContext($context);
-
- if ($baggage->isEmpty()) {
- return;
- }
-
- $headerString = '';
-
- /** @var Entry $entry */
- foreach ($baggage->getAll() as $key => $entry) {
- $value = urlencode($entry->getValue());
- $headerString.= "{$key}={$value}";
-
- if (($metadata = $entry->getMetadata()->getValue()) !== '' && ($metadata = $entry->getMetadata()->getValue()) !== '0') {
- $headerString .= ";{$metadata}";
- }
-
- $headerString .= ',';
- }
-
- if ($headerString !== '' && $headerString !== '0') {
- $headerString = rtrim($headerString, ',');
- $setter->set($carrier, self::BAGGAGE, $headerString);
- }
- }
-
- public function extract($carrier, PropagationGetterInterface $getter = null, ContextInterface $context = null): ContextInterface
- {
- $getter ??= ArrayAccessGetterSetter::getInstance();
- $context ??= Context::getCurrent();
-
- if (!$baggageHeader = $getter->get($carrier, self::BAGGAGE)) {
- return $context;
- }
-
- $baggageBuilder = Baggage::getBuilder();
- $this->extractValue($baggageHeader, $baggageBuilder);
-
- return $context->withContextValue($baggageBuilder->build());
- }
-
- private function extractValue(string $baggageHeader, BaggageBuilderInterface $baggageBuilder): void
- {
- (new Parser($baggageHeader))->parseInto($baggageBuilder);
- }
-}
diff --git a/vendor/open-telemetry/api/Baggage/Propagation/Parser.php b/vendor/open-telemetry/api/Baggage/Propagation/Parser.php
deleted file mode 100644
index 3518b858d..000000000
--- a/vendor/open-telemetry/api/Baggage/Propagation/Parser.php
+++ /dev/null
@@ -1,69 +0,0 @@
-<?php
-
-declare(strict_types=1);
-
-namespace OpenTelemetry\API\Baggage\Propagation;
-
-use function explode;
-use OpenTelemetry\API\Baggage\BaggageBuilderInterface;
-use OpenTelemetry\API\Baggage\Metadata;
-use function str_replace;
-use function trim;
-use function urldecode;
-
-final class Parser
-{
- private const EXCLUDED_KEY_CHARS = [' ', '(', ')', '<', '>', '@', ',', ';', ':', '\\', '"', '/', '[', ']', '?', '=', '{', '}'];
- private const EXCLUDED_VALUE_CHARS = [' ', '"', ',', ';', '\\'];
- private const EQUALS = '=';
-
- /** @readonly */
- private string $baggageHeader;
-
- public function __construct(string $baggageHeader)
- {
- $this->baggageHeader = $baggageHeader;
- }
-
- public function parseInto(BaggageBuilderInterface $baggageBuilder): void
- {
- foreach (explode(',', $this->baggageHeader) as $baggageString) {
- if (empty(trim($baggageString))) {
- continue;
- }
-
- $explodedString = explode(';', $baggageString, 2);
-
- $keyValue = trim($explodedString[0]);
-
- if (empty($keyValue) || mb_strpos($keyValue, self::EQUALS) === false) {
- continue;
- }
-
- $metadataString = $explodedString[1] ?? null;
-
- if ($metadataString && !empty(trim(($metadataString)))) {
- $metadata = new Metadata(trim($metadataString));
- } else {
- $metadata = null;
- }
-
- [$key, $value] = explode(self::EQUALS, $keyValue, 2);
-
- $key = urldecode($key);
- $value = urldecode($value);
-
- $key = str_replace(self::EXCLUDED_KEY_CHARS, '', trim($key), $invalidKeyCharacters);
- if (empty($key) || $invalidKeyCharacters > 0) {
- continue;
- }
-
- $value = str_replace(self::EXCLUDED_VALUE_CHARS, '', trim($value), $invalidValueCharacters);
- if (empty($value) || $invalidValueCharacters > 0) {
- continue;
- }
-
- $baggageBuilder->set($key, $value, $metadata);
- }
- }
-}