From c913ee6786486e25595f70091485918c1c530d7f Mon Sep 17 00:00:00 2001 From: Eligijus Vitkauskas Date: Sun, 25 Feb 2018 16:58:38 +0200 Subject: [PATCH] Introduce setTag method for a Span interface and get rid of setTags Having setTags instead of setTag means that you would have to be aware of tags that are set in order to add aditional tag to a span. But that is not the case if we expose an interface to set just a single tag. All other opentracing libraries also have setTag exposed instead of setTags so this helps to have more consistency between libraries. Closes #51 --- src/OpenTracing/NoopSpan.php | 2 +- src/OpenTracing/Span.php | 10 ++++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/OpenTracing/NoopSpan.php b/src/OpenTracing/NoopSpan.php index 6ca78f2..5ab510f 100644 --- a/src/OpenTracing/NoopSpan.php +++ b/src/OpenTracing/NoopSpan.php @@ -42,7 +42,7 @@ public function overwriteOperationName($newOperationName) /** * {@inheritdoc} */ - public function setTags(array $tags) + public function setTag($key, $value) { } diff --git a/src/OpenTracing/Span.php b/src/OpenTracing/Span.php index b1dbfc8..75b2d55 100644 --- a/src/OpenTracing/Span.php +++ b/src/OpenTracing/Span.php @@ -45,17 +45,19 @@ public function finish($finishTime = null, array $logRecords = []); public function overwriteOperationName($newOperationName); /** - * Sets tags to the Span in key => value format, key must be a string and tag must be either - * a string, a boolean value, or a numeric type. + * Adds a tag to the span. + * + * If there is a pre-existing tag set for key, it is overwritten. * * As an implementor, consider using "standard tags" listed in {@see \OpenTracing\Tags} * * If the span is already finished, a warning should be logged. * - * @param array $tags + * @param string $key + * @param string|bool|int|float $value * @return void */ - public function setTags(array $tags); + public function setTag($key, $value); /** * Adds a log record to the span in key => value format, key must be a string and tag must be either