Skip to content

Commit a879f80

Browse files
committed
Added isSampled to Context, delegate isSmapled to Context from Span
1 parent 86ae7e0 commit a879f80

2 files changed

Lines changed: 7 additions & 6 deletions

File tree

src/Span/Context/SpanContext.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ public function getParentId(): int
4444
return $this->parentId;
4545
}
4646

47+
public function isSampled(): bool
48+
{
49+
return (bool)($this->flags & 0x01);
50+
}
51+
4752
public function isDebug(): bool
4853
{
4954
return (bool)($this->flags & 0x02);

src/Span/Span.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ public function __construct(
3333
$this->flags = $context->getFlags();
3434
$this->operationName = $operationName;
3535
$this->startTime = $startTime;
36-
3736
$this->tags = $tags;
3837
$this->logs = $logs;
3938
parent::__construct();
@@ -42,14 +41,11 @@ public function __construct(
4241
public function __destruct()
4342
{
4443
if (null !== $this->duration) {
45-
return $this;
44+
return;
4645
}
4746
$this->tags[] = new ErrorTag();
4847
$this->tags[] = new OutOfScopeTag();
49-
5048
$this->tracer->finish($this);
51-
52-
return $this;
5349
}
5450

5551
public function getContext(): ?SpanContext
@@ -59,7 +55,7 @@ public function getContext(): ?SpanContext
5955

6056
public function isSampled(): bool
6157
{
62-
return (bool)($this->flags & 1);
58+
return $this->context->isSampled();
6359
}
6460

6561
public function start(int $startTimeUsec): SpanInterface

0 commit comments

Comments
 (0)