diff --git a/src/Zipkin/Reporters/Http.php b/src/Zipkin/Reporters/Http.php index 5888c7d7..98e73e35 100644 --- a/src/Zipkin/Reporters/Http.php +++ b/src/Zipkin/Reporters/Http.php @@ -36,7 +36,7 @@ public function __construct( ) { $this->clientFactory = $requesterFactory ?: CurlFactory::create(); $this->options = array_merge(self::DEFAULT_OPTIONS, $options); - $this->reportMetrics = $reporterMetrics; + $this->reportMetrics = $reporterMetrics ?: new NoopMetrics(); } /** diff --git a/src/Zipkin/Reporters/Http/CurlFactory.php b/src/Zipkin/Reporters/Http/CurlFactory.php index 81768cd3..ab47e298 100644 --- a/src/Zipkin/Reporters/Http/CurlFactory.php +++ b/src/Zipkin/Reporters/Http/CurlFactory.php @@ -7,6 +7,10 @@ final class CurlFactory implements ClientFactory { + private function __construct() + { + } + /** * @return CurlFactory * @throws \BadFunctionCallException if the curl extension is not installed. diff --git a/tests/Unit/Reporters/HttpTest.php b/tests/Unit/Reporters/HttpTest.php index 1c9e2abf..327dc364 100644 --- a/tests/Unit/Reporters/HttpTest.php +++ b/tests/Unit/Reporters/HttpTest.php @@ -16,6 +16,12 @@ final class HttpTest extends PHPUnit_Framework_TestCase const PAYLOAD = '[{"id":"%s","name":null,"traceId":"%s","parentId":null,' . '"timestamp":null,"duration":null,"debug":false,"localEndpoint":{"serviceName":""}}]'; + public function testCreateHttpReporterWithDefaultDependencies() + { + $httpReporter = new Http(); + $this->assertInstanceOf(Http::class, $httpReporter); + } + public function testHttpReporterSuccess() { $context = TraceContext::createAsRoot();