tracing-laravel icon indicating copy to clipboard operation
tracing-laravel copied to clipboard

Are we considering supporting `QueueReport`?

Open summerKK opened this issue 1 year ago • 2 comments

Using a queue can speed up the response time of your site and reduce a lot of risks. For example, if zipkin crashes, it won't affect the site.

It can be supported with very few code changes, I can provide a PR.

The reporter can be obtained through dependency injection.

tracing-laravel/src/Drivers/Zipkin/ZipkinTracer.php

protected function createReporter(): Reporter
{
    if (!$this->reporter) {
        return new HttpReporter([
            'endpoint_url' => sprintf('http://%s:%s/api/v2/spans', $this->host, $this->port),
            'timeout' => $this->requestTimeout,
        ]);
    }

    return $this->reporter;
}
class QueueReporter implements Reporter
{
    public function report(array $spans): void
    {
        if (count($spans) === 0) {
            return;
        }

        $reporterJob = new ReporterJob(
            config('tracing.zipkin.host'),
            config('tracing.zipkin.port'),
            config('tracing.zipkin.options.request_timeout', 1),
            $spans
        );
        dispatch($reporterJob)->onQueue();
    }
}

summerKK avatar Nov 17 '23 08:11 summerKK

@KinaneD

summerKK avatar Nov 17 '23 08:11 summerKK

Hey @summerKK could you please provide a use case of an architecture were crash in Zipkin could jeopardise your app.

KinaneD avatar Dec 26 '23 16:12 KinaneD