public function toArray()
    {
        $span = [
            'id' => (string) $this->id,
            'traceId' => (string) $this->traceId,
            'name' => $this->name,
            'timestamp' => $this->annotationBlock->getStartTimestamp(),
            'duration' => $this->annotationBlock->getDuration(),
            'annotations' => $this->annotationBlock->toArray()
        ];

        if ($this->parentId !== null) {
            $span['parentId'] = (string) $this->parentId;
        }

        if ($this->metadata !== null) {
            $span['binaryAnnotations'] = $this->metadata->toArray();
        }

        return $span;
    }