private function prepareSpan(Span $span): Span
    {
        $span->setTransactionId($this->transaction->getId());
        $span->setTraceId($this->transaction->getTraceId());

        if ($span->getId() === null) {
            $span->setId(AbstractEventBuilder::generateRandomBitsInHex(64));
        }

        if ($span->getParentId() === null) {
            $span->setParentId($this->transaction->getId());
        }

        if ($span->getStart() === null) {
            $span->setStart(
                intval(round(($span->getTimestamp() - $this->transaction->getTimestamp()) / 1000))
            );
        }

        return $span;
    }