├── .gitignore ├── src └── OpenTracing │ ├── Exception.php │ ├── Exception │ ├── OpenTracingException.php │ ├── EmptyCarrierException.php │ ├── InvalidFormatException.php │ ├── InvalidCarrierException.php │ └── CorruptedCarrierException.php │ ├── Propagation.php │ ├── Format.php │ ├── Tag.php │ ├── SplitBinaryCarrier.php │ ├── SplitTextCarrier.php │ ├── Stub │ ├── Tracer.php │ └── Span.php │ ├── Tracer.php │ └── Span.php ├── README.md ├── composer.json └── LICENSE.md /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | vendor/ 3 | composer.phar 4 | composer.lock 5 | -------------------------------------------------------------------------------- /src/OpenTracing/Exception.php: -------------------------------------------------------------------------------- 1 | state = $state; 26 | $this->baggage = $baggage; 27 | } 28 | 29 | /** 30 | * @return string 31 | */ 32 | public function getState() 33 | { 34 | return $this->state; 35 | } 36 | 37 | /** 38 | * @param string $state 39 | * @return SplitBinaryCarrier 40 | */ 41 | public function setState($state) 42 | { 43 | $this->state = $state; 44 | 45 | return $this; 46 | } 47 | 48 | /** 49 | * @return string 50 | */ 51 | public function getBaggage() 52 | { 53 | return $this->baggage; 54 | } 55 | 56 | /** 57 | * @param string $baggage 58 | * @return SplitBinaryCarrier 59 | */ 60 | public function setBaggage($baggage) 61 | { 62 | $this->baggage = $baggage; 63 | 64 | return $this; 65 | } 66 | 67 | } -------------------------------------------------------------------------------- /src/OpenTracing/SplitTextCarrier.php: -------------------------------------------------------------------------------- 1 | state = $state; 25 | $this->baggage = $baggage; 26 | } 27 | 28 | /** 29 | * @return array 30 | */ 31 | public function getState() 32 | { 33 | return $this->state; 34 | } 35 | 36 | /** 37 | * @param array $state 38 | * @return SplitTextCarrier 39 | */ 40 | public function setState(array $state) 41 | { 42 | $this->state = $state; 43 | 44 | return $this; 45 | } 46 | 47 | /** 48 | * @return array 49 | */ 50 | public function getBaggage() 51 | { 52 | return $this->baggage; 53 | } 54 | 55 | /** 56 | * @param array $baggage 57 | * @return SplitTextCarrier 58 | */ 59 | public function setBaggage(array $baggage) 60 | { 61 | $this->baggage = $baggage; 62 | 63 | return $this; 64 | } 65 | 66 | } -------------------------------------------------------------------------------- /src/OpenTracing/Stub/Tracer.php: -------------------------------------------------------------------------------- 1 | noopSpan = new Span($this); 23 | } 24 | 25 | /** 26 | * Starts and returns a new Span representing a unit of work. 27 | * 28 | * @param string $operationName 29 | * @param Span $parent 30 | * @param array $tags 31 | * @param float $startTime 32 | * @return Span 33 | */ 34 | public function startSpan($operationName = null, $parent = null, $tags = null, $startTime = null) 35 | { 36 | return $this->noopSpan; 37 | } 38 | 39 | 40 | /** 41 | * Takes $span and injects it into $carrier. 42 | * 43 | * The actual type of $carrier depends on the $format. 44 | * 45 | * Implementations may raise implementation-specific exception 46 | * if injection fails. 47 | * 48 | * @param OpenTracing\Span $span 49 | * @param string $format 50 | * @param mixed $carrier 51 | * @throws \OpenTracing\Exception 52 | */ 53 | public function inject(OpenTracing\Span $span, $format, &$carrier) { 54 | // noop 55 | } 56 | 57 | /** 58 | * Returns a Span instance with operation name $operationName 59 | * that's joined to the trace state embedded within $carrier, or null if 60 | * no such trace state could be found. 61 | * 62 | * Implementations may raise implementation-specific errors 63 | * if there are more fundamental problems with `carrier`. 64 | * 65 | * Upon success, the returned Span instance is already started. 66 | * 67 | * @param string $operationName 68 | * @param string $format 69 | * @param mixed $carrier 70 | * @throws \OpenTracing\Exception 71 | * @return OpenTracing\Span 72 | */ 73 | public function join($operationName, $format, $carrier) { 74 | return $this->noopSpan; 75 | } 76 | 77 | 78 | /** 79 | * Flushes any trace data that may be buffered in memory, presumably 80 | * out of the process. 81 | * 82 | * @return void 83 | */ 84 | public function flush() 85 | { 86 | // noop 87 | } 88 | } -------------------------------------------------------------------------------- /src/OpenTracing/Tracer.php: -------------------------------------------------------------------------------- 1 | getTracer()->startSpan($operationName, $this, $tags, $startTime); 124 | } 125 | 126 | } -------------------------------------------------------------------------------- /src/OpenTracing/Stub/Span.php: -------------------------------------------------------------------------------- 1 | tracer = $tracer; 21 | } 22 | 23 | /** 24 | * Sets or changes the operation name. 25 | * 26 | * @param string $operationName 27 | * @return $this 28 | */ 29 | public function setOperationName($operationName) 30 | { 31 | return $this; 32 | } 33 | 34 | /** 35 | * Indicates that the work represented by this span has been completed 36 | * or terminated, and is ready to be sent to the Reporter. 37 | * 38 | * If any tags / logs need to be added to the span, it should be done 39 | * before calling finish(), otherwise they may be ignored. 40 | * 41 | * @param float $finishTime 42 | */ 43 | public function finish($finishTime = null) 44 | { 45 | // noop 46 | } 47 | 48 | /** 49 | * Attaches a key/value pair to the span. 50 | * 51 | * The set of supported value types is implementation specific. It is the 52 | * responsibility of the actual tracing system to know how to serialize 53 | * and record the values. 54 | * 55 | * If the user calls set_tag multiple times for the same key, 56 | * the behavior of the tracer is undefined, i.e. it is implementation 57 | * specific whether the tracer will retain the first value, or the last 58 | * value, or pick one randomly, or even keep all of them. 59 | * 60 | * @param string $key 61 | * @param mixed $value 62 | * @return $this 63 | */ 64 | public function setTag($key, $value) 65 | { 66 | return $this; 67 | } 68 | 69 | /** 70 | * Logs an event against the span, with the current timestamp. 71 | * 72 | * @param string $event 73 | * @param array $payload 74 | * @return $this 75 | */ 76 | public function logEvent($event, $payload = null) 77 | { 78 | $this->log(null, $event, $payload); 79 | 80 | return $this; 81 | } 82 | 83 | /** 84 | * Records a generic Log event at an arbitrary timestamp. 85 | * 86 | * @param float $timestamp 87 | * @param string $event 88 | * @param array $payload 89 | * @return $this 90 | */ 91 | public function log($timestamp, $event, $payload = null) 92 | { 93 | return $this; 94 | } 95 | 96 | /** 97 | * Stores Baggage Item in the span as a key/value pair. 98 | * 99 | * Enables powerful distributed context propagation functionality where 100 | * arbitrary application data can be carried along the full path of 101 | * request execution throughout the system. 102 | * 103 | * Note 1: baggage is only propagated to the future (recursive) 104 | * children of this Span. 105 | * 106 | * Note 2: baggage is sent in-band with every subsequent local and 107 | * remote calls, so this feature must be used with care. 108 | * 109 | * Note 3: keys are case-insensitive, to allow propagation via HTTP 110 | * headers. Keys must match regexp `(?i:[a-z0-9][-a-z0-9]*)` 111 | * 112 | * @param string $key 113 | * @param mixed $value 114 | * @return $this 115 | */ 116 | public function setBaggageItem($key, $value) 117 | { 118 | return $this; 119 | } 120 | 121 | /** 122 | * Retrieves value of the Baggage Item with the given key. 123 | * 124 | * Returns null if key doesn't exist. 125 | * 126 | * Key is case-insensitive. 127 | * 128 | * @param string $key 129 | * @return mixed 130 | */ 131 | public function getBaggageItem($key) 132 | { 133 | return null; 134 | } 135 | 136 | /** 137 | * Provides access to the Tracer that created this Span. 138 | * 139 | * @return Tracer 140 | */ 141 | public function getTracer() 142 | { 143 | return $this->tracer; 144 | } 145 | } --------------------------------------------------------------------------------