From 4f29bcde740d8646bb4a790316bf46789c34f412 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Carlos=20Ch=C3=A1vez?= Date: Thu, 18 Jan 2018 20:17:42 +0100 Subject: [PATCH] Adds some usability tweaks. --- src/Zipkin/Reporters/Http.php | 4 +++- src/Zipkin/TracingBuilder.php | 12 ++++++++++-- tests/Unit/TracingBuilderTest.php | 17 ++++++++++++++--- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/src/Zipkin/Reporters/Http.php b/src/Zipkin/Reporters/Http.php index ffc194b7..d8732d42 100644 --- a/src/Zipkin/Reporters/Http.php +++ b/src/Zipkin/Reporters/Http.php @@ -55,7 +55,9 @@ public function report(array $spans) $client = $this->clientFactory->build($this->options); $client($payload); } catch (Exception $e) { - $this->logger->info($e->getMessage()); + $this->logger->error( + sprintf('Failed to report spans: %s', $e->getMessage()) + ); } } } diff --git a/src/Zipkin/TracingBuilder.php b/src/Zipkin/TracingBuilder.php index dbbe7c8d..d539bd8f 100644 --- a/src/Zipkin/TracingBuilder.php +++ b/src/Zipkin/TracingBuilder.php @@ -123,15 +123,23 @@ public function havingTraceId128bits($usesTraceId128bits) return $this; } + /** + * @param CurrentTraceContext $currentTraceContext + * @return $this + */ public function havingCurrentTraceContext(CurrentTraceContext $currentTraceContext) { $this->currentTraceContext = $currentTraceContext; return $this; } - public function beingNoop() + /** + * @param bool $isNoop + * @return $this + */ + public function beingNoop($isNoop = true) { - $this->isNoop = true; + $this->isNoop = $isNoop; return $this; } diff --git a/tests/Unit/TracingBuilderTest.php b/tests/Unit/TracingBuilderTest.php index 17fa3c6f..c0cd4a86 100644 --- a/tests/Unit/TracingBuilderTest.php +++ b/tests/Unit/TracingBuilderTest.php @@ -21,7 +21,10 @@ public function testCreatingTracingWithDefaultValuesSuccess() $this->assertEquals(false, $tracing->isNoop()); } - public function testCreatingTracingIncludesExpectedValues() + /** + * @dataProvider boolProvider + */ + public function testCreatingTracingIncludesExpectedValues($isNoop) { $endpoint = Endpoint::createAsEmpty(); $reporter = new Noop(); @@ -36,11 +39,19 @@ public function testCreatingTracingIncludesExpectedValues() ->havingSampler($sampler) ->havingTraceId128bits($usesTraceId128bits) ->havingCurrentTraceContext($currentTraceContext) - ->beingNoop() + ->beingNoop($isNoop) ->build(); $this->assertInstanceOf(Tracing::class, $tracing); - $this->assertEquals(true, $tracing->isNoop()); + $this->assertEquals($isNoop, $tracing->isNoop()); + } + + public function boolProvider() + { + return [ + [true], + [false] + ]; } private function randomBool()