|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace OpenTelemetry\Sdk\Trace; |
| 6 | + |
| 7 | +use OpenTelemetry\Trace as API; |
| 8 | + |
| 9 | +class NoopSpan implements \OpenTelemetry\Trace\Span |
| 10 | +{ |
| 11 | + /** @var SpanContext */ |
| 12 | + private $context; |
| 13 | + |
| 14 | + /** @var API\Attributes */ |
| 15 | + private $attributes; |
| 16 | + |
| 17 | + /** @var API\Links */ |
| 18 | + private $links; |
| 19 | + // @todo when links will be implemented, this attribute should be initialized properly |
| 20 | + |
| 21 | + /** @var API\Events */ |
| 22 | + private $events; |
| 23 | + |
| 24 | + /** @var API\SpanStatus */ |
| 25 | + private $status; |
| 26 | + |
| 27 | + public function __construct() |
| 28 | + { |
| 29 | + $this->context = new SpanContext( |
| 30 | + SpanContext::INVALID_TRACE, |
| 31 | + SpanContext::INVALID_SPAN, |
| 32 | + 0, |
| 33 | + [] |
| 34 | + ); |
| 35 | + |
| 36 | + $this->attributes = new Attributes(); |
| 37 | + $this->events = new Events(); |
| 38 | + $this->status = SpanStatus::ok(); |
| 39 | + } |
| 40 | + |
| 41 | + public function getSpanName(): string |
| 42 | + { |
| 43 | + return ''; |
| 44 | + } |
| 45 | + |
| 46 | + public function getContext(): API\SpanContext |
| 47 | + { |
| 48 | + return $this->context; |
| 49 | + } |
| 50 | + |
| 51 | + public function getParent(): ?API\SpanContext |
| 52 | + { |
| 53 | + return null; |
| 54 | + } |
| 55 | + |
| 56 | + public function getStartEpochTimestamp(): int |
| 57 | + { |
| 58 | + return 0; |
| 59 | + } |
| 60 | + |
| 61 | + public function getStart(): int |
| 62 | + { |
| 63 | + return 0; |
| 64 | + } |
| 65 | + |
| 66 | + public function getEnd(): ?int |
| 67 | + { |
| 68 | + return 0; |
| 69 | + } |
| 70 | + |
| 71 | + public function getAttributes(): API\Attributes |
| 72 | + { |
| 73 | + return $this->attributes; |
| 74 | + } |
| 75 | + |
| 76 | + public function getLinks(): API\Links |
| 77 | + { |
| 78 | + return $this->links; |
| 79 | + } |
| 80 | + |
| 81 | + public function getEvents(): API\Events |
| 82 | + { |
| 83 | + return $this->events; |
| 84 | + } |
| 85 | + |
| 86 | + public function getStatus(): API\SpanStatus |
| 87 | + { |
| 88 | + return $this->status; |
| 89 | + } |
| 90 | + |
| 91 | + public function setAttribute(string $key, $value): API\Span |
| 92 | + { |
| 93 | + return $this; |
| 94 | + } |
| 95 | + |
| 96 | + public function addEvent(string $name, int $timestamp, ?API\Attributes $attributes = null): API\Span |
| 97 | + { |
| 98 | + return $this; |
| 99 | + } |
| 100 | + |
| 101 | + public function addLink(API\SpanContext $context, ?API\Attributes $attributes = null): API\Span |
| 102 | + { |
| 103 | + return $this; |
| 104 | + } |
| 105 | + |
| 106 | + public function updateName(string $name): API\Span |
| 107 | + { |
| 108 | + return $this; |
| 109 | + } |
| 110 | + |
| 111 | + public function setSpanStatus(string $code, ?string $description = null): API\Span |
| 112 | + { |
| 113 | + return $this; |
| 114 | + } |
| 115 | + |
| 116 | + public function end(int $timestamp = null): API\Span |
| 117 | + { |
| 118 | + return $this; |
| 119 | + } |
| 120 | + |
| 121 | + public function isRecording(): bool |
| 122 | + { |
| 123 | + return false; |
| 124 | + } |
| 125 | + |
| 126 | + public function isSampled(): bool |
| 127 | + { |
| 128 | + return false; |
| 129 | + } |
| 130 | + |
| 131 | + public function getSpanKind(): int |
| 132 | + { |
| 133 | + return API\SpanKind::KIND_INTERNAL; |
| 134 | + } |
| 135 | + |
| 136 | + public function getCanonicalStatusCode(): string |
| 137 | + { |
| 138 | + return $this->status->getCanonicalStatusCode(); |
| 139 | + } |
| 140 | + |
| 141 | + public function getStatusDescription(): string |
| 142 | + { |
| 143 | + return $this->status->getStatusDescription(); |
| 144 | + } |
| 145 | + |
| 146 | + public function isStatusOk(): bool |
| 147 | + { |
| 148 | + return $this->status->isStatusOK(); |
| 149 | + } |
| 150 | +} |
0 commit comments