traceId = $traceId ?? uniqid(); $this->parentSpanId = $parentSpanId; $this->spanId = $spanId; } public static function newFromParent($traceInfo) { $traceContext = new self($traceInfo['traceId'], $traceInfo['spanId']); return $traceContext; } public function getTraceInfo() { return [ 'traceId' => $this->getTraceId(), 'parentSpanId' => $this->getParentSpanId(), 'spanId' => $this->getSpanId() ]; } public function getParentSpanId() { return $this->parentSpanId; } public function getSpanId() { return ++$this->spanId; } public function getTraceId() { return $this->traceId; } }