From 37c3548cde6fbc21966c0162068e9afea00746e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Carlos=20Ch=C3=A1vez?= Date: Mon, 11 Mar 2019 10:24:08 +0100 Subject: [PATCH] chore: improves reporter logging. --- src/Zipkin/Reporters/Http.php | 6 +++++- src/Zipkin/Reporters/Http/CurlFactory.php | 5 +++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Zipkin/Reporters/Http.php b/src/Zipkin/Reporters/Http.php index 52377888..fd2fb65f 100644 --- a/src/Zipkin/Reporters/Http.php +++ b/src/Zipkin/Reporters/Http.php @@ -29,6 +29,10 @@ final class Http implements Reporter private $options; /** + * logger is only meant to be used for development purposes. Enabling + * an actual logger in production could cause a massive amount of data + * that will flood the logs. + * * @var LoggerInterface */ private $logger; @@ -63,7 +67,7 @@ public function report(array $spans): void try { $client($payload); } catch (RuntimeException $e) { - $this->logger->error($e->getMessage()); + $this->logger->error(sprintf('failed to report spans: %s', $e->getMessage())); } } } diff --git a/src/Zipkin/Reporters/Http/CurlFactory.php b/src/Zipkin/Reporters/Http/CurlFactory.php index 4d411d8e..bd93b1bf 100644 --- a/src/Zipkin/Reporters/Http/CurlFactory.php +++ b/src/Zipkin/Reporters/Http/CurlFactory.php @@ -39,8 +39,9 @@ public function build(?array $options = []): callable return static function ($payload) use ($options) { $handle = curl_init($options['endpoint_url']); if ($handle === false) { - return static function () { - }; + throw new RuntimeException( + sprintf('failed to create the handle for url "%s"', $options['endpoint_url']) + ); } curl_setopt($handle, CURLOPT_POST, 1);