Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip creating the labels info until there are labels. #542

Merged
merged 1 commit into from
Jun 16, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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