Skip to content
This repository has been archived by the owner on Aug 18, 2021. It is now read-only.

Commit

Permalink
serialize status restore fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nekufa committed Feb 13, 2020
1 parent 44df6b7 commit 8d835c5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 deletions.
4 changes: 4 additions & 0 deletions src/Exporter/BasisExporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ public function restoreSpan(array $source): Span

$span->setInterval($start, $end);

if ($end !== null && !$span->getStatus()) {
$span->setStatus(new Status(Status::OK));
}

if ($statusCode) {
$span->setStatus(new Status($statusCode));
}
Expand Down
20 changes: 2 additions & 18 deletions tests/TracingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -249,24 +249,8 @@ public function testBasisConverter()

$exporter = new BasisExporter();
$row = $exporter->convertSpan($span);
$this->assertSame($row['traceId'], $span->getSpanContext()->getTraceId());
$this->assertSame($row['spanId'], $span->getSpanContext()->getSpanId());
$this->assertSame($row['parentSpanId'], $span->getParentSpanContext()->getSpanId());

$this->assertNotNull($row['body']);
$unserialized = unserialize($row['body']);
$this->assertSame($unserialized->getName(), $span->getName());
$this->assertSame($unserialized->getAttributes(), $span->getAttributes());

$this->assertSame(
$unserialized->getEvents()[0]->getName(),
$span->getEvents()[0]->getName()
);

$this->assertSame(
$unserialized->getEvents()[0]->getTimestamp(),
$span->getEvents()[0]->getTimestamp()
);
$span2 = $exporter->restoreSpan($row);
$this->assertSame(serialize($span), serialize($span2));
}

public function testZipkinConverter()
Expand Down

0 comments on commit 8d835c5

Please sign in to comment.