public function flushTraces()
    {
        $spans = $this->buffer->pop();
        $spansCount = $spans->count();

        if ($this->debugLoggingEnabled) {
            $this->logger->debug(sprintf("Sending %d spans", $spansCount));

            foreach($spans as $span) {
                $this->logger->debug(sprintf("SPAN:\n%s", $span->__toString()));
            }
        }

        if (!$this->isEnabled() || !$this->hasTransport() || $spansCount == 0) {
            return;
        }

        $traceBuffer = TracesBuffer::fromSpanCollection($spans);

        $this->transport->sendTraces($traceBuffer);
    }