summaryrefslogtreecommitdiff
path: root/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/SpanContext.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/jonahgeorge/jaeger-client-php/src/Jaeger/SpanContext.php')
-rw-r--r--vendor/jonahgeorge/jaeger-client-php/src/Jaeger/SpanContext.php120
1 files changed, 120 insertions, 0 deletions
diff --git a/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/SpanContext.php b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/SpanContext.php
new file mode 100644
index 000000000..447ffd1a5
--- /dev/null
+++ b/vendor/jonahgeorge/jaeger-client-php/src/Jaeger/SpanContext.php
@@ -0,0 +1,120 @@
+<?php
+
+namespace Jaeger;
+
+use ArrayIterator;
+use OpenTracing\SpanContext as OTSpanContext;
+
+class SpanContext implements OTSpanContext
+{
+ private $traceId;
+
+ private $spanId;
+
+ private $parentId;
+
+ private $flags;
+
+ /**
+ * @var array
+ */
+ private $baggage;
+
+ private $debugId;
+
+ /**
+ * SpanContext constructor.
+ *
+ * @param string $traceId
+ * @param string $spanId
+ * @param string $parentId
+ * @param int|null $flags
+ * @param array $baggage
+ * @param int|null $debugId
+ */
+ public function __construct($traceId, $spanId, $parentId, $flags = null, $baggage = [], $debugId = null)
+ {
+ $this->traceId = $traceId;
+ $this->spanId = $spanId;
+ $this->parentId = $parentId;
+ $this->flags = $flags;
+ $this->baggage = is_array($baggage) ? $baggage : [];
+ $this->debugId = $debugId;
+ }
+
+ /**
+ * {@inheritdoc}
+ * @return ArrayIterator
+ */
+ #[\ReturnTypeWillChange]
+ public function getIterator()
+ {
+ return new ArrayIterator($this->baggage);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function getBaggageItem(string $key): ?string
+ {
+ return array_key_exists($key, $this->baggage) ? $this->baggage[$key] : null;
+ }
+
+ /**
+ * {@inheritdoc}
+ *
+ * @param string $key
+ * @param string $value
+ * @return SpanContext
+ */
+ public function withBaggageItem(string $key, string $value): OTSpanContext
+ {
+ return new self(
+ $this->traceId,
+ $this->spanId,
+ $this->parentId,
+ $this->flags,
+ [$key => $value] + $this->baggage
+ );
+ }
+
+ public function getTraceId()
+ {
+ return $this->traceId;
+ }
+
+ public function getParentId()
+ {
+ return $this->parentId;
+ }
+
+ public function getSpanId()
+ {
+ return $this->spanId;
+ }
+
+ /**
+ * Get the span context flags.
+ *
+ * @return int|null
+ */
+ public function getFlags()
+ {
+ return $this->flags;
+ }
+
+ public function getBaggage()
+ {
+ return $this->baggage;
+ }
+
+ public function getDebugId()
+ {
+ return $this->debugId;
+ }
+
+ public function isDebugIdContainerOnly(): bool
+ {
+ return ($this->traceId === null) && ($this->debugId !== null);
+ }
+}