Skip to content

Commit

Permalink
Skip creating the labels info until there are labels. (#542)
Browse files Browse the repository at this point in the history
Revert extension name change in test
  • Loading branch information
chingor13 authored and dwsupplee committed Jun 16, 2017
1 parent d75e733 commit f0856c7
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Trace/TraceSpan.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class TraceSpan implements \JsonSerializable
public function __construct($options = [])
{
$this->info = $this->pluckArray(
['spanId', 'kind', 'name', 'parentSpanId', 'labels'],
['spanId', 'kind', 'name', 'parentSpanId'],
$options
);

Expand All @@ -78,6 +78,10 @@ public function __construct($options = [])
$this->setEnd($options['endTime']);
}

if (array_key_exists('labels', $options)) {
$this->addLabels($options['labels']);
}

$this->info += [
'kind' => self::SPAN_KIND_UNSPECIFIED
];
Expand Down
7 changes: 7 additions & 0 deletions tests/unit/Trace/TraceSpanTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@ public function testNoLabels()
$this->assertArrayNotHasKey('labels', $info);
}

public function testEmptyLabels()
{
$traceSpan = new TraceSpan(['labels' => []]);
$info = $traceSpan->info();
$this->assertArrayNotHasKey('labels', $info);
}

public function testGeneratesDefaultSpanName()
{
$traceSpan = new TraceSpan();
Expand Down

0 comments on commit f0856c7

Please sign in to comment.