Skip to content

Commit

Permalink
Introduce setTag method for a Span interface and get rid of setTags
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ellisv committed Feb 25, 2018
1 parent 80012b4 commit c913ee6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/OpenTracing/NoopSpan.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function overwriteOperationName($newOperationName)
/**
* {@inheritdoc}
*/
public function setTags(array $tags)
public function setTag($key, $value)
{
}

Expand Down
10 changes: 6 additions & 4 deletions src/OpenTracing/Span.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c913ee6

Please sign in to comment.